Vert.x fails to "Run your module and see your changes immediately" - java

I am working with the Vert.x Gradle template hosted at the Vert.x Github space.
The build file suggests that there is a runModIDEA target that runs IDEA-built class files so that rebuild/redeploy is not required to pick up changes:
runModIDEA - run the module from the project resources in IDEA. This allows you to run the module without building it
first!
... yet the task does not exist per ./gradlew tasks.
I am not tied to this particular build task per se.
I just want a working auto-redeploy solution that enables me to see updates without a two minute rebuild/redeploy cycle.
EDIT: I also tried running it directly, pointing to InteliJ IDEA output classpath. It works fine, but doesn't pick up changes.
vertx runmod com.mycompany~vert-x-reverse-proxy~1.0.0-final -c conf.json -cp out/production/vert-x-reverse-proxy
EDIT: I also tried ./gradlew runmod -m, first changing vertx_classpath.txt so that the IDEA files (out/production) are looked at first. Still no redeploy. In fact, while it was running, I deleted the out directory and it continued working.
EDIT: I also tried vertx run com.mycompany.myproject.ReverseProxyVerticle -c conf.json -cp out/production/vert-x-reverse-proxy... same results. It ran as expected but did not pick up changes. Only way to pick up changes was to gradlew clean and re-assemble.
EDIT: I have been through these instructions as well.

For anyone who stumbles upon this question, I had the same problem and managed to fix it by deleting everything under the /mods folder in the /target directory. This is in fact mentioned in the vertx documentation - though maybe could be a little more emphatic. Once everything under /mods is removed, start up the application and it redeploys whenever anything is changed.

If you are new to vertx and stumble with this problem or similar, it might be worth to have a look at this vertx google group entry. It describes the changes that need to be done to the generated project by the Vertx Gradle Template to get it running.
I know, this does not answer directly the question posted here but I hope it helps you further.

Related

Spring Boot Azure Deployment Unable to Update Code

I have followed step by step instruction for this document. And it works perfectly fine.
However, I tried changing the return from "Greetings from Spring Boot!" to "Greetings from Spring Boot! v2.0" and made necessary changes (on tests). And then ran mvn clean package to remove any existing jar and create a new one and finally ran ./mvnw azure-webapp:deploy it does update the existing web service. And also states "BUILD Success"
Not sure where am i going wrong.
Just as hujtomi said in the comment, every time the maven deploy task will create different web app. Could you please have a check with that?
Alright, here is the solution - pretty simple. Basically you need to change version under pom.xml i.e.
<groupId>org.springframework</groupId>
<artifactId>gs-spring-boot</artifactId>
<version>0.1.1</version>
update version value every time you want to publish. thanks to #hujtomi however you need to do one more thing. i.e. change the value under web.config under httpPlatform
by default it will point to 0.1.0 version, but you will need to change to 0.1.1 (basically to the version that you want).
In that way, it is actually quite good, so if there are any crashes, you can simply roll back to prev. version.
-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\gs-spring-boot-0.1.0.jar"
to
-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\gs-spring-boot-0.1.1.jar"

YAJSW - Startup script to clear .lck files

We use YAJSW (11.08) to wrap our java application as a service, but when switching to java 8, I noticed that if the application did not terminate gracefully, the .lck files generated by the logger, is not cleared.
We are in the process of switching to a new logger, but in the mean time I need a start up script to clear these .lck files.
I read here that YAJSW supports shell and groovy scritps, but the answer to this SO question answer claims it only supports groovy scripts.
As far as I can tell I need to indicate the STATE at which the script will be executed, so for me I assume that it's the START
state.
I have added this to my wrapper.conf:
wrapper.script.START=scripts/clean-up.bat
What am I missing or doing wrong? Is running scripts not available in the version I'm using? Or are shell scripts really not supported?
EDIT: Updated YAJSW to version 11.11 (latest) - still does not work
run the process from the console and see what error messages you get. I am running 11.11 with java 8 and I noticed that even though documentation specifies you want to say this:
wrapper.script.START=scripts/clean-up.bat
YAJSW already looks in the scripts directory by default, and you just have to make sure your script is in that directory. You can see the file not found error when running in the console.
My problem now is that I am getting a 'returned 1' error. I am beginning to doubt that YAJSW will run .bat files as I have made mine very simple just to test and it still fails.

Compiling standalone selenium: Failed to load Main-Class manifest attribute from

I'm a total Java noob so please understand =) I need a quick advice on how to fix the issue.
I cloned the official selenium git repo, changed the code a bit (need to dump the page into some specified dirs), and tried to rebuilt it:
./go //java/server/src/org/openqa/selenium/remote/server:server:uber //java/client/src/org/openqa/selenium:client-combined:uber
It was successful but when I tried to execute it I got this:
$ java -jar build/java/server/src/org/openqa/selenium/remote/server/server-standalone.jar
Failed to load Main-Class manifest attribute from
build/java/server/src/org/openqa/selenium/remote/server/server-standalone.jar
Tried to check classpath, CLASS_PATH and CLASSPATH env variables (as a friend of mine suggested) - I simply don't have any.
At the same time, the pre-compiled standalone server from the official downloads works out of the box.
The official docs didn't help. There's nothing about it there.
So - I need a quick advice how to compile it? Thanks.
P.S. JDK 8 (latest), Mac OS 10.7
P.P.S. That friend of mine tried to build it by himself and he was lucky - he got a new build/dist folder where the target big file was. But in my case, the build folder is created, but there's not 'dist' folder in it.
Finally found the answer: I should have built it like that:
./go clean release
it's really strange that all the docs state I need to use these long /bla/bla/:uber things to get a whole single 'uber' server.

