Where is the "jrebel JAR-file" in the my WAR-file? - intellij-idea

I want to use jrebel with intellij IDEA and JBOSS AS7.
(have a web application(so have WAR)).
By apache-ANT , build my-WAR and deploy it under JBOSS AS.
I know how introduce any changes of classes or resources to jrebel in the my-WAR (If I'm not mistaken!) , as follows:
(In rebel.xml)
<classpath>
<dir name="D:/project/myProject/out/production/myProject">
</dir>
</classpath>
<web>
<link target="/">
<dir name="D:/project/myProject/resources">
</dir>
<dir name="D:/project/myProject/view">
</dir>
</link>
</web>
But, really, "jerebel jar-file" Where is the my-WAR?
in => "warFile >WEB-INF > lib"?I did not see it.
please help me.

jrebel.jar is packaged inside the JRebel plugin for IntelliJ IDEA. It doesn't have to be deployed with the WAR itself. JRebel plugin will set the correct JVM parameters to the command line when you start via "Run with JRebel" or "Debug with JRebel":
-javaagent:/path/to/jrebel.jar
UPDATE: the newer versions of JRebel are configured using -agentpath JVM option instead:
-agentpath:${JREBEL_HOME}/lib/<platform-specific-binary>
See the documentation reference of the correct settings.
You don't have to do it yourself if you start the server from the IDE. If you start the server from the command line then you would have to add the JVM argument yourself with the correct path to jrebel.jar as described here: http://manuals.zeroturnaround.com/jrebel/standalone/launch-from-command-line.html#jboss-7-x
Java agents intercept class loading and thus have to be loaded before other classes. As you might have guessed, jrebel.jar is a Java agent and therefor nothing requires it to be packaged inside a WAR.
Instead, rebel.xml, the configuration file, has to be packaged in the WAR, in WEB-INF/classes directory. JRebel uses rebel.xml to detect, where the compiled classes and resources are. So when the application is deployed, JRebel finds rebel.xml configuration file and won't load the application classes from WAR itself, but instead it will use the path that is specified in that rebel.xml file. This is why rebel.xml has to be inside the war, as you may also start the server from command line instead of the IDE.

Related

IntelliJ, JRebel, Maven and a JEE 6 application

My setup is
IDE: IntelliJ
Application: JEE6 with an EAR and a WAR module
Build: Maven
Hot-Code-Replacement: JRebel
App-Server: Glassfish 3.1
I configured the application in IntelliJ in a way that the ear gets deployed. The ear "target" folder looks like this
target/classes/
target/appEar/appWeb-version-Snapshot.war/
target/appEar/lib/
target/appEar/META-INF
In the default configuration JRebel listens for changes in the classes/ folder.
When I change something in the web module, and build this, the classes are only updated in appWeb/target/classes/ but not in appEar/target/appEar/appWeb-version-Snapshot.war/.
If I want to update those classes I have to select "Build Artifacts" in IntelliJ after building the project.
To sum up, I have to do these steps for a hot code replacement:
(once) Configure JRebel correctly.
Make project
Build Artifacts
This whole procedure appears to be too complicated to me. Does anyone have a clue how to setup IntelliJ/Maven/Glassfish/JEE/JRebel correctly? I have not found an example containing all my tools. I'd like to have only one action for the code replacement, not two.
There's "build on make" checkbox in your project artifact settings, that will always recreate your artifact on compiling, if that's what you are looking for. However JRebel should remap where your application is reading class files and resources based on rebel.xml, so you probably should just rewrite rebel.xml to look for classes where they are compiled to, not where they end up after building the artifact.
Why do you need to Build Artifacts every time?
Your war should contain the rebel.xml that maps to the classes in /target/classes folder.
When you make changes to said classes, your server then knows to load the changes from those classes.
So you only need to build your project in order to see the changes assuming your rebel.xml classpath points to /target/classes.

IBM MobileFirst: using external jar files during command line build

We are trying to use a org.JSON.JSONObject library for some intense json processing in the adapter side. We have Java classes which processes the data received from http adapters.
mobilefirst 6.3.0 and using cli 20150701 build
(the recent one).
This JSON referencing has no issues when building from eclipse mobilefirst studio environment.
We are building this environment in ubuntu linux 14.04. There is an error in referencing org.JSON.JSONObject..x.jar file when we execute
mfp start or mfp build or mfp deploy
Is there a way to reference this jar file during mfp start or mfp build or mfp deploy as a classpath.
We need to have something like
mfp -classpath "path/to/json.jar" build
please help.
As it turns out, the CLI does not yet recognize jars placed into the server/lib folder of your project. In oder to make this work, you can make a simple edit to the following file:
[cli install folder]/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml
At or about line 123, add the third fileset element shown below:
<!-- Classpath for server runtime libraries used when building the WAR -->
<path id="server-classpath">
<fileset dir="${worklight.jars.dir}" includes="worklight-jee-library.jar" />
<fileset dir="${worklight.server.install.dir}/wlp/dev" includes="**/*.jar" />
<!-- add server/lib folder to classpath -->
<fileset dir="${worklight.app.dir}/../server/lib" includes="**/*.jar" />
</path>
After that, running 'mfp start' (or 'mfp restart' if your server is already running) will compile your custom Java code with any jars that you add to the server/lib folder included in the classpath.
JARs for use by your adapters should be added to you Project's server directory in the folder lib. They will be included in your Projects WAR file when the project is built (in Studio or by the ant tasks) and when you deploy that WAR it will be visible to your adapters.
I agree with #bjustin_ibm. Thanks for that. While the above approach works, there's also another way of doing this.
Alternative hack
Just add your required .jars to the following location, it gets added to the classpath during mfp start
/home/instanceubuntu/.ibm/mobilefirst/6.3.0/server/wlp/dev/spi/third-party
This solution is more simple and doesn't really have to maintain the build.xml file.
Hope this helps.

Unable to load dialect 'org.drools.rule.builder.dialect.mvel.MVEL DialectConfiguration:mvel

I am using drools for processing rules. Web-service calls a method in a class which is in jar included in lib directory of web-service. And this method in turn uses drools. Now the problem is web-service is able to find jar that is using drools but not the drools-compiler jar which is residing in same lib directory. And it gives Unable to load dialect 'org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel' error. It works if I copy all jars in web-service.aar/lib to axis2/WEB_INF/lib. I also tried to set classpath in a way to take web-service.aar/lib jars first then the one's in axis2/WEB_INF/lib by setting classpath in setenv.sh and catalina configurations. But that didn't help either.
What can be the reason/solution?
You probably need to add a newer version of the mvel jar. I added the mvel-1.3.3-java1.5.jar and it did the trick for me, but just remember to restart your IDE.

Glassfishv3 not adding jars in ear to the classpath

I have been working on this problem for one whole day but in vain without any effective solution.
I have an ear file packaged with an ejb and a handful of jar files (including hibernate and the other dependent jar files).The ejb is stateless and enabled as a web service.
The ear file has been packaged using maven and has the below structure
ear->projectrelatedejb.jar
->hibernate.jar
->otherdependent. jar
->META-INF/application.xml
->META-INF/manifest.mf
The application.xml and manifest file are automatically generated by maven when I do a package.
When I deploy this ear file on glassfish it gets deployed with the ejb methods being accessible using web services. However when accessing the application (using soapui),
the ejb methods that perform some database functionality using hibernate throw java.lang.NoClassDefFoundError for the hibernate api during runtime.
It is obvious from the error that the hibernate jars are not on the classpath during runtime but since the jars are within the ear Glassfish should have
added it to the application classpath.
I tried various options like adding the classpath entries to the manifest.mf during the package (by using the element addClasspath with the maven-ear-plugin) which didn't do any good.Also with Glassfish we cannot add the dependent jars as modules to the application.xml unless the jars are application client jars
(Glassfish wouldn't deploy the ear file if the application.xml has the dependent jars declared as modules).
I also tried placing the jars in the lib directory within the ear (which isn't actually required) and with the manifest Class-Path header referencing the jars in the lib directory which also didn't fix the problem.
The quick and dirty fix which I can do to get this working is to place the hibernate and the other the dependent jars in Glassfish's lib directory.However,this is a bad practice
and I am somewhat reluctant to do it.
I would really appreciate if someone can provide me with a working solution to this problem.I have gone through the net looking for this problem
but couldn't find any solution.
Wondering if its a bug with glassfish or does glassfish need something special to reference the jars in an ear.
Thanks in advance.
I found a similar problem which is discussed here: http://www.tricoder.net/blog/?p=59.
Simply put, try putting the libraries in EAR/lib directory and according to JEE5 spec, glassfish will add them to class path automatically.
I used Server Library option to deploy application JARs and it worked for me.
Right click on your EAR-> Properties -> Libraries-> Add Library -> Create -> give name and change type in Library Type to Server Libraries then add JARs that should be deployed and confirm.
I work with NetBeans 7.0.1 and GlassFish server 3.1
When you say you added classpath entries to manifest.mf, which manifest.mf do you refer to? The one in ear-root/META-INF/manifest.mf ? Try adding a META-INF/MANIFEST.MF to your ejb module with Class-Path entries!

How does Intellij deploy to JBoss?

I finally have my application in IntelliJ and deploying to JBoss. I'd like to get hot deploy working but it looks like I need to understand how IntelliJ and JBoss interact.
When I build my project in IntelliJ and then start JBoss, the ear file does not appear in the deploy directory so I assume that there is some magic that IntelliJ does so that JBoss reads from a different folder. What is happening during this step?
Thanks :)
I know this is an old and apparently answered question, but unfortunately the links provided in the accepted answer didn't give me the simple details I was looking for. For anyone also trying to understand how IntelliJ IDEA deploys your exploded war to JBoss without copying files to the deployments folder, here's what I've found while deploying locally from IDEA 14 (EAP) to JBoss 7.1.1.Final:
After you've created an "exploded war" artifact for your project (or it has automatically been created for you), IDEA will build your provided sources and place the output in the directory set in the artifact options (you can change this setting to place the output inside the deployments folder inside your jboss installation).
IDEA will update your JBoss configuration file (/standalone/configuration/standalone.xml) and add a "deployment" node inside the deployments section. This entry simply defines a name, a runtime name and the exploded war root folder for your project, which will point to the output directory of your artifact set in IDEA.
When JBoss is started (either manually or from your run/debug configuration in IDEA), it will automatically deploy your artifact. Be warned that if your files are in the output directory of your project and you clean it, JBoss will still try to find the directory, thus encountering errors in your next attempt to start it: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Failed to mount deployment content, Failed to process phase STRUCTURE of deployment and java.io.FileNotFoundException to name a few.
Please refer to the documentation.
Basically, you need an exploded Artifact configuration with the directory name ending with .ear.
Build | Make performs hot deployment as well as Update action (which is configurable and can update only resources, resources and classes, optionally redeploy or restart the server).
Instead of copying your application to JBoss, IDEA runs it with appropriate parameters so that it uses Artifact directory instead. Configuration is very flexible and you can just change the artifact directory location to reside under JBoss directory.