Problem when using redeploy in development

241 views
Skip to first unread message

Thomas Hirsch

unread,
Jan 28, 2016, 10:04:56 AM1/28/16
to vert.x

Hi, I wanted to try out the automatic redeploy on file change.

This is how it is suggested in the docs (http://vertx.io/docs/vertx-core/groovy/):

    vertx run MyVerticle.groovy --redeploy="**/*.groovy"


This is how I am trying it:

    vertx run src/main/groovy/start.groovy --redeploy="src/main/groovy/**/*.groovy*

I have also tried with different orders of the arguments, always the same error:

    Starting the vert.x application in redeploy mode
    Starting vert.x application...
    b4ed5825-b094-43e7-89f9-07efcbe77601-redeploy
    java.lang.ClassNotFoundException: run
    (... Stacktrace)

I am probably making a really dumb mistake, considering what the error tells me, but for the heck of me I am not seeing it...
If I leave out the run, I am getting '(whatever is first argument) is not a valid command', obviously

Thanks for help, and regards, 
Thomas

Message has been deleted

Thomas Hirsch

unread,
Jan 28, 2016, 10:14:35 AM1/28/16
to vert.x
It's really weird, even the simplest example (copied from the documentation) I cannot get to work.

$ vertx run test.groovy
hello from vertx
Succeeded in deploying verticle

$ vertx run test.groovy --redeploy="*.groovy"
Starting the vert.x application in redeploy mode
Starting vert.x application...
95750119-a35d-49f2-8191-9a45bbeb4f72-redeploy
java.lang.ClassNotFoundException: run

Thomas Hirsch

unread,
Jan 28, 2016, 10:31:33 AM1/28/16
to vert.x
I'm using MacOS right now, vert.x version 3.2.0, if that is of any concern, which I don't think it should because it is Java after all. I am really confused because the example is so simple...

Thomas Hirsch

unread,
Jan 28, 2016, 10:45:15 AM1/28/16
to vert.x
Using this method (https://github.com/vert-x3/vertx-examples/blob/master/gradle-redeploy/build.gradle) works.
What I would like though is make it work without having to rebuild the jar file every time during development. 
However another problem would be adding the dependency for the JDBC driver in the simple case, since it would normally be included in the fat jar.
Does anybody have a working setup for this case?

Clement Escoffier

unread,
Jan 28, 2016, 11:10:07 AM1/28/16
to ve...@googlegroups.com
Hi,

You need to set the —launcher-class parameter as explained on

Clement

--
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.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/5273917c-5d3c-425e-a0d3-c0d3ad68a902%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Hirsch

unread,
Jan 28, 2016, 11:39:43 AM1/28/16
to vert.x
Hello Clement!

Thanks for your reply, adding the launcher parameter, which btw is not mentioned in the groovy documentation I am looking at,  helped me to get further.
Now how to solve the problem of adding the JDBC driver to the classpath?

This is what I am doing: 

    vertx run src/main/groovy/start.groovy -conf=config/dev.json  --launcher-class=io.vertx.core.Launcher -cp ./lib/postgresql-9.4.1207.jre7.jar


The error is:

    Could not load driverClass org.postgresql.Driver


However, when I build a fat jar, and run that, the class is found.

Thanks for your help!

Clement Escoffier

unread,
Jan 28, 2016, 11:45:20 AM1/28/16
to ve...@googlegroups.com
Hi,

You are absolutely right about the groovy doc, a bit behind the java doc. Everything will be in order avec the 3.2.1 release. 

So about the postgres driver. The problems comes the C3PO connection pool that requires the driver to be in the (genuine) class path. So in your case as your are using the `vertx` command line, you should add the jar file to %VERTX_HOME/lib. Alternatively, you can edit the vertx-stack.json, add the dependency for the driver and launch:

vertx resolve --dir=lib --stack=./vertx-stack.json

Clement

--
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.
Visit this group at https://groups.google.com/group/vertx.

Thomas Hirsch

unread,
Jan 29, 2016, 9:40:20 AM1/29/16
to vert.x
Hi again, 
thanks for your reply! I solved the problem using a CLASSPATH environment variable, which gets picked up when the process restarts.

Regards, Thomas

Thomas Hirsch

unread,
Jan 29, 2016, 9:53:40 AM1/29/16
to vert.x
What also works is using the Gradle application plugin like this:
(compare https://github.com/vert-x3/vertx-examples/blob/master/gradle-redeploy/build.gradle )

def watchForChange = 'src/**/*.groovy'
def doOnChange = './gradlew classes'
def config = 'config/dev.json'
run {
    classpath = sourceSets.main.runtimeClasspath // this line is doing the trick ...
    args = ['run', mainVerticleName, "--redeploy=$watchForChange", "--launcher-class=$mainClassName", "--on-redeploy=$doOnChange", "-conf=$config"]
}

with

dependencies {
    compile "io.vertx:vertx-core:$version"
    compile "io.vertx:vertx-lang-groovy:$version"
    compile "io.vertx:vertx-jdbc-client:$version"
    runtime 'org.postgresql:postgresql:9.4.1207.jre7' // ... together with this declaration 
}

After working with NodeJS exclusively for 1.5years now, I am looking back again into Vert.x. I am setting up an example (HTTP + websocket) backend project, with some development niceties, and a registration based on email and JWT. I will share it when I'm done!
Reply all
Reply to author
Forward
0 new messages