How to properly deploy war file in tomcat? - spring

Im Deploying the .war in webapps, but at manager/html/WarFileName gives 404 error
(https://i.stack.imgur.com/bvtLW.png)
I have tried to check for logs, but catalina.out seems to be fine without any errors. Obvisouly even reaching the path with postman does not work.
Do you have any ideas?

Fixed by downgrade tomcat from version 10 to 8;
Tomcat 10 keep looking for jakarta packages, while my springboot app was still using Javax
Tomcat 10.0.4 doesn't load servlets (#WebServlet classes) with 404 error

Related

Is there any way to disable TLD Validation in JBOSS EAP 7.2?

I am trying to migrate my project from jboss-eap-6.4 to jboss-eap-7.2.
When I try to deploy my war file, I get following error:
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYUT0027: Failed to parse XML descriptor \"/C:/jboss-eap-7.2/standalone/deployments/my.war/WEB-INF/lib/spring-modules-validation-1.0.0.jar/META-INF/valang.tld\" at [13,23]
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[13,23]
Message: Unexpected value 'body-content' encountered"}}
I tried searching about this and I got to know that this is common issue. And I got one of the solution as,
changing <body-content>None</body-content> to <body-content>empty</body-content> in valang.tld
in this redhat link: https://access.redhat.com/solutions/910833
as body-content is present at line 13 and I read the documentation for jboss eap 7.2 in which it has written that the value should be empty.
I saw another solution as making this as dependency in maven pom.xml or excluding it.
But I can't do any of this things.
I am using JBOSS EAP 7.2 with gradle, So is there any thing I can do by making changes in gradle or JBOSS's configuration files to solve this issue?
Please help me on this :)
I finally made the same change in the spring-modules-calidation.jar. My concern was to after making this change does it affect my other server, as I was running this on jboss as well as tomcat. So now I am providing the updated jar to JBOSS EAP 7 and the original one to tomcat.

2 Spring WebApplicationInitializers detected on classpath

i have a springboot webapp and when i deployed it on my server on tomcat 7.0.54 then i got following message in catalina.out
INFO: 2 Spring WebApplicationInitializers detected on classpath
and my application is deploying twice which casue Exception
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [inbound] with key 'inbound'; nested exception is javax.management.InstanceAlreadyExistsException
but i tried the same war file on my local system with tomcat 7.0.37 and the application works fine
any suggestion?
Thanks.
I had the same issue. I removed spring-boot-starter-thymeleaf from my pom.xml file and it worked. You may have a library in your classpath which has another WebApplicationInitializer.
I had the same issue. I removed compile("org.springframework.boot:spring-boot-actuator-docs") from my gradle file and it worked.
I had an identical situation. Spring Boot + Tomcat + InstanceAlreadyExistsException on a remote server but worked perfectly on my local Tomcat.
The cause was the remote server having two Host elements in server.xml pointing to the same Tomcat appBase directory (webapps.) That caused all webapps to be loaded twice. For some webapps it wasn't a problem, but for mine it was because it tried to register MBeans twice.
My solution was to replace one of the Host elements with an Alias under the other Host element. Now I just have one Host element and apps are loaded only once each.

Read emails on Tomcat: ClassNotFoundException: javax.mail.MessagingException

My application is running on Tomcat 7.
I'm trying to read emails from inbox, and for that I use a normal Java class.
There is also a Servlet that calls the method readMails in the mentioned class.
Now I get an exception:
java.lang.ClassNotFoundException: javax.mail.MessagingException
...
I use IntelliJ IDEA with Maven, I changed the dependency of javax.mail a lot (see http://mvnrepository.com/artifact/javax.mail), but the exception keeps coming up.
I've also changed the Version of Tomcat (7 and 8), and the version of "Project SDK" (1.7 and 1.8) and "Project language level" (7 and 8).
I've read somewhere that there is a difference between reading emails via IMAP with normal Java application and running it on Tomcat.
In a previous project I read emails successfully with a normal Java application.
Can anyone help me with this exception?
JavaMail API is not included by default among Tomcat libraries.
Make sure that JavaMail dependency (mail-X.X.jar) is either packaged together with your application (in WEB-INF/lib) or is in a folder that Tomcat class loaders read (for example $CATALINA_HOME/lib), as described here:
http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
Thanks, it works now.
I put the jar file (javax.mail: javax.mail-api-1.5.4.jar) downloaded by maven (.m2/repository/ ...) into WEB-INF/lib (in my project).
I also needed to put another jar file into WEB-INF/lib (com.sun.mail: javax.mail-1.5.4.jar) due to this exception:
java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger
javax.mail.Session.initLogger(Session.java:226)
javax.mail.Session.<init>(Session.java:210)
javax.mail.Session.getDefaultInstance(Session.java:321)
I added
<packaging>war</packaging>
to my pom.xml. This way maven puts the dependencies in the target folder.

grails 2.3 java.lang.NoClassDefFoundError: org/apache/batik/dom/svg/SVGOMDocument

When i run my grails application in tomcat i get the following error
java.lang.NoClassDefFoundError: org/apache/batik/dom/svg/SVGOMDocument. But the batik-svg-dom.1.7.jar is packaged in the war and in the classpath.
I don't however get this error when i am running the application in debug mode in STS.
I am using Grails 2.3 and building my war using maven. I am using FOP and have excluded the "xml-apis".
I have tried to place the batik-svg-dom.jar in the lib folder of tomcat, that did not work.
Thanks in advance.

grails tomcat 7 deployment

So I have a grails 2.0.4 application that works exactly the way I want. I created the war file and deployed it to Tomcat 7. I'm getting an error saying that the application can't find the jar I'm using to connect to oracle (ojdbc6.jar). The jar is listed under mywebapp/WEB-INF/lib. WHY can't it be found?? Any help would be greatly appreciated!
The jar file should be in the toplevel lib directory of your project (or specified as a dependency in a repository), not webapp/WEB-INF/lib. Is the jar file actually inside the warfile? You can test this by opening the war as a zip file, or by running jar tf target/mywebapp*.war and looking for ojdbc6.jar. If it is, it should get deployed and you should see it in tomcat7/webapps/mywebapp/WEB-INF/lib.
The default environment for grails war is production instead of development. Make sure you've got the production data source configured correctly in grails-app/conf/DataSource.groovy

Resources