Eclipse JBoss hot code replace - eclipse

I am using Eclipse 4.2 and JBoss 7.
I have Build automatically checked in Eclipse.
Even then I have to build and redeploy the EAR file to JBOSS to test any code changes I make in Eclipse debug mode.
Am I missing something here?
THanks,

What the "Build automatically" option in eclipse do is that when you modify the source code of a class, this one will be automatically compiled, which doesn't mean that all the whole project that contains the class (i.e. war, jar, ear ...) is redeployed in the server. But of course it helps in the speed of deployment, because the classes you've been modifying are already compiled when you manually build or deploy the project.
On the other hand, to avoid problems with redeployments, you'd better set up JBoss to delete the files related to the application keeps in the work directory, when the application is undeployed / redeployed. Look at this stackoverflow thread for more information.

Concerning the "Build automatically" option:
In order for the Deployment Scanner in JBoss to work, you have to have it turned on in JBoss.
Also, you need to add your project to the JBoss server in the Servers window. Look for the "Add or Remove..." option.
Once your project is added, any changes you make to your code will get detected and your module will be redeployed automatically in the background. Failing that and assuming your project doesn't have a snag, you can use mvn install & mvn jboss-as:deploy to manual update your module.
Beware, sometimes mvn doesn't pick up the latest java code. This seems to be a project configuration issue more than anything. Re-creating the project seems to correct the issue.
Also, keep an eye out for duplicate persistence.xml files.
You only need one.

Related

File in the classpath not being published (Eclipse + JBoss AS)

I am working in an ActiveJDBC project that requires an instrumentation step before the build in order to do the entity mapping. I did this by adding a script that generates an activejdbc.properties at the classpath.
The build part is fine and the file is being properly generated in the workspace. However, when I publish the project the file is being packed in the WAR file (all the other classes are fine though).
It is a simple dynamic web project, no changes in the build or classpath besides the instrumentation step. I am using:
- OS X Mavericks.
- Eclipse Juno.
- Maven 3.
- JBoss AS 7.
- JRE 1.6.
I used the following tutorial: http://javalite.io/eclipseIntegration
Can you guys give me a hint on whats going on? There is no error or warning in console...
I think you mean activejdbc_models.properties file. This file will be produced by instrumentation process and will be placed at the root of your classpath, usually target/classes. Please see if it is there. If it is there, it will be placed at the root of your war file: war_root/WEB-INF/classes. Unpack your war file and see if it is there. If not, something is wring in how you create a war file.
I went through the whole process again and, after a lot of attempts, I changed the configuration in the instrumentation builder to refresh resources recursively upon completion and it started working. Its on Proj Properties >> Builders >> Edit (on instrumentation builder) >> Refresh tab.
It seems to be working now, but I'll try to map more entities to check if its really ok.

Google App Engine, Maven and Eclipse development setup

I'll try keep this short. I have Eclipse with an installed M2E (Maven to Eclipse) plugin. I have a GAE (Google App Engine) project I'm working on. Everything is working ok apart from one really annoying thing: I have to stop/start the devserver every time I make a change.
If you have any experience with this setup then you might be able to answer this simple question?
I start the development server with "mvn appegnine:devserver" on the command line. Now I would expect that if I made changes to a *.jsp for example that those changes would automatically be updated on the devserver. Is this what happens with you?
I have noticed that if I make changes to *.jsp files under my target folder then devserver will see those changes and updates as I would expect. I think my problem lies with Eclipse not copying changes to target folder, but not sure if is even suppose to?
Does anyone have any suggestions on how I should progress investigating this? I've ran out of ideas :-/
I thank you in advance for any comments you may have.
P.s I know I can run "mvn package" to update files, but this is slow and the devserver runs out of memory after a do it twice.
This can be little painful, depending on how you want to work and which version of eclipse you're using.
Install the m2e-wtp plugin if you haven't. It's the secret sauce that makes appengine projects work in eclipse. Note this isn't m2e - but another plugin.
Install the GPE - the google plugin for eclipse if you haven't
Make sure your project is being managed by m2e as a maven project.
Go into your project properties - enable it as an appengine project using the GPE (listed under 'Google'). Don't forget to tick HRD while you're here.
Go to your project build path (Properties -> Java Build Path).
Ensure on the source tab that your src/main/resources doesnt have an ** exclusion.
Ensure on the libraries tab your have the three libraries 'JDK', 'Google Appengine' and 'Maven Dependencies' and nothing else
Ensure on the order and export tab that the appengine dependencies are above the maven dependencies.
It sounds pretty ridiculous - i'm not really sure why its still so painful, but that is a good recipe for success. Once that's done, this should allow you to run in debug from eclipse itself, with hotloading of code, jsps, css, scripts etc. I've had this work in helios, indigo and juno.
You can read more about the m2e-wtp setup instructions here. They refer to GWT but it's the same for appengine (I'm not sure why the emphasis on using GWT on GAE) because its actually about the correct setup of GPE and Maven.
You will also find that you may need to repeat some parts of step 5 pretty frequently - if your app isn't loading properly take a quick look to ensure that your resources haven't been excluded. This happens when you update your project configuration using the m2e plugin.
The wtp-m2e plugin updates the target folder as resources modified - so this should also resolve your issues running from the command line, but i can't vouch for that - I prefer to run straight out of eclipse.
I have the same problem as you, however I resolved with other way. I use FileSync plugin (which can be found in the market place).
With this plugin you configure an input directory (webapp) and output directory (target).
Any change made to the webapp will be passed to the target.
I have helped too.
You can use rsync like this:
rsync -r --existing src/main/webapp/ target/ROOT
where "ROOT" is the project build finalName.
The below point worked for me.
Ensure on the order and export tab that the appengine dependencies are above the maven dependencies.

