Javassist: unavailable and ClassNotFoundException

1,538 views
Skip to first unread message

mathias

unread,
Aug 17, 2014, 11:05:13 AM8/17/14
to ve...@googlegroups.com
I have problems running "mvn clean vertx:runMod" on the "PingVerticle-App":

[DEBUG] Javassist: unavailable
[DEBUG] You don't have Javassist in your class path or you don't have enough permission to load dynamically generated classes.  Please check the configuration for better performance.
[DEBUG] -Dio.netty.tmpdir: C:\Users\Mathias\AppData\Local\Temp (java.io.tmpdir)
[DEBUG] -Dio.netty.bitMode: 64 (sun.arch.data.model)
[DEBUG] -Dio.netty.noPreferDirect: false
[DEBUG] -Dio.netty.noKeySetOptimization: false
[DEBUG] -Dio.netty.selectorAutoRebuildThreshold: 512
[ERROR]
java.lang.ClassNotFoundException: com.test.PingVerticle
    at org.vertx.java.platform.impl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:127)
    at org.vertx.java.platform.impl.ModuleClassLoader.loadClass(ModuleClassLoader.java:108)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.vertx.java.platform.impl.java.JavaVerticleFactory.createVerticle(JavaVerticleFactory.java:55)
    at org.vertx.java.platform.impl.DefaultPlatformManager$21.run(DefaultPlatformManager.java:1733)
    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:353)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    at java.lang.Thread.run(Unknown Source)

What is Javassist?
What does a ClassNotFoundException mean in the world of vertx?

Alexander Lehmann

unread,
Aug 17, 2014, 12:03:04 PM8/17/14
to ve...@googlegroups.com
Javassist you can ignore, this is only warning. This is used in netty to improve performance in some way, but it will work without. I think Javassist is a library for byte code manipulation.

ClassNotFoundException means exactly what it says, you are trying to call a call "com.test.PingVerticle", but your project doesn't have that class. You can check the main class in mod.json, that should be the same a your main verticle class in src/main/java

mathias

unread,
Aug 17, 2014, 5:26:40 PM8/17/14
to ve...@googlegroups.com
I like to setup my tools (eclipse+m2e) in a way to get the best "vert.x module development experience" possible :-)

But I still don't know what is causing the ClassNotFoundException. Maybe it happened bacause I renamed the .java file (changing the package name), which is maybe not reflected to the maven local repository somehow?
Which mod is actually run when using the command "mvn clean vertx:runMod"? The mod in the local maven repo, the mod-jar inside target/mods or jar inside target/, or the zip file inside target/, or something else? As far as I understood it this command should do the trick for the autodeploy feature.

Alexander Lehmann

unread,
Aug 17, 2014, 5:37:59 PM8/17/14
to ve...@googlegroups.com
vertx:runMod will run the sources (or rather the compiled sources), not the packaged module or the module in the local maven repo. Autodeply will take care of recompiling the changed sources later.

If you have renamed the example file, you have to change the main classname in src/main/resources/mod.json with the same name. The maven archetype creates a class with the given package name and PingVerticle.java.

mathias

unread,
Aug 18, 2014, 3:33:34 PM8/18/14
to ve...@googlegroups.com
Hi Alexander, thank you for the answer. I checked the main class in mod.json. It has the same FQCN as my java file. The problem seems to be that the command "mvn clean vertx:runMod" does not generate class files in target/classes before runMod gets called. So the java source file have never been compiled.

How is this command supposed to work, if it does not compile java files? Maybe vert.x compiles java files on-the-fly?
So I changed the command to "mvn clean compile vertx:runMod" and now it can run the mod without errors.

The autodeploy feature also works provided that "Build Automatically" is checked in eclipse. Without "Build Automatically" file changes are only detected inside src/main/resources. Changes inside src/main/java are not detected. When vertx detectes changes on the module it prints out this message:
INFO: Module com.test~pingme~1.0 has changed, reloading it.

Currently my eclipse does not generate class files in target/classes when creating or changing java files. So I wonder how autodeploy actually works. However, it works great :-)

Alexander Lehmann

unread,
Aug 18, 2014, 6:22:08 PM8/18/14
to ve...@googlegroups.com
vertx:runMod does not compile the classes, to run the classes after compiling you have to do mvn package vertx:runMod
after that, the autoreload should work.

Tim Fox

unread,
Aug 19, 2014, 3:18:56 AM8/19/14
to ve...@googlegroups.com
On 18/08/14 23:22, Alexander Lehmann wrote:
vertx:runMod does not compile the classes, to run the classes after compiling you have to do mvn package vertx:runMod

actually, no.

It's your *IDE* that compiles the files. It's all in the docs:

http://vertx.io/dev_guide.html#run-your-module-and-see-your-changes-immediately

Note:

"Now, make sure your IDE has built your project at least once (e.g. hit CTRL-F9 in IntelliJ IDEA)."

