I am new to maven and tomcat . I have created a project. After running, created a jar file.So, I deployed it in the tomcat. Now It is running on my localhost properly.Now I have added one print statement in the code. So,where will this get printed , because I already deployed that jar file of the code. So, what is the way to debug an application after deploying it ?
You have two options - either start tomcat from your IDE or use remote debugging. Here are some tutorials for you:
Intellij:
IntelliJ IDEA – Run / debug web application on Tomcat
HOW TO REMOTELY DEBUG APPLICATION RUNNING ON TOMCAT FROM WITHIN INTELLIJ IDEA
Eclipse:
Debugging your Tomcat Webapp with Eclipse (remote debug)
Launching and Debugging Tomcat in Eclipse
Once you make changes to the code you will need to rebuild the project and redeploy. If you used 'System.out.println(..)' it will be printed out to the console. Where that ends up depends on how you run Tomcat.
You can enable remote debugging in the jvm that runs Tomcat. To do that edit the catalina.sh or catalina.bat it you are running under Windows. Add the following to the CATALINA_OPTS: '-Xdebug -Xrunjdwp:transport=dt_socket,address=8998,server=y'. You will then need to configure your IDE to connect to that remote debugging session. You did not say, which IDE are you using.
Related
I have a Java Web Application and a web container Glassfish 5.0 with some custom java agent attached to the container.
I want to Debug my application as well as attach a Remote Debugger to Debug my Agent code simultaneously.
I am using Intellij IDEA Ultimate.
Now in the Intellij Run Configuration for Glassfish, I do the usual settings with some domain name. For Debug options "-agentlib:jdwp=transport=dt_socket,address=9100,server=y,suspend=n"
I want to make 'servey=y, suspend=y' , NO COMPROMISE ON THAT.
I try doing that by changing the 'domain.xml' but when I open my intellij glassfish configuration setting it gives me 'Warning : Debugger Settings are Invalid...' , I click Fix and the domain.xml is changed back to default with 'server=n,suspend=y'.
I tried changing from the Glassfish Administration console as well, both the default-config and server-config, but no luck.
WORKAROUND : I can deploy a WAR / Exploded WAR of my Application in glassfish domain folder, and customize 'domain.xml' and run the domain in debug mode ./asadmin start-domain --debug domain1, then I can successfully attach a Remote Debugger. BUT THIS ALLOWS TO ONLY DEBUG MY AGENT CODE and NOT MY APPLICATION
I suppose this is a problem with Intellij IDEA. Does anyone have a fix for this ?
I'm trying to deploy a java web application to Tomcat using Visual Studio Code and I'm having some issues that I'd like to share.
After installing the extension Tomcat for Java, I've tried to deploy a Maven Java Web project. To do so, I've clicked over project's folder and selected "Run on Tomcat Server" option. The result is an error with this message: The folder is not a valid web app to run on Tomcat Server.
Then, I've realized that maybe I should create a war file before running it on Tomcat. Therefore, I've executed mvn clean package command and afterwards execute "Run on Tomcat Server" option over the war file. Doing this the project has been deployed correctly.
However, compared to Eclipse's way to work with Tomcat, it seems to me a bit tedious. Particularly if I'm working with static files, like css or js, because every time I modify a file I should execute mvn clean package and "Run on Tomcat Server". Whereas, in Eclipse, these files are deployed automatically on Tomcat without restarting.
I wonder if there is another way to work with VS Code and Tomcat for Java.
Thanks!
If you use Spring, there is an easy way.
The Spring Initializr extension comes with an embedded Tomcat installation, and hot reloading works out of the box.
Rely on the following guide to install it:
https://code.visualstudio.com/docs/java/java-spring-boot
I have a Java 1.6.0 web application that I am developing using a Kepler Version 2 Eclipse development environment. I am using an Oracle Weblogic Server Administration Console 12c.
I'm running the app locally - and trying to debug it. Instead of stopping at any of the breakpoints I've set - I get the following error:
When I installed the application to Weblogic, I ran the Weblogic console and then installed the application by adding the ear file.
I thought I did everything exactly the same as previous web applications I've done this way - but I was always able to debug those applications.
Also - one other thing that is different. When make any changes and re-build the ear file - I actually have to delete and reinstall from the Weblogic console for the changes to take place. I'm thinking this might be related.
Any suggestions?
Thanks!
Have a jar file added to a build path in any of the projects that
include the classes in your project
I have developed a java webservice application that I have been running on my dev-computer and in the meanwhile been setting up a dedicated ubuntu based linux server.
I have installed oracle-jre, mysql and apache tomcat 7 on this linux server and
after reading documentation I understand that I can either copy the deployed project archive (.WAR) or I can simply copy the project folder, into the servers /webapps/ folder from my development computer. Then restart tomcat7 and it should automatically run the webapp.
On my dev-computer with Eclipse IDE the webservice works properly as expected, but I cannot access the POST URL methods at all on the server
e.g. localhost:8080/Webservice/rest/account/login
(The installation on the server seems to be O.K as the Apache examples all work properly.)
I cannot see any logs in the /logs/ directory, in fact the folder is completely empty, so I cannot debug whats actually happening. Why aren't logs writing to the Catalina.out file?
Am I deploying this correctly as explained above?
Do I need to configure Eclipse or any project settings to reflect the change from the eclipse IDE / dev-computer to the server? E.g Is there any real difference?
A lot of questions there, but I wanted to clarify as much as possible,
Cheers,
Oliver
I fixed this issue by reinstalling tomcat.
My firm is change the development environment, looking for some tricks and tips on how to work in the new environment.
The current environment is Eclipse and Tomcat. We are developing web applications with Spring, Web Flow, and MySQL..
The new environment is going to be Eclipse, Jboss AS7 and Maven.
Question 1:
Now for the questions as the current time we run tomcat on the local workstations and I can use eclipse to write my code and then just click on “Run On Server” and eclipse will build the war file and start tomcat.
With the new environment it does not look like Eclipse can start and stop and depoy right to Jboss AS so we are running a command line: mvn jboss-as:deploy does anyone know a better way?
Question 2:
Debugging.. Does anyone know how to get debugging working with eclipse and jboss as7
1) You can use "Run On server" with JBoss As 7 just like you do it with Tomcat. Just add new server in Eclipse for JBoss As. One difference comparing to adding new server for Tomcat is that during new server definition you should also create new runtime Environment for JBoss (if you haven't done this before) but this is very easy and intuitive. And there is a lot of examples in internet.
2) Debug is working with JBoss As very good too. If you start server from eclipse, then you can use debugger like you have used it before for Tomcat. If you run your server from command line without Eclipse, you can use remote debug from eclipse (as I remember Dubug as.. -> Remote Java Application and then specify there project, host and port).