Setting fork and spawn in a maven plugin

We're converting a buildfile from ant to a maven plugin. We're trying to start/stop a database (hsqldb) in a maven plugin.
We succeeded to start the database. But we think that the plugin stops the database when the plugin is executed. The database should keep on running after the execution, but it seems to stop right away.
Our guess is that we should use the 'fork' and 'spawn' attributes (they are also in our build.xml from ant), but we don't have an idea how to implement them in our java class from our DatabaseController (which extends from AbstractMojo).
Any ideas?
We're using hsqldb, thisis the code how we initialize it:
hsqlServer = new Server();
hsqlServer.setLogWriter(null);
hsqlServer.setSilent(true);
hsqlServer.setDatabaseName(0, "database");
hsqlServer.setDatabasePath(0, "file:data/database");
getLog().info("Starting server!");
hsqlServer.start();
When we run the plugin, the database starts, we even managed to create tables and write data to it. Then the plugin stops, and the server stops automatically with it.
If we run another plugin, one to stop the server, we always get a nullPointerException at this line:
hsqlServer.stop();
Kind regards,
Jeroen
One thing you can do is, looking at existing maven plugins that does the forking of new java processes. Maven-surefire-plugin for one, do something similar. Surefire has a configuration (which will be specified in the pom.xml) called forkMode, which controlls the forking.
You may have to go through the source (svn checkout the code) of the plugin to figure it out.
I'm not much familiar with surefire much. But as a start, you may read the following class (#fork( Object testSet, Properties...)!
./maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
Any code executed in maven is forked in another process. I worked with processes in some projects realm, it doesn't have a clear documentation about that.
You could call your code something like that:
Thread.currentThread().setDaemon(true);
hsqlServer = new Server();
hsqlServer.setLogWriter(null);
hsqlServer.setSilent(true);
hsqlServer.setDatabaseName(0, "database");
hsqlServer.setDatabasePath(0, "file:data/database");
getLog().info("Starting server!");
hsqlServer.start();
With an daemon thread, maven could thing witch your code is to be runned in background.
It´s supposition, but you could try it.

Java Reflection not working on my system - working for team members

I am working on a team project in Java. One requirement is that we dynamically populate a drop-down menu of all classes that implement a certain interface. New classes can be added after compile time. To accomplish this we are using reflection.
Problem: All of the drop-down menus are blank on my system. I cannot for the life of me figure out why they are not populating. All other 5 team members have it working on their system.
Things I tired that didn't work:
1) Installing most recent eclipse (galileo) because rest team was using it
2) Re-install most recent java release (jdk1.6.0-17 and jre6)
3) Check PATH and JAVA_HOME variables
Any thoughts as to what else I can try or if something I did should have solved it and didn't? It is driving me crazy.
Edit:
I should have been clearer that we are developing in a team. We are using SVN for version control and we are all running the exact same source code. I even tried checking out a fresh copy of the entire tree from SVN, but I had the same issue with reflection on my system while it worked for teammates.
The team created an executable jar and that ran on everyone's system fine except for mine. Everything worked for me except the reflection bit.
You need to debug your application. This means you have to systematically explore possible causes of the problem. Here are some things that come to mind:
Could your GUI be failing rather than reflection? What if you output with System.out.println() rather than your menu?
Is your reflection code throwing an exception, and are you ignoring it?
Is your reflection code actually being called? Toss a println() in there to be sure!
Is the test for the interface suffering from a typo or similar error that's causing it to fail? Try finding classes that implement Serializable instead!
Is your reflection test running in the main thread and trying to update your GUI? You need to use SwingUtilities.invokeAndWait to get an update to the Swing worker thread.
You're working with Eclipse; Eclipse has a fantastic debugger. Set a breakpoint near where your main action is and then single step through the code.
PATH and JAVA_HOME won't help. PATH only affects dynamically-linked libraries ("native code"). JAVA_HOME is a scripting variable that happens to be used by some Java-based utilities like Ant and Tomcat; it means nothing to the Java runtime itself.
You need to be investigating the classpath, which should be specified by the -classpath option to the java command, in the Build Path in your Eclipse project properties, or in the Class-Path attribute of the main section of a JAR file if you're launching java with the -jar option.
From within your code, you should be able to list the contents of your classpath by examining the system property, "java.class.path"
System.out.println(System.getProperty("java.class.path"));
Problem solution:
Classpath leading to source code must have no spaces in it.
I am running windows XP and, for whatever reason, if the classpath that leads to the jar file or source code that is using reflection has any spaces in it, then the reflection fails.
I took the jar file that works for the rest of my team and ran it from C:\ on my system and the reflection worked perfectly fine.
I do not know why this is so please comment if you know what is happening.
Might be a long shot, but look for differences in security settings for you and your team mates. Article describing more details http://www.ibm.com/developerworks/library/j-dyn0603/ heading "Security and reflection"

Categories