Deploying a new version of WAR onto tomcat on eclipse

So I'm having this issue with eclipse and tomcat 6.
I am able to upload the first version of my war on eclipse using server(tomcat 6)->add resource, add all.
But then I tried editing some lines, and then run as maven clean->run as maven install, then clean, clean tomcat work directory, and restart the server, and it would not show me the reflected changes.
Any suggestions?
You clean your application, and executing an install, but seems you're not executing the build correctly. Ensure you're generating a new war file (take a look at the date of when it is generated to make sure you're deploying the last version). If your project has many modules, e.g: war and jars. Make sure you build the jars as well, and the jars are being replaced in the tomcat/libs folder or in your WEB-INF/libs, check the date of when are the depending jars generated too, then you can see the differences.
Best regards.

Eclipse + JBoss - some JAR files not deployed

I have an Eclipse Indigo installation with a JBoss 6 server managed by it. I have a Maven project with a few modules. These modules all build just fine from the command line.
One of the modules is an EAR. This is dependent on two JAR modules and a couple of WAR modules. When I package the EAR from the command line (mvn clean package), the EAR contains all the necessary JAR and WAR files. However, when I deploy it from Eclipse, the two module JAR files are missing from JBoss. The WAR files are just fine. Inside the "Add and Remove..." dialog the JAR files are also present, but not when deployed. I've checked JBoss' deployments folder and there they are indeed missing. The strange thing is, with the exact same POMs and code, all of my colleagues with the same(?) setup don't have this problem.
The two JAR modules are listed in the dependency management part of the parent POM. They are also listed as dependencies in the EAR POM. Still, Eclipse refuses to deploy them with the EAR.
Does anybody have any idea how I can solve this issue? I can manually package and deploy the EAR, but 1) that takes longer, and 2) I can't use Eclipse's debugging functionality this way.
Note: previously asked at http://www.coderanch.com/t/580959/vc/Eclipse-JBoss-some-JAR-files
Right mouse button on project -> Maven -> Update project
I experienced the exact same issue, different eclipse (Eclipse Mars, WildFly 8.1 ).
The unsettling part was that I didn't change anything in the code or in the IDE (that I am aware of) and it started malfunctioning.
I suspect it has something to do with the cached memory of eclipse for it's plugins, anyway, after many hours of trying different things we fixed it by deleting the folder .eclipse under your user in windows.
Seems silly, but we tried everything except that, and that thing did the trick
I'm encountering a similar issue, however my environment is much, much simpler - being a web project, with a utility project. Not using maven at all and deploying to tomcat7.
The class file is not being deployed to the web-inf as expected, although the utility project is referenced, and marked as to be exported.
However with your issue, I came across this post:
http://blog.frankel.ch/better-maven-integration-leads-to-unforeseen-consequences-bugs#comments
which might provide a clue. Hope this helps.
I had the same issue. I didn't modify my code at all, I deleted all the projects from the work space, closed eclipse and reopened it. Then I did a clean and build of the project (which took much longer than before). This time when I went to add the EAR project, it had all the dependencies listed and actually worked.

