Unable to deploy war to Tomcat - spring-boot

I get this error when deploying application war to the server:
12-Sep-2018 10:21:54.726 SEVERE [localhost-startStop-1] org.apache.catalina.startup.ContextConfig.processAnnotationsJar Unable to process Jar entry [module-info.class] from Jar [file:/xxx/apache-tomcat-8.0.41_xxxx/webapps/xxx/WEB-INF/lib/jaxb-api-2.3.0.jar] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19
Informations:
Application is a micro-service created with Spring Boot
Java used is version 8
Tomcat version: tomcat-8.0.41
Thank you.

module-info.class is a module descriptor for Java’s module system that was introduced in Java 9. Some code in Tomcat 8.0 is unable to read the bytecode in that class file so deployment is failing.
I believe this is a limitation of Tomcat 8.0 that has been fixed in 8.5. Also note that an end-of-life announcement has been made for 8.0 so you should be planning to upgrade ASAP even without this problem.

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.

Spark microframework 2.1 deploys well in Tomcat but not version 2.5

I am not good at all this web stuff, but I have managed to port a small Spark-tinyweb application to serve REST services from jetty to Tomcat, following the project from Leonan Luppi in
https://github.com/leonanluppi/SparkTomcat
But in the folder WebContent/WEB-INF/lib, if I replace the file
spark-core-2.1.jar
to a newer version:
spark-core-2.5.jar
The application does not work.
Any suggestions?
Your build.gradle file specifies the dependency on com.sparkjava:spark-core:2.1. You have to upgrade the version in the file too so that Gradle can resolve the dependencies and compile your app.

CDI Beans module deployment failed: couldn't start owb context

I have a Maven project. The build runs properly including tests. But when I run the tests only using Eclipse Luna, then the tests fail:
javax.enterprise.event.ObserverException: Caught Exception while handling event object with type : org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl
...
Caused by: java.lang.AbstractMethodError: org.apache.webbeans.container.InjectableBeanManager.getInjectionTargetFactory(Ljavax/enterprise/inject/spi/AnnotatedType;)Ljavax/enterprise/inject/spi/InjectionTargetFactory;
at com.sun.faces.util.cdi11.CDIUtilImpl.createHelperBean(CDIUtilImpl.java:76)
at com.sun.faces.flow.FlowCDIExtension.afterBeanDiscovery(FlowCDIExtension.java:120)
... 60 more
INFO - Undeploying app: .../classpath.ear
org.apache.openejb.OpenEJBException: Creating application failed: /home/schnikow/projects/barbuchon2/BarbuchonKernel-2.0r0b-SNAPSHOT/classpath.ear: couldn't start owb context
(full stack trace is too long, I can provide it if needed)
I've add the needed JVM argument (-javaagent:/usr/devel/apache-tomee-webprofile-1.7.1/lib/openejb-javaagent.jar) in the launch configuration. I may miss something trivial, but I haven't any idea, what.
I use Eclipse Luna and Tomee embedded EJB container running on Java 8 virtual machine.
it seems you use mojarra, is it a CDI 1.0 compatible version or 1.1 (only TomEE 2 will be CDI 1.1/1.2 compatible)

deployment single ejb module with dependencies in netbeans and glassfish

In NB 7.2 i have ejb module managed by maven with several dependencies. I try to run it on Glassfish 3.1.2.2 but it seems like server doesn't resolve libraries on classpath. I think arguments in deploy command ("deploy?DEFAULT=..." - i'm not sure it is command) are correct - there are all libraries in this command, but during creating ejb server throws class not found exception - although this class is in library in deploy command.
It is possible to deploy single EJB module with dependencies without enterprise application?
Thanks for advice
There are a couple of mechanisms for deploying EJBs. If the EJB has dependencies and is used in a web application, check if it can be used in the EJB lite configuration. It is easiest to deploy it in a WAR file along with a web application. There is an article Introducing the Java EE 6 Platform: Part 3 that details a number of the specifics.
Alternatively, you may deploy it as part of an EAR file which will include the dependencies.
If the EJB must be used as a standalone EJB, the dependencies must be be in the server classpath, or repackaged in the EJB jar file. NetBeans 7.2.1 can do that for you.

Resources