Perfectly Fine Working Eclipse Project throws 404 on Tomcat - java

I have a web application which includes Spring Boot , Joinfaces , JSF and Spring Security. This web application works excellent when i run in ECLIPSE IDE. All pages works fine with 0 Error.
The thing is when i do mvn install and package this project into WAR and deploy it in TOMCAT its just not working. No deploy error. Just 404 when i try to reach my pages.
What can cause this ? Why it is working perfectly fine on Eclipse but not working on Tomcat after packaging ?
Where should i look to solve this ?

I found the problem.
The thing is rest of the project was built to be run on embedded Tomcat as JAR. So the packaging was the problem. I ran the application as java -jar on tje distant machine and it worked.

Related

Deploy java web application to Tomcat with Visual Studio Code

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

NoClassDefFoundError after deploying WAR on Weblogic10.3.6 created from Eclipse

I've created a simple web app and it works fine when I deploy it on internally configured server in eclipse.
But now I exported it as a WAR and tried to deploy on another Weblogic server. I get the following error:
java.lang.NoClassDefFoundError: com/ofss/UcbparamConnector
at jsp_servlet.__ucbparam12._jspService(__ucbparam12.java:88)
The UcbparamConnector.class is present in the WAR under WEB-INF/classes/ but looks like it is not found during the runtime. Please suggest what could have gone wrong.
The other Weblogic server was configured to run on different JRE which was causing this problem.
After changing JDK path, web app is working as expected.
Thank you.

Spring MVC App runs in Eclipse but not Intellij - 404 Not Found

I've written a Spring MVC app that is functional on an app server. I'm attempting to switch development of this app from Eclipse and to Intellij. I am very new to the IDE so I'm not sure where I have gone wrong here.
When I run this application on the server in Eclipse it goes to localhost just fine and works as expected. I created a run configuration in IntelliJ, the app compiles and the server log says it was deployed successfully.
However in the browser it gives the standard HTTP Status 404 - Resource Not Available.
I really don't think it's the servlet or web.xml because those are working just fine in Eclipse. I've also created a brand new app in Intellij to test it and it works fine. So it must be something specific to IntelliJ that I have misconfigured or not setup at all...any ideas? Let me know if you need to see specific screens or anything.
So after toying with this, making it worse a few times, and then getting it back to the original 404 I found the difference.
Eclipse has an internal tomcat server it runs projects on, Intellij runs its projects on the default tomcat server installed on your computer. Intellij exports the project you are running to the server in the web apps folder as the name of your project.
So after I found that, in my tomcat run configuration in Intellij I had to specifiy the application context. Edit Configurations -> Deployment tab -> Application context, and set it to /YourProjectName. My guess is that this tells tomcat where to find your project within the web apps folder.
I hope this can help anyone else who is a relative beginner to tomcat/java EE and intellij like I am.
There is a plugin in intellij called "Smart Tomcat", it allows running spring or web app with much fewer configurations.

Run Spring MVC project on Tomcat server

Hi I am a newbie with Spring MVC and I have a little problem.
I can't deploy this project on a Tomcat server. https://spring.io/guides/gs/securing-web/
I can run the project by running it as an application. And you see everything starting in the console, with a spring boot. And if I go to http://localhost:8080/ I see the right page.
I think this is deployed on an internal Tomcat server, but what do I have to do if I want to deploy it on another server, raspberry pi or a BeagleBone with a Tomcat server installed on it ?
I tried to use the WAR file to deploy on an external tomcat server but that doesn't work because i think its because this project doesn't use a WEB-INF folder and also has no web.xml file.
Thanks.

Spring MVC application deployed on Tomcat does not run on IntelliJ

I try to run a basic Spring MVC application, like the one here (or also the Spring MVC tutorial here).
I just open the project in IntelliJ, import it on a Tomcat 7 instance, and start the Tomcat server. But when I try to reach the http://localhost:8080, I get a 404 error.
The project I downloaded from GitHub provides 2 ways to start the application, with mvn jetty:run or mvn tomcat7:run. When I run any of these commands (outside IntelliJ), the application starts succesfully, and the web page is displayed correctly on the http://localthost:8080 URL, which led me think that the problem comes from IntelliJ.
Adding some debug information, it appears that when run under IntelliJ, the WebInitializer class is loaded, but not the WebConfig class, even if the method WebInitializer.getServletConfigClasses() is called.
With mvn jetty:run or mvn tomcat7:run, both classes are correctly instantiated.
Unfortunately, I have no error at all in any logs provided by Tomcat / IntelliJ, so I'm a bit lost.
What I am doing wrong, or what I've missed in the configuration of my project in IntelliJ?
Thanks
Technical info: Java 7, Tomcat 7, IntelliJ Ultimate 12.1.4, Spring 3.2.2.RELEASE
My problem is solved. I was using Tomcat 7.0.8 in IntelliJ, while the tomcat7-maven-plugin relies on Tomcat 7.0.30.
So I downloaded the latest version, 7.0.42, and now IntelliJ is working fine.
I'm not sure what feature was missing in the 7.0.8, but IntelliJ was not able to start my Spring MVC application correctly.

Categories