I'm developping a web application in Eclipse and I'm using maven, spring and tomcat.
Now the problem I have is that debug as => debug on server doesn't work.
I just get exceptions. (and yes I've created the server)
If I use the mvn command to compile it, put the war in my tomcat webapps dir and start my tomcat the application works fine. But for the functionallity I'm now working on debugging would be usefull.
I found the answer for this in http://jacksonps4.me/wordpress/?p=868
Worked like a charm for me, yet I don't understand anything!
We used to test our application with Tomcat as well, but switched to starting an embeddable Jetty. Here's a sample app. It's JSF, but it doesn't really matter. The pseudo-unit test simply starts a jetty "before" and shuts stops it "after". No need for external server infrastructure, no need for IDE dependencies.
you can run tomcat with maven with this command:
mvn tomcat:run
and if you want to debug, set this maven options:
export MAVEN_OPTS=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
if you are in windows, use the set command:
set MAVEN_OPTS=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
then you can debug with eclipse Remote Java Application.
Hope this help.
Related
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.
I've got a poor beginner question about Spring/Eclipse usage.
I'm working on tutorials to learn Spring, coding "Hello World" or other little webapps running few controllers and JSP.
Each time I wanna run the app from within Eclipse, nothing happens. I just get a 404 error.
In order to make the web app works, I have to run my Tomcat outside Eclipse (ie launch Tomcat from Windows with the startup.bat command line) and deploy a War through the manager-gui window of Tomcat.
So it works, but it would be more comfortable directly from within Eclipse on the embedded servers because this way running tests are so loooooooooong...
In Eclipse, I tried :
Run on Server -> 404
Run a Maven conf with Clean-Install goals,
obtained a War, but was unable to use it from within Eclipse (it's
the same War I use in the Tomcat GUI) as I saw it here
So can someone tell me how to run a Spring webapp from with Eclipse to make my work easier ?
Thanx by advance.
You need to enable 'Use Tomcat Installation' option in tomcat server when controlling it inside eclipse.
Please check this link
Tomcat not starting from eclipse, this will solve your issue.
I really need to debug my code by the use of breakpoints, however this seems a complex undertaking with an OSGi container.
I have Eclipse and Felix (both the latest). My project is a raw OSGi project, I am not using PDE, just maven bundle plugin to generate the bundles and then copy them to the /bundle folder in felix, then I perform java -jar bin/felix.jar and the project runs. So no fuss here.
However I cannot debug the application that way. I've tried to read the docs (http://felix.apache.org/documentation/development/integrating-felix-with-eclipse.html) but they are outdated/broken and cant make them work...
How can I debug this? Will I have to avoid using OSGi just because debug is not supported...?
Thanks!
Have you considered using an IDE tool like bndtools to do the debugging? You can create a repository from your folder of bundles and run them using a bndrun file. This gives you a debug environment in Eclipse which sounds to be what you want. The bndtools website is here.
Bndtools also does a lot more, but it sounds as if you're happy with your existing Maven build. The tutorial runs through setting up a basic workspace, but the main thing you'll be interested in is Running a framework
Start felix with the following parameters to enable remote debugging.
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044 -jar bin/felix.jar
After you can connect via Eclipse Remote Debugging to your Felix Container.
Run
Debug Configurations
Remote Java Application
Choose as project the project/sources you want to debug
Configure port to 1044
Trigger debugger by clicking on debug
I'm trying to run the JHipster application via my Eclipse Juno, using jdk 1.7.
The app seems to be loading properly (no console errors), but when i'm trying to reach the server with the client side (or via Postman, by sending a request to the REST servlets in port 8080), it's not responding.
However, when i'm running "mvn spring-boot:run" in the command shell, the server is loaded successfully and is responding to the exact same requests. Also, I managed to run the same command via eclipse with some maven configuration but it seems to be running only the target files (jars) and not the source code. I still haven't been able to run the source code of this app using eclipse in order to properly debug it.
Any suggestions?
Thanks!
So the answer is quite trivial, but since I spent several hours to reach it, it might save some time for others-
Download & install STS IDE.
Import the project as existing Maven project.
Run/Debug the project.
I tried to run it via Eclipse the whole time (wasn't familiar with STS to be honest) and this probably needs some extra configuration (another comment with explanations on eclipse configuration will be much appreciated). Once you work with STS, it's easy.
You should not need STS, just Eclipse with the J2EE stuff.
I've imported the sample jhipster in Eclipse (without STS) as a Maven project and everything was OK, after installing the maven dependencies.
To run the project, run as an application and search for the Application (com.mycompany.myapp.Application)
This app works for me: https://github.com/jhipster/jhipster-sample-app. It is stuck on Boot RC5 which probably means it's a bit old. Maybe Julien can comment on that (or update it)?
I have a Maven project which is a web project and is packaged as a war.
I use tomcat-maven-plugin v1.2-SNAPSHOT to do a tomcat:deploy when i want to deploy.
But my question is how do i debug it / set breakpoints like i can do for normal web projects in eclipse (where a Debugging perceptive is shown and the server is paused.)
(i am a noob in this field)
[EDIT] I am not asking how to deploy to TOMCAT. i am rather asking how to setup the debug mode .FYI i am not able to right click on my project and select run> run on server, even though i have generated WTP specific files through maven.
mvn tomcat:deploy deploys an app to an external Tomcat server. If you want to debug that, you'll need to run that Tomcat server with debugging enabled and set up a remote debugging profile in Eclipse.
Edit: There's a succinct guide to doing this on the Tomcat wiki. The simplest approach is to start Tomcat with catalina jpda start. That will start Tomcat in debug mode listening on port 8000 for debugger connections. Then in Eclipse, you create a "remote" launcher configuration and tell it to connect to localhost:8000.
It doesn't matter whether you deploy it with maven or with Eclipse WTP as long as you started the server to which you deploy from eclipse and eclipse knows where the sources of the code you deployed are placed.
Keep attention if you have set the CATALINA_HOME environment variable, this will used to deploy to with mvn tomcat:deploy. But you can also define this in the configuration of the pom.xml.
<configuration>
<url>http://www.mydomain.com:1234/mymanager</url>
</configuration>
I'm not sure that it is feasible through the Maven plugin.
But you can generate eclipse specific files: mvn eclipse:eclipse -Dwtp.version=2.0 (The WTP version depends on the WTP version of your Eclipse).
Then, you can update your project and deploying it into a Tomcat like you can do for normal web projects.
This solution worked in my case, you can try this
Add module to Server
Go to the Servers view.
Double click on the Tomcat server.
You will get the server editor view.
Click on Modules tab in view (at bottom)
Click add External Web Module enter the path to your built files (e.g., C:\svn\projectName\trunk\test\project\target\webapp) and give a path.
Save.
Debug Server
Right-click on Tomcat in Servers view.
Choose Debug.
Debugging Startup
If you are debugging the startup of your application you might need to increase the startup timeout in the server view.
Thanks.