Reduce noise in an onejar FatJar

Posted: May 15, 2015 in Java
Tags: ,

When you’re using onejar 1.4.5 or above you want to turn off the noise the bootloader makes.

java -Done-jar.verbose=false -jar service.jar
Advertisements

Vertx3 is nearing its release date and we’re experimenting with the upcoming release to minimize future surprises. One of the major changes is the generation of fatjars. The Vertx2 fatJar plugin doesn’t exist anymore in the Vertx 3 world. Now Vertx 3 uses the maven-shade-plugin to generate the fat JAR. Unfortunately, the shader has its own problems. For example, it is very cumbersome to handle duplicate files especially in transitive dependencies which are something out of your control.

When you’re running into unsolvable errors with the maven-shade-plugin, you can easily switch to the onejar-maven-plugin. Configure your POM as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <archive>
            <manifestEntries>
                <Main-Class>io.vertx.core.Starter</Main-Class>
                <Main-Verticle>io.vertx.example.HelloWorldVerticle</Main-Verticle>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>
<plugin>
    <groupId>org.dstovall</groupId>
    <artifactId>onejar-maven-plugin</artifactId>
    <version>1.4.5</version>
    <executions>
        <execution>
            <configuration>
                <attachToBuild>true</attachToBuild>
                <filename>service.jar</filename>
            </configuration>
            <goals>
                <goal>one-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

This will create a new fat JAR with the project JARs as a complete file on the inside. They are not unpacked, so there are no issues with overwriting files in the META-INF. The downside is that they use an own boot-mechanism.

This again has some problems when for example certain JARs use the SPI mechanism or self-cooked mechanisms to load classes.

Ubuntu 15.04 and Handbrake

Posted: May 2, 2015 in Ubuntu
Tags: , , ,

And again, when watching DVDs does not work on Ubuntu 15.04, you must install the restricted codecs (ubuntu-restricted-extras). After that you must install libdvdcss2 which is not in the repositories (for some strange reason). Even though I installed it in 14.10, after the upgrade it was not installed anymore. You have to run the following command on a terminal:

$ sudo /usr/share/doc/libdvdread4/install-css.sh

This fixed Handbrake for me once again.

Ubuntu 15.04 and Docker 1.6.0

Posted: April 27, 2015 in Docker, Ubuntu
Tags: , , ,

When you upgrade to Ubuntu 15.04 and install docker using the get.docker.io script, you’ll probably run into an error like “Are you trying to connect to a TLS-enabled daemon without TLS?”.

Ubuntu 15.04 changed to systemd and you should enable docker with this command:

$ systemctl enable docker

Restart your computer, and it should be working.

OpenVPN on 14.10

Posted: March 23, 2015 in Ubuntu
Tags: ,

When you run into the issue that the NetworkManager is not starting your connection (nothing happens when you click on the VPN connection in the applet), you’ll see the following line in the syslog:

No agents were available for this request

When you start the connection from the CLI, you get the following error

$ sudo nmcli -p con up id YourConnection

Error: Connection activation failed: no valid VPN secrets.

Now, there are solutions available for password connection, but none when you work with certificates. You can use a workaround by editing the configuration file yourself. You can find it here:

/etc/NetworkManager/system-connections/YourConnection

Open the file and add or overwrite the following lines:

[vpn]

service-type=org.freedesktop.NetworkManager.openvpn
connection-type=tls
username=YourName

auth=SHA1
remote= ######
cipher=AES-256-CBC
comp-lzo=yes
cert-pass-flags=0
port= ######
cert=path-to-your.p12
ca=path-to-your.p12
key=path-to-your.p12

[vpn-secrets]
cert-pass=YourPasswordForThisConnection

Restart your command, and VPN should be up and running.

Easy streaming in Vertx.io

Posted: March 9, 2015 in Java
Tags: ,

If you want to stream an incoming request, you can use the following code:

    final Handler<HttpServerRequest> streamer = (HttpServerRequest request) -> {
        HttpServerResponse response = request.response();

        container.logger().info("Streaming... ");
        long ts = System.currentTimeMillis();

        // handle the content
        request.dataHandler((Buffer data) -> {
            container.logger().info("Received " + data.length());

        });

        request.endHandler(v -> {
            container.logger().info("Done! " + (System.currentTimeMillis() - ts));
            request.response().end();
        });

        // handle upload errors
        request.exceptionHandler(
                (Throwable throwable) -> {
                    throwable.printStackTrace();
                    response.setStatusCode(HttpResponseStatus.BAD_REQUEST.code()).end();
                }
        );
    };

GoCD and Docker

Posted: January 25, 2015 in Uncategorized

I’m currently working on a Docker-plugin for GoCD. You can find the project right here. Since GoCD 15 has a different plugin-api, I will release a new plugin soon.