Can't get compile on save / hot deploy feature to work with maven based webapp in eclipse or netbeans - eclipse

So our new webapp project is based on maven. I'm really liking the dependency management and IDE agnostic approach but I'm having problems with compilation and debugging.
Here's how I would currently get a clean copy of the project working
Check out the main project from SVN
Open the project in IDE (I've tried in eclipse 3.4 and netbeans 6.7)
The IDE will automatically open two subprojects one being the webapp, the other being a supporting utils jar.
From the command line I run mvn war:inplace on the webapp module which builds a working copy of the webapp with all dependencies in WEB-INF/lib/
This then runs fine but whenever I change a java class I have to clean and build / reload the app context.
I've googled high and low but no one seems to be complaining about this so I guess there must be something really obvious I'm missing. How is everyone else handling incremental compilation and hot deploy with maven?
To clarify all I'm looking for is the replicate the behavior I used to have before maven where I could make simple changes to java classes and they would be instantaneously compiled and hot deployed to a running webapp. I don't need anything fancy like jRebel etc I just want the new tool to give me the same functionality I enjoyed with my old tools.

If you can use mvn jetty:run it will read the classes and resources directly from the project. Using Maven2 Eclipse plugin and running the server embedded in Eclipse has auto-publishing, which gets you there in the end, although it's slower. And JRebel starting with 2.0 (as you may know) can map the Maven module directly to the deployed application, so you get instant build and redeploy. Those are the only solutions I know of.

Netbeans should support it out of the box. Though, there remains a bug related to this: http://netbeans.org/bugzilla/show_bug.cgi?id=177230

In-place deployment works for me with Netbeans 7.0.1 and Tomcat 6.0.x if I use Tomcat 7.0.x in-place deployment doesn't work. Tomcat always copies application to $CATALINA_HOME/temp :(

Related

Apache Wicket Quick Start

I was trying to start learning about Apache Wicket (as it looked like an easy to use UI for Java) and as I like to work with Eclipse and Maven. I also like to work with Tomcat, however, Wicket seems to prefer Jetty at least in its tutorials. I do not know nothing about Jetty, however should not take ages to learn.
I tried the Wicket Quick Start and successfully imported the generated Maven project to Eclipse workspace.
But errors appear: e.g.
import org.eclipse.jetty.server.HttpConfiguration;
It seems Eclipse cannot find the jetty server classes. How to add these to the Eclipse project?
Does the creater of the Wicket Quick Start assumed that Jetty is already installed on the machine?
I installed it. However: what is the recommended way to make what jar file available to a maven project to have jetty server classes available? I would assume via the pom.xml but I doubt that is the case here - the given pom.xml would contain it.
Or is there some special plugin for Eclipse (Photon)?Run-Jetty-Run?. I wasn't brave enough to try that.
I would love to get the Wicket Quick Start running.
I also tried Eclipse + Tomcat + Apache Wicket Maven Setup with Hello World Example but it seems that it is outdated. I was not able to install qwickie to Eclipse as described.
I am using Eclipse Proton with Java 10.0.2 on Debian Stretch.
If you are using https://wicket.apache.org/start/quickstart.html then you can start the application these ways:
mvn jetty:run - this will use jetty-maven-plugin
Open in Eclipse src/test/java/com/example/Start.java and run it as a normal Java class with a main(String[]) method. This will use Jetty Maven dependencies to start an embedded Jetty server.
Wicket's Quickstart prefers Jetty because Jetty developers made it easy to use it in non production way, i.e. in development mode, for faster dev cycles. No need to build a .war file and deploy it.
On the other side Tomcat devs (disclaimer: I am a member of both Wicket and Tomcat teams) never spent time in this direction. Tomcat's Maven plugin has been abandoned long time ago. The best integration for starting embedded Tomcat is provided by Spring Boot project (I recommend it if you use Spring!).
So, just remove the Jetty related dependencies and plugin in pom.xml and the Start.java in src/test/java/.... Then you can continue developing with Eclipse and Tomcat the way you like to do it.

Eclipse juno deployment requires clean and build everytime

I have a web application developed in Eclipse Juno, I am using Tomcat 7.0.32 as a web server. When ever I'm doing small changes and deploying the application, changes are not taken by the tomcat.
Under Eclipse tomcat deploy path wtpwebapps, I have found the following:
Few/all JAR's given in the build path are missing
Recently compiled java files are not updated
These things led into ClassNotFoundException sometimes and Unexpected functionality sometimes.
So, when I do clean and build the project for small changes every time,deployment works fine. But clean and build takes more time
Is it a problem with eclipse deployment plug-in? Help me out to overcome, thanks

JUnit uses wrong Base64

I wanna use the class Base64 from commons-codec 1.5 and when I run the code on Server this works fine. My application runs on Websphere 7.0.
But when I run my JUnit tests the wrong Base64 Class is choosen, when i ask the Class with:
System.out.println(Base64.class.getProtectionDomain().getCodeSource().getLocation());
the output is: file:/C:/EProg/IBM/SDP80/runtimes/base_v7/plugins/com.ibm.ws.prereq.soap.jar
Thats definitly the wrong Version.
And an error occurs because of the wrong Version:
java.lang.NoSuchMethodError:
org/apache/commons/codec/binary/Base64.decodeBase64(Ljava/lang/String;)
The crazy thing is, that happens only it i choose one Test and run it with Run As: JUnit Test in Eclipse, if I run the whole thing with Maven everthing works fine.
I use JUnit 4.8.1 and Eclipse Indigo Service Release 2 with some Plugins for Websphere, GWT and Maven.``
com.ibm.ws.prereq.soap.jar is an OSGi bundle, and in WebSphere (which is built on an OSGi container), the classes in org.apache.commons.codec.binary are not visible to applications because that package is not exported by the OSGi bundle (you can examine the list of exported packages by looking at the META-INF/MANIFEST.MF file in com.ibm.ws.prereq.soap.jar). That explains why you don't encounter any issue when running your application in WebSphere.
On the other hand, when you add that JAR to a Java project in Eclipse, it will be treated like a simple JAR, not an OSGi bundle, and all packages will be visible. In your case this creates a conflict with another commons-codec dependency.
I guess that the reason why you don't encounter that issue in Maven is that com.ibm.ws.prereq.soap.jar is only a dependency of your Eclipse project, but not of your Maven project.
Unfortunately there are not many (simple) ways to solve that issue. One is to remove com.ibm.ws.prereq.soap.jar from your Java project (I doubt that you are actually using Apache SOAP). The other is to change the order, so that your other commons-codec dependency comes before com.ibm.ws.prereq.soap.jar.
It looks like a class path issue. More precisely, Eclipse integration with Maven. I would investigate Eclipse dependencies and make sure that it uses Maven for dependency management.
You can do it in two ways, either you can run mvn eclipse:eclipse command or use M2Eclipse plugin. If you use the later, then there is a update dependency option, in the project context menu.

slight url mismatch while publishing java 6 maven webapp to tomcat from netbeans

Honestly I've started this small maven webapp using eclipse 3.6 (STS) and i found it so complicated that i had to switch to netbeans.I really wanted to use eclipse but these are reality on the ground.So at the end of everything I'll like to have an eclipse version of the same project. thanks
I set up the maven webapp using the embedded archetype, and use cargo plugin to take care of the deployment.basically there is only hello world index.jsp in the project.after picking pom configuration here and there my pom finally is like this .
while it started publishing after i restart the IDE, it's publishing to http://localhost:8080/ but for me I'm expecting it at http://localhost:8080/mvnTestWebap
so here are my questions
Question 1 : How can i correct that?
Question 2 : I believe my pom is tied to netbeans too much, how can i achieve the publishing to tomcat result but having a portable pom?Can anyone suggest a rewrite that can run on eclipse?
Question 3 : what correspond to netbeans "run" in eclipse?
probably by some deployment descriptor editing.
don't really understand the point. by default netbeans uses it's own embedded IDE way of deployment. That's not creating a pom tied to netbeans in any way. You can use that in eclipse or IDE or command line to build the project. The deployment part of the web app is specific to the server being used and the IDE being used.
You can also tell netbeans to execute your cargo plugin on executing the Run/Debug/Profile action (bypassing the netbeans default behaviour)
run basically performs a redeploy of the app on the server of choice. There has to be an equivalent on eclipse.

Unable to publish web app: SpringSource Tool Suite problem?

I have an existing, fully functional Spring web application based on Spring 2.5.6 - developed using SpringSource Tool Suite 2.1.0.SR1.
Because I'd like to use REST I decided to upgrade to Spring 3.0.0.M4. After editing the dependencies in pom.xml and changing my code to reflect the API changes in Spring 3.0 I tried to publish my web app to a local server (SpringSource tc - a Tomcat derivate).
The result is an almost empty web app folder and therefore a non-functional app. The app's folder only contains WEB-INF/lib with all libraries required by the Maven dependencies.
After realising that something's broken, I created a new Spring MVC project (based on the default 2.5.6) and published it to the same server. No problems. I tried to adapt my project's files (.settings/*, .project, .classpath, .springBeans), but this didn't change anything.
I'm pretty lost right now. My guess is that STS doesn't handle 3.0 apps correctly. Any suggestions?
PS: I don't want to revert to 2.5 if it's not absolutely necessary. I don't need STS and tc so I don't have a problem using other tools, but it worked fine so far.
I run into this all the time using Eclipse Galileo and m2eclipse 0.9.8 and Tomcat with WTP. I think it is m2eclipse that is the culprit. The problem seems worse after switching from Ganymede. The work around is to run mvn to create the war and then copy the war contents from "target" to WTP's "wtpwebapps" directory. You can conveniently find this horribly long path by double clicking the server in the Servers view, and choosing "Open Launch Configuration" from there click on Arguments(?) tab I think and copy the catalina.home java property that is defined as an argument there.
The problem vanished with newer versions of STS. Additionally my development environment changed a bit since I posted this question, so I can't really tell what caused the problem.
For me, it looked like a weird hiccup inside STS.
Spring Tool Suite 2.1.0 claims partial support for Spring 3.0, though not for the REST features. According to the release, future releases will add full support. From the release statement:
Features
Support for milestones of Spring 3.0 including XML editing and validation, support for #Configuration and #Bean annotations
Future
Complete Spring 3.0 support including tools for developing RESTful web applications
Try deploying your app to embedded jetty. 'mvn jetty:run' with help you confirm if that there's nothing wrong with your build (that all the right manifests and deps are in place)