Setting up IntelliJ 11.1 for Vertx

2,222 views
Skip to first unread message

spriet

unread,
Jun 23, 2012, 1:27:06 PM6/23/12
to vert.x
I am having some troubles running a Java Vertx application from
IntelliJ.

Steps I took..

1. Create a new project from scratch
2. Create a Java Module (JVM based)
3. Src directory
4. Project is created

..

1. In the Project structure I added the Vertx lib jars folder
2. I add a Server.java file containing the Java Hello World example
from the homepage.

.. compile ok!

1. Open up the Run configuration
2. I select the Application configuration
3. I specify the main class as :
org.vertx.java.deploy.impl.cli.Starter
4. Program arguments : run src/Server.java
5. use classpath of module .. the only module selectable

.. try running it will throw the following exception:

SEVERE: Failed to create verticle
java.lang.IllegalStateException: Do not add application classes to the
vert.x classpath

Thats true, its added i can see it in the run log.

But I can't find a way to not add the vertx to the classpath, since i
need the lib for the imports.

Does anyone know how to solve this?

Greetings Rene





Tim Fox

unread,
Jun 23, 2012, 1:57:17 PM6/23/12
to ve...@googlegroups.com
As yet we haven't worked on any IDE integration, so your best bet is to
run it from the command line.
Message has been deleted
Message has been deleted

spriet

unread,
Jun 24, 2012, 9:33:21 AM6/24/12
to ve...@googlegroups.com
To debug Groovy applications within IntelliJ, is less problematic.

A good desciption can be found here:

http://blog.developer-b.com/post/22846036353/debuging-vertx-application-from-idea#disqus_thread




spriet

unread,
Jun 24, 2012, 11:50:01 AM6/24/12
to ve...@googlegroups.com
I found a way to debug JAVA from IntelliJ.


First you need to disable the idea runner. Disable the idea launcher by setting the idea.no.launcher to true.

#---------------------------------------------------------------------
# Configure if a special launcher should be used when running processes from within IDE.
# Using Launcher enables "soft exit" and "thread dump" features
#---------------------------------------------------------------------
idea.no.launcher=true

You might have to search for this setting. This setting is global and cannot be set per project, see also http://devnet.jetbrains.net/docs/DOC-181 and http://devnet.jetbrains.net/docs/DOC-197.

Restart your IntelliJ to reload the settings.

Create a new empty JAVA project with a src folder. Add a lib folder containing the vertx libraries and dependances.

In project structure add the vertx libraries to your project.
Set the scope of the vertx libraries as compile. They need to end up in your output folder.

Create a Server.java file containing the example source code from the vertx homepage.

Go to the Run/ Edit Configuration and create a new configuration based on Application.

The settings are:

Keep the main class empty.

Set the VM options (replace paths with your paths) :

-classpath /Users/someone/projectfolder/lib/* org.vertx.java.deploy.impl.cli.Starter run /Users/someone/projectfolder/src/Server.java -cp=/Users/someone/projectfolder/out/production/projectfolder/

Keep program arguments, Environment paths empty
Keep Working directory as it is.
Use the classpath of your project.

I just tested the HelloWorld application I could start and debug the application.

Greetings Rene





























N8

unread,
Jun 25, 2012, 9:51:40 AM6/25/12
to ve...@googlegroups.com
There is a MUCH simpler way to do this if you are using maven: 
 1) Setup the vertx maven plugin in your pom (https://github.com/rhart/vertx-maven-plugin)
 2) Add a new Maven Run Configuration, and make the goal vertx:run
 3) Press the debug button and your off and debugging.


As a side note, you can set this up with out maven and without changing launcher settings by adding a new dummy module to you project which has all the vertx classpaths but none the ones from your vertx modules (simply add all the jars in the vertx/lib dir, and delete the content root of the dummy module). Then setup a run configuration that mimics the arguments the src/script/vertx script. So the Program Arguments section would look like: 

org.vertx.java.deploy.impl.cli.VertxMgr run -cp ../verticle_module/classes

It is very important that you chose the new dummy module as the module classpath to use for the Run Configuration. This dummy module has all the classes in the classpath to run Vertx but none of the ones from your Verticles which would cause  Vertx to throw  an IllegalStateException complaining "Do not add application classes to the 
vert.x classpath " - for which I strongly think an option to disable via a system property as we can see it complicates the heck of out testing and debugging. 

davem

unread,
Jun 25, 2012, 11:45:09 AM6/25/12
to ve...@googlegroups.com
Thanks, will have to try that.

I am currently using Vertx in 'embedded mode', ie: without Verticles, so that I can debug in Intellij, just like any other java application.

ie: ia java application which creates vertx, configures the routes, eventbus, socket handlers, etc., starts listening on the ports, and creates a non-daemon thread loop sleeping for several seconds, (in order to stop vertx's daemon threads from exiting the app).

spriet

unread,
Jun 25, 2012, 12:51:06 PM6/25/12
to ve...@googlegroups.com
Thanks N8, I will try it !

Great to share this kind of information, so other beginners will not suffer for 3,13 hours like I did.

+1 for a more intelligent 'Do not add application classes to the vert.x classpath' feature. ;-)

Greetings Rene

Mario Gutierrez

unread,
Jun 26, 2012, 3:42:53 AM6/26/12
to ve...@googlegroups.com
This seems to work for me. Simply `git clone https://github.com/mgutz/vertx-web-hello` and open her up in IntelliJ. 
Reply all
Reply to author
Forward
0 new messages