Reputation: 2256
I am not able to deploy the my Spring BOOT REST Application on JBOSS EAP 7 Server.
However, its running fine after deployment on Apache Tomcat 8 Server.
Application Main Class:
@SpringBootApplication(scanBasePackages= {"org.nic"})
@PropertySource(value="classpath:database.properties")
public class PopulationApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(PopulationApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(PopulationApplication.class, args);
}
}
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>org.nic.PopulationApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
It's throwing the following error at server logs
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter]: Factory method 'httpPutFormContentFilter' threw exception; nested exception is java.lang.VerifyError: Failed to link com/fasterxml/jackson/databind/type/ReferenceType (Module "deployment.nhpmapi-0.0.1-SNAPSHOT.war:main" from Service Module Loader): Cannot inherit from final class
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579)
... 35 more
My Server environment only had JBOSS EAP 7.
I had research to solve the issue but could not find any success.
I had last option to remove Spring BOOT configuration into order to run on JBOSS EAP 7
Upvotes: 4
Views: 8679
Reputation: 141
I had the exact same problem and struggled for two days. Finally found a solution!
java.lang.VerifyError
is usually caused when there is inconsistency of classes.
As shown in the error message, it's caused by com.fasterxml.jackson.core.jackson-databind
Since Jboss has its internal Jackson module, and its version is different from your application specified.
To solve the problem, add jboss-deployment-structure.xml
and put it under src/main/webapp/WEB-INF
:
<?xml version='1.0' encoding='UTF-8'?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<exclusions>
<module name="com.fasterxml.jackson.core.jackson-annotations" />
<module name="com.fasterxml.jackson.core.jackson-core" />
<module name="com.fasterxml.jackson.core.jackson-databind" />
<module name="com.fasterxml.jackson.datatype.jackson-datatype-jdk8"/>
<module name="com.fasterxml.jackson.datatype.jackson-datatype-jsr310"/>
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
<module name="org.slf4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
It will avoid implicit dependencies and solve the problem.
Found the answer here and here and here thanks to them!
For more information:
Causes of getting a java.lang.VerifyError
What is jboss-deployment-structure.xml
Module Dependencies
Upvotes: 12
Reputation: 444
It seems like Spring is not able to instantiate beans from the WAR. Can you check classes inside are visible and are loaded properly?
Seems like class loading issue.
Upvotes: 0