missing classes after publish web project into tomcat using eclipse wtp

I have several dynamic web projects in my workspace, each contains classes and refers to other utility projects (simple Java Projects), and to 3rd party jars.
These apps (dynamic web projects) are deployed on tomcat v6.0.6 using eclipse WTP (Helios 3.6)
When I update my workspace and new classes/resources/jars are extracted from the SVN repository, I re-publish my apps in tomcat apps, and restart it.
Occasionally, when tomcat starts one of my apps, it throws ClassNotFoundException, or complains about other missing resource. Sometimes I see that the a deployed resource (spring beans xml for example) is not up to date, and has 'old' content in it.
The common anti-voodoo-black-magic treatment I use:
* stop / start tomcat
* clean (when right click on the server configuration)
* clean tomcat work directory
* remove all apps from tomcat, clean, restart tomcat, add all apps
I need to run this 'procedure' several time until problem is solved.
Do you guys suffer from it as well ? Is this a known bug ?
Any suggestions how to tackle it ? is using jars instead of utility projects will solve/reduce this problems?
I would consider using Embedded Jetty instead, I just want to avoid from proprietary scripts for running Jetty on a 'production' environment.
-- Yonatan
It happened to me a lot. I wouldn't call that Voodoo. I think that Eclipse WTP doesn't work well when you change stuff in the background (e.g. a maven build).
What I do to solve this is to avoid using it altogether. Instead I use Maven WAR plugin to deploy the application:
mvn war:inplace tomcat:inplace -DskipTests=true
This works very fast, as it doesn't need to assemble, and package the war.
Then to undeploy the application:
mvn tomcat:undeploy
I have scripts that
deploy and start tomact
undeploy and stop tomcat
It looks something like this:
Start tomcat and deploy app:
#!/bin/sh
if [ -f $CATALINA_PID ]; then
echo "tomcat already running with pid " `cat $CATALINA_PID`
exit 1
fi
java -Dmy.arg=val -Dcatalina.home=<catalina-home> -Dlog4j.configuration=file:///log4j.xml -classpath <path-to-tomcat-lib>/bootstrap.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/lib/tools.jar org.apache.catalina.startup.Bootstrap start &
echo $! > $CATALINA_PID
mvn war:inplace tomcat:inplace -DskipTests=true
Undeploy and Stop tomcat:
#!/bin/sh
mvn tomcat:undeploy
<path-to-tomcat>/shutdown.sh -force
rm $CATALINA_PID
The same with probably any other build script - its just a matter of how much code you will have to write.
I chose Maven's war:inplace goal is since it does very little, and thus runs very quickly. See here: maven.apache.org/plugins/maven-war-plugin/usage.html.
BTW, ANT and Gradle have a war task/plugin which can probably be configured to do something similar (I don't really remember...)
Hope this helps.
Another thing to look out for is that Project -> Build Automatically should be enabled and the project should not have any build path problems.
Open the navigator view and confirm that the build folder is having generated class files.
If the files are not being built they won't be published. Though this seems obvious it is easy to over look and wasted a lot of my time.
Interesting behaviour.... Something similar was happening on my Linux machine due to permission issues.
Anyway, i suggest not to use WTP. Try ant build script instead. Its simple and for me it works brilliant.
Been working with Eclipse since it came out, these problems have always existed. Arrived here because atm my web.xml doesn't get deployed anymore. Especially in combination with m2eclipse you'll never know what happens when you try to start your Tomcat. Everybody I know how has worked with Eclipse has these problems, I don't understand why they don't get fixed...and unfortunately working as a contractor means I can't choose my IDE or the container or the way publishing is done, so most of the time I'm stuck with WTP.
I had a similar problem. When I published a web application, Eclipse was not including one of the jar and hence publish to sever through Eclipse fails. I corrected this by modifying the .classpath file of the project to correct dependency as below. To makes sure that its in sync with other jars configuration.
<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.17/log4j-1.2.17.jar" sourcepath="M2_REPO/log4j/log4j/1.2.17/log4j-1.2.17-sources.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
It seems progress is being made on solving this problem.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=365748
Hopefully it will be fixed for the next release of Eclipse.
one possible solution could be that your bin folder is not getting created. check that you have not deleted build/bin folder and it does exists in your work space.