I am using Spring Boot to implement a spark application. I build an uber jar, and use spark-submit to execute the application. But I got the following exception:
18/06/05 15:32:37 ERROR SpringApplication: Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gsonBuilder' defined in class path resource
[org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [com.google.gson.GsonBuilder]: Factory method
'gsonBuilder' threw exception; nested exception is
java.lang.BootstrapMethod
Error: java.lang.NoSuchMethodError: com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1254)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1103)
.....
The exception is still there even if I put the following dependency in my pom.xml:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>compile</scope>
</dependency>
How can I resolve this dependency issue?
Maybe you can use #SpringBootApplication(exclude = {GsonAutoConfiguration.class}) to disable gson autoconfiguration.
Related
Recently, I have upgraded to Spring 5.3.20 from 4.0.5.RELEASE and I have changed the other dependencies versions also. It is getting successfully build, but when I try to run, it is giving error after jetty.
Upgraded versions in Pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java-version>1.8</java-version>
<org.springframework-version>5.3.20</org.springframework-version>
<org.springframework-security-version>5.6.3</org.springframework-security-version>
<org.apache.tiles-version>3.0.4</org.apache.tiles-version>
<!-- <org.hibernate-version>5.6.10.Final</org.hibernate-version> --> <!-- 4.3.5.Final -->
<org.hibernate-version>5.3.7.Final</org.hibernate-version><!-- 5.1.17.Final -->
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.7.7</org.slf4j-version>
<jackson.version>2.11.3</jackson.version> <!-- 2.11.3 -->
<!-- <jackson.version>2.14.1</jackson.version> -->
</properties>
The build is successful (using maven) but when I try to run the code I am getting this error after jetty,
Error -
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#31' while setting bean property 'sourceList' with key [31];
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#31': Cannot resolve reference to bean 'concurrencyFilter' while setting constructor argument with key [2];
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'concurrencyFilter' defined in ServletContext resource [/WEB-INF/spring/security.xml]: Instantiation of bean failed;
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.session.ConcurrentSessionFilter]: No default constructor found;
nested exception is java.lang.NoSuchMethodException: org.springframework.security.web.session.ConcurrentSessionFilter.<init>()
Can anybody help me to resolve this error. Would really appreciate any help.
When created a Spring Boot with JPA and Camel JPA, and throws below "Failed to instantiate [com.zaxxer.hikari.HikariDataSource] ... " error. If exclude the hikary depency for spring-boot-data-jpa start inside the pom.xml, this goes away. Finding difficulties in including a db connection with spring boot jpa and camel-jpa.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.22.jar:5.3.22]
... 107 common frames omitted
It is missing mysql reference.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
Assuming you're using mysql, the driver must be on the classpath. If you're using maven, that means your pom must declare the mysql driver as a dependency.
during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'taxLotsController': Unsatisfied
dependency expressed through field 'taxLotsService'; nested exception
is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'taxLotsServiceImpl': Lookup method resolution
failed; nested exception is java.lang.IllegalStateException: Failed to
introspect Class [com.frk.fds.api.service.impl.TaxLotsServiceImpl]
from ClassLoader [ParallelWebappClassLoader
Please check your dependency on pom.xml maybe some dependency problem occurs:
you can try with this:
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>9.0.37</version>
</dependency>
Maybe your TaxLotsServiceImpl class referring to another class i.e. is missing right now.
Please find out these missing dependencies if there are any.
I am relatively new to spring ,I am facing jackson data bind error while deploying the war to Jboss EAP 7 but when i deploy the same war on wildfly 10 its deploying successfully .I have added Moxy but its not helping on Jboss
Jboss Log
"{\"WFLYCTL0080: Failed services\" => {\"jboss.undertow.deployment.default-server.default-host.\\"/gamification-1.0.0\\"\" => \"org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host.\\"/gamification-1.0.0\\": java.lang.RuntimeException: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.JavaType.isTypeOrSubTypeOf(Ljava/lang/Class;)Z
Caused by: java.lang.RuntimeException: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.JavaType.isTypeOrSubTypeOf(Ljava/lang/Class;)Z
Caused by: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.JavaType.isTypeOrSubTypeOf(Ljava/lang/Class;)Z
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.JavaType.isTypeOrSubTypeOf(Ljava/lang/Class;)Z
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.JavaType.isTypeOrSubTypeOf(Ljava/lang/Class;)Z\"}}"
I know It has passed many days just Answering if someone else got the problem.
What i did was just Excluded Rest Easy Implementation from Jboss by Adding the Following Config File ,So it wont clash with Jersey config
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
<module name="org.jboss.resteasy.resteasy-jackson-provider" />
</exclusions>
</deployment>
</jboss-deployment-structure>
After including that Issue Was resolved
Having an issue deploying a Spring 3.0.7 MVC web application to Tomcat via Eclipse and the WST plugin. Getting this error message:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'messageSource' defined in ServletContext
resource [/WEB-INF/beans/appContext.xml]: BeanPostProcessor before
instantiation of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'org.springframework.transaction.config.internalTransactionAdvisor':
Cannot resolve reference to bean
'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0'
while setting bean property 'transactionAttributeSource'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0':
Initialization of bean failed; nested exception is
java.lang.IllegalArgumentException: error at ::0 can't find referenced
pointcut webLayer
Any ideas? Thanks.
Got past this issue for now. Was using the wrong version of JDK for our project (1.7 instead of 1.6).
You can try updating the pom to use aspectjrt-1.7 / aspectjweaver-1.7 for 1.7 java.
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.4</version>
</dependency>