Incompatible magic value - corrupted fatjar created by Maven Vertx plugin?

93 views
Skip to first unread message

Mik Quinlan

unread,
Feb 17, 2015, 6:14:42 AM2/17/15
to ve...@googlegroups.com
Hi All

I'm trying to create a Vertx fat jar using the Vertx Maven pluging 2.0.11-final and Java 1.8.0_25 on OSX.

When i try to run the fat jar using java -jar I get a weird error suggesting the jar is corrupted. 

Does anybody have any ideas?

Thanks in advance.

Mik

Error

 java -jar target/myjar-1.0-UWD-2-SNAPSHOT-fat.jar
Feb 17, 2015 11:07:25 AM org.vertx.java.platform.impl.cli.Starter
SEVERE: Failed in deploying module
java.lang.ClassFormatError: Incompatible magic value 4022320623 in class file package/to/RoutingServer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at org.vertx.java.platform.impl.ModuleClassLoader.doLoadClass(ModuleClassLoader.java:136)
at org.vertx.java.platform.impl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:121)
at org.vertx.java.platform.impl.ModuleClassLoader.loadClass(ModuleClassLoader.java:108)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.vertx.java.platform.impl.java.JavaVerticleFactory.createVerticle(JavaVerticleFactory.java:55)
at org.vertx.java.platform.impl.DefaultPlatformManager$21.run(DefaultPlatformManager.java:1748)
at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:175)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:370)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
at java.lang.Thread.run(Thread.java:745)

Plugin config

<plugin>
<groupId>io.vertx</groupId>
<artifactId>vertx-maven-plugin</artifactId>
<version>2.0.11-final</version>
<configuration>
<configFile>${mods.directory}/${module.name}/routes.json</configFile>
<instances>1</instances>
<!--<classpath>src/main/resources/:src/test/resources/:target/classes/:target/test-classes/</classpath>-->
</configuration>
<!-- Make sure that the plugin uses the vert.x versions from this pom.xml not from its own pom.xml -->
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-platform</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-hazelcast</artifactId>
<version>${vertx.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>pull-in-deps</id>
<phase>prepare-package</phase>
<goals>
<goal>pullInDeps</goal>
</goals>
</execution>
<execution>
<id>create-fat-jar</id>
<phase>package</phase>
<goals>
<goal>fatJar</goal>
</goals>
</execution>
</executions>
</plugin>


Alexander Lehmann

unread,
Feb 17, 2015, 6:39:04 AM2/17/15
to ve...@googlegroups.com
that is not an error in the zip, rather it looks like an error in the class file included in the zip

you should be able to verify that the zip is correct with unzip -t file.jar, anything else is probably a java incompatibility

Jez P

unread,
Feb 17, 2015, 7:57:47 AM2/17/15
to ve...@googlegroups.com

Jez P

unread,
Feb 17, 2015, 7:59:49 AM2/17/15
to ve...@googlegroups.com
This might also be similar? https://github.com/dynjs/dynjs-vertx-module/issues/2 (filtering in the maven pom looks responsible)


On Tuesday, February 17, 2015 at 11:39:04 AM UTC, Alexander Lehmann wrote:

Mik Quinlan

unread,
Feb 17, 2015, 8:31:02 AM2/17/15
to ve...@googlegroups.com
Hey Alex,

Thanks for that tip.  Helped diagnose the problem.

Mik Quinlan

unread,
Feb 17, 2015, 8:32:26 AM2/17/15
to ve...@googlegroups.com
Hey Jez,

That was exactly it.

<resource>
  <directory>target/classes</directory>
  <filtering>true</filtering>
</resource>

was causing the problem.  Resolved by setting filtering to false.

Thanks again to both you and Alex for the prompt responses!

Mik

Jez P

unread,
Feb 17, 2015, 8:50:29 AM2/17/15
to ve...@googlegroups.com
Nice one, if I'd had more time I'd have dug a bit deeper to try and find out why filtering appears to mess classes up. Weirdly we didn't have the same problem when we were using vert.x 2 (and the vertx maven plugin) - we were using OS X, but not sure if we were using the same Java 8 version. We've moved our code to vert.x 3 now, so I'm not planning on looking back at the past to see exactly how what we had in place differed.

Glad you're back up and running!

Jez

Mik Quinlan

unread,
Feb 17, 2015, 9:15:01 AM2/17/15
to ve...@googlegroups.com
Yep, we're planning on evaluating and hopefully moving to Vertx 3 once it has come out and been battle tested a bit.  We are about to deploy Vertx 2 in an environment where it will handle 8000 requests per second.  Not a huge amount, but Vertx's latency and standard deviation in performance was only surpassed by Go in our tech evals.  Nice work!
Reply all
Reply to author
Forward
0 new messages