^^ This is the step that is often forgotten. (BTW search for this topic on this group and you will get many hits as it's been answered many times before ;) )

To paraphrase.. All you need to do is:

1. Git clone the project
2. Generate the project files - ./gradlew idea
3. Open the files (note: *open* not *import*) the project in IDEA
4. Make the IDE compile the files (CTRL-F9). Better still set your project to auto-compile on save (Go to settings... compiler)
5. At command line: ./gradlew runMod -i

That's it

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexander Lehmann

unread,
Aug 19, 2014, 1:44:04 PM8/19/14
to ve...@googlegroups.com
does this apply to maven as well?

doing mvn clean vertx:runMod will not work since it removes the target dir, so mvn clean package vertx:runMod should work. When the IDE recompiles the files, I assume they end up in the target dir as well.

Tim Fox

unread,
Aug 19, 2014, 1:46:38 PM8/19/14
to ve...@googlegroups.com
Are the instructions in the docs not working for you?

Alexander Lehmann

unread,
Aug 19, 2014, 2:40:53 PM8/19/14
to ve...@googlegroups.com
Everything is working for me, I assume that Mathias had problems running his project in connection with the IDE.

Alexander Lehmann

unread,
Aug 19, 2014, 3:04:53 PM8/19/14
to ve...@googlegroups.com
Sorry, I found the place where the information is wrong, on the page http://vertx.io/dev_guide.html, the suggested command is

mvn clean vertx
:runMod

that doesn't work, correct is


mvn clean compile vertx
:runMod

Tim Fox

unread,
Aug 19, 2014, 3:13:02 PM8/19/14
to ve...@googlegroups.com
You shouldn't do mvn compile - it's the IDE that's supposed to do the compiling.

Can you tell me the _exact_ sequence of steps you did? (Including git clone, open project in IDE etc)

Alexander Lehmann

unread,
Aug 19, 2014, 6:03:35 PM8/19/14
to ve...@googlegroups.com
mvn archetype:generate -Dfilter=io.vertx:
cd mvnproject
mvn install
-DskipTests=true
mvn eclipse
:eclipse

import the existing project into eclipse,
in the command shell

mvn clean vertx:runMod

this will not work since the clean task has just removed the target dir

Tim Fox

unread,
Aug 19, 2014, 6:12:42 PM8/19/14
to ve...@googlegroups.com


On 19/08/14 23:03, Alexander Lehmann wrote:
mvn archetype:generate -Dfilter=io.vertx:
cd mvnproject
mvn install
-DskipTests=true

Why are you doing mvn install? It doesn't mention this in the docs....


mvn eclipse:eclipse

import the existing project into eclipse,
in the command shell

mvn clean vertx:runMod

this will not work since the clean task has just removed the target dir

That's because you need to build in the IDE (I'll mention it again!) :

" Now open your project file in your IDE, and set your project in your IDE to automatically compile when source files are saved - how to do this depends on your particular IDE so consult your IDE documentation if in doubt."

Let me just paraphrase:

1. mvn archetype:generate -Dfilter=io.vertx:
2. cd mvnproject
3. Open project in IDE.
4. Build it
5. mvn clean vertx:runMod

Does this not work? (This is what is in the docs)

Alexander Lehmann

unread,
Aug 19, 2014, 6:44:14 PM8/19/14
to ve...@googlegroups.com
ok, i'll say again that the last step doesn't work.

mvn archetype:generate -Dfilter=io.vertx: -DgroupId=cx.lehmann.test -DartifactId=mvnproject -Dversion=1.0-SNAPSHOT

import maven project into eclipse
build maven project in eclipse, eclipse will compile the classes from here on automatically

mvn clean vertx:runMod

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project - mvnproject 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ mvnproject ---
[INFO] Deleting C:\Projects\vertx\newproject\mvnproject\target
[INFO]
[INFO] --- vertx-maven-plugin:2.0.7-final:runMod (default-cli) @ mvnproject ---
[ERROR]
java.lang.ClassNotFoundException: cx.lehmann.test.PingVerticle

        at org.vertx.java.platform.impl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:127)
        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:1733)
        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:353)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at java.lang.Thread.run(Thread.java:745)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.747 s
[INFO] Finished at: 2014-08-20T00:39:17+02:00
[INFO] Final Memory: 10M/176M
[INFO] ------------------------------------------------------------------------

this doesn't work with or without IDE, since clean removes the class files and then doesn't rebuild.

Tim Fox

unread,
Aug 20, 2014, 1:18:42 AM8/20/14
to ve...@googlegroups.com
Well, don't do the clean then!

Alexander Lehmann

unread,
Aug 20, 2014, 7:40:02 AM8/20/14
to ve...@googlegroups.com
Yes, that was my point, the docs say mvn clean vertx:runMod and that has to be changed

Tim Fox

unread,
Aug 20, 2014, 9:52:44 AM8/20/14
to ve...@googlegroups.com
Clean might be correct depending on how you have Eclipse configured. I believe the default place for eclipse to put its output classes is bin (or at least it used to be). If your eclipse is putting them in target then clean is going to delete them.

At the end of the day its pretty simple - take a look at vertx_classpath.txt - that should point to where your IDE has put its classes. Where that is depends from IDE to IDE and how's it configured.
Reply all
Reply to author
Forward
0 new messages