I am using jersey v2.21 and I am trying to set my ObjectMapper with couple of configurations:
Don't return a property if its value is null
Return the properties of object ordered alphabetically
Return dates in a format like this: 2015-06-22T17:57:05.000-07:00
This how my ObjectMapper looks like:
Edited:
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
/**
* Created by Shiran Maor on 1/13/16.
*/
#Provider
#Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public class ObjectMapperResolver implements ContextResolver<ObjectMapper> {
private ObjectMapper defaultMapper;
public ObjectMapperResolver() {
this.defaultMapper = createDefaultMapper();
}
#Override
public ObjectMapper getContext(Class<?> aClass) {
return this.defaultMapper;
}
private static ObjectMapper createDefaultMapper() {
ObjectMapper result = new ObjectMapper();
result = result.configure(SerializationFeature.INDENT_OUTPUT, true);
result = result.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
result = result.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
result.setSerializationInclusion(JsonInclude.Include.NON_NULL);
result.setDateFormat(new ISO8601DateFormat());
return result;
}
}
Edit:
These are my dependencies:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.21</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
<version>2.21</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>2.7.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.7.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-xml-provider</artifactId>
<version>2.7.0</version>
<scope>runtime</scope>
</dependency>
Edit:
This is the tree dependencies:
[INFO] +- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.1.1:compile
[INFO] +- org.apache.httpcomponents:httpcore:jar:4.1.1:compile
[INFO] +- commons-httpclient:commons-httpclient:jar:3.1:runtime
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.7:runtime
[INFO] +- org.slf4j:jul-to-slf4j:jar:1.7.7:runtime
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.7:runtime
[INFO] +- log4j:log4j:jar:1.2.14:compile
[INFO] +- org.mockito:mockito-all:jar:1.9.5:test
[INFO] +- org.jasig.cas.client:cas-client-core:jar:3.2.1:compile
[INFO] +- com.google.code.gson:gson:jar:1.7.1:compile
[INFO] +- org.testng:testng:jar:6.8.8:test
[INFO] | +- org.beanshell:bsh:jar:2.0b4:test
[INFO] | \- com.beust:jcommander:jar:1.27:test
[INFO] +- net.sf.ehcache:ehcache-core:jar:2.4.2:compile
[INFO] +- commons-cli:commons-cli:jar:1.2:runtime
[INFO] +- commons-io:commons-io:jar:1.4:compile
[INFO] +- commons-lang:commons-lang:jar:2.4:compile
[INFO] +- com.thoughtworks.xstream:xstream:jar:1.2.2:provided
[INFO] | \- xpp3:xpp3_min:jar:1.1.4c:provided
[INFO] +- org.glassfish.jersey.containers:jersey-container-servlet:jar:2.22.1:runtime
[INFO] | +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.22.1:runtime
[INFO] | +- org.glassfish.jersey.core:jersey-common:jar:2.22.1:runtime
[INFO] | | \- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.22.1:runtime
[INFO] | \- org.glassfish.jersey.core:jersey-server:jar:2.22.1:runtime
[INFO] | \- org.glassfish.jersey.core:jersey-client:jar:2.22.1:runtime
[INFO] +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.21:runtime
[INFO] | +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.21:runtime
[INFO] | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.5.4:runtime
[INFO] +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.21:runtime
[INFO] | +- org.glassfish.hk2:hk2-api:jar:2.4.0-b31:runtime
[INFO] | | +- org.glassfish.hk2:hk2-utils:jar:2.4.0-b31:runtime
[INFO] | | \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b31:runtime
[INFO] | +- org.glassfish.hk2.external:javax.inject:jar:2.4.0-b31:runtime
[INFO] | +- org.glassfish.hk2:hk2-locator:jar:2.4.0-b31:runtime
[INFO] | | \- org.javassist:javassist:jar:3.18.1-GA:runtime
[INFO] | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:runtime
[INFO] +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.7.0:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.4.2:compile
[INFO] +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.7.0:runtime
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.7.0:compile
[INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.7.0:runtime
[INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-xml-provider:jar:2.7.0:runtime
[INFO] | +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.7.0:runtime
[INFO] | +- org.codehaus.woodstox:stax2-api:jar:3.1.4:runtime
[INFO] | \- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:runtime
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- javax.servlet.jsp:javax.servlet.jsp-api:jar:2.3.1:provided
[INFO] +- org.apache.httpcomponents:httpmime:jar:4.1.1:test
[INFO] +- org.bouncycastle:bcprov-jdk15:jar:1.45:test
[INFO] +- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- javax.xml.bind:jaxb-api:jar:2.2.11:compile
[INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.2.11:runtime
[INFO] +- com.sun.xml.bind:jaxb-core:jar:2.2.11:runtime
[INFO] +- org.eclipse.persistence:eclipselink:jar:2.6.1:runtime
[INFO] | +- org.eclipse.persistence:javax.persistence:jar:2.1.0:runtime
[INFO] | +- org.eclipse.persistence:commonj.sdo:jar:2.1.1:runtime
[INFO] | +- javax.validation:validation-api:jar:1.1.0.Final:runtime
[INFO] | \- org.glassfish:javax.json:jar:1.0.4:runtime
[INFO] +- com.sun.xml.bind:jaxb-xjc:jar:2.2.11:runtime
[INFO] \- javax.xml.stream:stax-api:jar:1.0-2:runtime
Edit:
This is my web.xml part:
<servlet>
<servlet-name>api-service-endpoints</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>
com.mypack
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
However, I am getting null values, not alphabetic, and with dates represented in milliseconds.
Update:
After updating the dependencies, I am getting this exception:
<pre>org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: com.fasterxml.jackson.jaxrs.cfg.EndpointConfigBase.<init>(Lcom/fasterxml/jackson/databind/cfg/MapperConfig;)V
org.glassfish.jersey.servlet.internal.ResponseWriter.rethrow(ResponseWriter.java:278)
org.glassfish.jersey.servlet.internal.ResponseWriter.failure(ResponseWriter.java:260)
org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:509)
org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:334)
org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
org.glassfish.jersey.internal.Errors.process(Errors.java:315)
org.glassfish.jersey.internal.Errors.process(Errors.java:297)
org.glassfish.jersey.internal.Errors.process(Errors.java:267)
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471)
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
com.anaplan.api.security.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:63)
</pre>
Update1:
I was reading about depedencies issues that jersey have and when I removed:
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.21</version>
<scope>runtime</scope>
</dependency>
I am getting the result as expected, BUT, only in xml, not in json.
any ideas?
Adding this dependency:
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.22.1</version>
<scope>runtime</scope>
</dependency>
Fixed it.
Add dependency:
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-base</artifactId>
<version>${jackson.version}</version>
</dependency>
Your ObjectMapper works perfectly (with some minor modifications) as long as you're using it correctly (e.g., registering jackson feature and registering your provider in the jax-rs application).
If you substitute MyObjectMapperProvider with your object mapper in the json-jackson example in Jersey (see https://github.com/jersey/jersey/tree/2.x/examples/json-jackson) slightly modified
private static ObjectMapper createDefaultMapper() {
ObjectMapper result = new ObjectMapper();
result = result.configure(SerializationFeature.INDENT_OUTPUT, true);
result = result.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
result = result.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
result.setSerializationInclusion(JsonInclude.Include.NON_NULL);
result.setDateFormat(new ISO8601DateFormat());
return result;
}
it will work just fine.
Related
I am fairly new to Spring Boot and working on a project ,but getting an error of URL attribute not specified in my console.
Application.properties files
spring.datasourse.url=jdbc:mysql://localhost:3306/employee_directory?useSSL=false&serverTimeZone=UTC
spring.datasourse.username=springstudent
spring.datasourse.password=springstudent
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto = update
My pom.xml file (~generated using spring.io)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.luv2code.springboot</groupId>
<artifactId>cruddemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>cruddemo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- --> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I know my error seems to be in application properties file but i have checked the files and is not able to seems to find any error.
my Appilcation
package com.luv2code.springboot.cruddemo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class CruddemoApplication {
public static void main(String[] args) {
SpringApplication.run(CruddemoApplication.class, args);
}
}
my EmployeeDAOImpl
package com.luv2code.springboot.cruddemo.dao;
import java.util.List;
import javax.persistence.EntityManager;
import org.hibernate.Session;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.luv2code.springboot.cruddemo.entity.Employee;
#Repository
public class EmployeeDAOHibernateImpl implements EmployeeDAO {
private EntityManager entityManager;
#Autowired
public EmployeeDAOHibernateImpl(EntityManager theEntityManager) {
entityManager = theEntityManager;
}
#Override
public List<Employee> findAll() {
Session currentSession = entityManager.unwrap(Session.class);
Query<Employee> theQuery = currentSession.createQuery("from Employee", Employee.class);
List<Employee> employees = theQuery.getResultList();
return employees;
}
#Override
public Employee findById(int theId) {
Session currentSession = entityManager.unwrap(Session.class);
Employee theEmployee = currentSession.get(Employee.class, theId);
return theEmployee;
}
#Override
public void save(Employee theEmployee) {
Session currentSession = entityManager.unwrap(Session.class);
currentSession.saveOrUpdate(theEmployee);
}
#Override
public void delete(int theId) {
Session currentSession = entityManager.unwrap(Session.class);
Query theQuery = currentSession.createQuery("delete from Employee where id=:employeeId");
theQuery.setParameter("employeeId", theId);
theQuery.executeUpdate();
}
}
my EMployeeDAO
package com.luv2code.springboot.cruddemo.dao;
import java.util.List;
import com.luv2code.springboot.cruddemo.entity.Employee;
public interface EmployeeDAO {
public List<Employee> findAll();
public Employee findById(int theId);
public void save(Employee theEmployee);
public void delete(int theId);
}
my error screen
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.3.RELEASE)
2020-08-24 14:03:56.750 INFO 11608 --- [ restartedMain] c.l.s.cruddemo.CruddemoApplication : Starting CruddemoApplication on DESKTOP-AR3MS4U with PID 11608 (D:\Eclipse && STS\eclipse\cruddemo\target\classes started by Abhijay in D:\Eclipse && STS\eclipse\cruddemo)
2020-08-24 14:03:56.763 INFO 11608 --- [ restartedMain] c.l.s.cruddemo.CruddemoApplication : No active profile set, falling back to default profiles: default
2020-08-24 14:03:56.990 INFO 11608 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-08-24 14:03:56.991 INFO 11608 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-08-24 14:04:00.471 INFO 11608 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-08-24 14:04:00.493 INFO 11608 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-08-24 14:04:00.494 INFO 11608 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.37]
2020-08-24 14:04:00.957 INFO 11608 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-08-24 14:04:00.957 INFO 11608 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3965 ms
2020-08-24 14:04:01.323 WARN 11608 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeDAOHibernateImpl' defined in file [D:\Eclipse && STS\eclipse\cruddemo\target\classes\com\luv2code\springboot\cruddemo\dao\EmployeeDAOHibernateImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.persistence.EntityManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2020-08-24 14:04:01.331 INFO 11608 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-08-24 14:04:01.380 INFO 11608 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-08-24 14:04:02.111 ERROR 11608 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.luv2code.springboot.cruddemo.dao.EmployeeDAOHibernateImpl required a bean of type 'javax.persistence.EntityManager' that could not be found.
Action:
Consider defining a bean of type 'javax.persistence.EntityManager' in your configuration.
I am new to the AWS ecosystem and in one of our code snippet we are consuming from the Kinesis stream of DynamoDB. It was working all well till i added JPA dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
after that when i tried running my SpringBoot Application it ends up with this error
java.lang.NoClassDefFoundError: com/amazonaws/transform/SimpleTypeJsonUnmarshallers$DateJsonUnmarshallerFactory
at com.amazonaws.services.dynamodbv2.model.transform.TableDescriptionJsonUnmarshaller.unmarshall(TableDescriptionJsonUnmarshaller.java:70) ~[aws-java-sdk-dynamodb-1.11.376.jar:na]
at com.amazonaws.services.dynamodbv2.model.transform.DescribeTableResultJsonUnmarshaller.unmarshall(DescribeTableResultJsonUnmarshaller.java:53) ~[aws-java-sdk-dynamodb-1.11.376.jar:na]
at com.amazonaws.services.dynamodbv2.model.transform.DescribeTableResultJsonUnmarshaller.unmarshall(DescribeTableResultJsonUnmarshaller.java:29) ~[aws-java-sdk-dynamodb-1.11.376.jar:na]
at com.amazonaws.http.JsonResponseHandler.handle(JsonResponseHandler.java:118) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.JsonResponseHandler.handle(JsonResponseHandler.java:43) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.response.AwsResponseHandlerAdapter.handle(AwsResponseHandlerAdapter.java:70) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleResponse(AmazonHttpClient.java:1545) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1270) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1056) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513) ~[aws-java-sdk-core-1.11.312.jar:na]
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:3443) ~[aws-java-sdk-dynamodb-1.11.376.jar:na]
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:3419) ~[aws-java-sdk-dynamodb-1.11.376.jar:na]
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executeDescribeTable(AmazonDynamoDBClient.java:1660) ~[aws-java-sdk-dynamodb-1.11.376.jar:na]
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.describeTable(AmazonDynamoDBClient.java:1635) ~[aws-java-sdk-dynamodb-1.11.376.jar:na]
at com.shc.microservice.Application.run(Application.java:79) [classes/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:732) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:716) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:703) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:304) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at com.shc.microservice.Application.main(Application.java:54) [classes/:na]
Caused by: java.lang.ClassNotFoundException: com.amazonaws.transform.SimpleTypeJsonUnmarshallers$DateJsonUnmarshallerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372) ~[na:1.8.0_11]
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_11]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_11]
at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_11]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_11]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_11]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_11]
... 27 common frames omitted
Things tried so far:
I googled it and found from other thread to add aws-sdk and aws-sdk-core dependencies but to no luck. Here is the list of dependencies in the pom file which i have been working on.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<!-- email functionality -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<!-- spring-kafka -->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>${spring-kafka.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<version>${spring-kafka.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.everit.json</groupId>
<artifactId>org.everit.json.schema</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<!-- kinesis -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-kinesis-client</artifactId>
<version>1.8.8</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-kinesis-producer</artifactId>
<version>0.12.9</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>dynamodb-streams-kinesis-adapter</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.312</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-core -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.312</version>
</dependency>
</dependencies>
I got this same error and it was because I was using different versions of my com.amazonaws dependencies.
So my solution was to ensure that my 2 amazon dependencies had the same version as shown below in my pom.xml.
</properties>
<aws.version>1.11.627</aws.version>
</properties>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-kinesis</artifactId>
<version>${aws.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-ssm</artifactId>
<version>${aws.version}</version>
</dependency>
Seems to be working for me
However, I did remove the explicit versions which are already specified in Spring Boot parent POM and used postgresql instead of mysql. But, I suppose that should not matter.
Here is my pom.xml.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.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>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<!-- email functionality -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>
<!-- spring-kafka -->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.everit.json</groupId>
<artifactId>org.everit.json.schema</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<!-- kinesis -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-kinesis-client</artifactId>
<version>1.8.8</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-kinesis-producer</artifactId>
<version>0.12.9</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>dynamodb-streams-kinesis-adapter</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.312</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-core -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.312</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Here is run log.
-> mvn -s /home/dragon/.m2-personal/settings.xml spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) > test-compile # demo >>>
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) # demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) # demo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) # demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/dragon/workspace-personal/demo/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) # demo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) < test-compile # demo <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) # demo ---
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.4.RELEASE)
2018-08-01 07:55:13.580 INFO 27190 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication on divinedragon-box with PID 27190 (/home/dragon/workspace-personal/demo/target/classes started by dragon in /home/dragon/workspace-personal/demo)
2018-08-01 07:55:13.584 INFO 27190 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2018-08-01 07:55:13.653 INFO 27190 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#70bb3cd: startup date [Wed Aug 01 07:55:13 CEST 2018]; root of context hierarchy
2018-08-01 07:55:15.140 INFO 27190 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.kafka.annotation.KafkaBootstrapConfiguration' of type [org.springframework.kafka.annotation.KafkaBootstrapConfiguration$$EnhancerBySpringCGLIB$$70ac68a3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-08-01 07:55:15.206 INFO 27190 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$9cfa5720] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-08-01 07:55:15.263 INFO 27190 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$1c7aa452] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-08-01 07:55:15.735 INFO 27190 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-08-01 07:55:15.776 INFO 27190 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-08-01 07:55:15.776 INFO 27190 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.32
2018-08-01 07:55:15.794 INFO 27190 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-08-01 07:55:15.911 INFO 27190 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-08-01 07:55:15.912 INFO 27190 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2263 ms
2018-08-01 07:55:16.016 INFO 27190 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-08-01 07:55:16.021 INFO 27190 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-08-01 07:55:16.022 INFO 27190 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-08-01 07:55:16.022 INFO 27190 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-08-01 07:55:16.022 INFO 27190 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-08-01 07:55:16.260 INFO 27190 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-08-01 07:55:16.355 INFO 27190 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-08-01 07:55:16.428 INFO 27190 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-08-01 07:55:16.453 INFO 27190 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-08-01 07:55:16.583 INFO 27190 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2018-08-01 07:55:16.586 INFO 27190 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-08-01 07:55:16.638 INFO 27190 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-08-01 07:55:16.792 INFO 27190 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL95Dialect
2018-08-01 07:55:16.963 INFO 27190 --- [ main] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.useContextualLobCreation(LobCreatorBuilderImpl.java:113) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.makeLobCreatorBuilder(LobCreatorBuilderImpl.java:54) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.<init>(JdbcEnvironmentImpl.java:271) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:114) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:242) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:861) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) [spring-orm-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) [spring-orm-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) [spring-orm-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) [spring-orm-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) [spring-orm-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1758) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1695) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at com.example.demo.DemoApplication.main(DemoApplication.java:10) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:496) ~[na:na]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_121]
Caused by: java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.
at org.postgresql.Driver.notImplemented(Driver.java:688) ~[postgresql-42.2.4.jar:42.2.4]
at org.postgresql.jdbc.PgConnection.createClob(PgConnection.java:1269) ~[postgresql-42.2.4.jar:42.2.4]
... 50 common frames omitted
2018-08-01 07:55:16.965 INFO 27190 --- [ main] org.hibernate.type.BasicTypeRegistry : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType#24a6e0a4
2018-08-01 07:55:17.193 INFO 27190 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-08-01 07:55:17.320 INFO 27190 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-01 07:55:17.957 INFO 27190 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#70bb3cd: startup date [Wed Aug 01 07:55:13 CEST 2018]; root of context hierarchy
2018-08-01 07:55:18.028 WARN 27190 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2018-08-01 07:55:18.102 INFO 27190 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-08-01 07:55:18.103 INFO 27190 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-08-01 07:55:18.154 INFO 27190 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-01 07:55:18.154 INFO 27190 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-01 07:55:18.660 INFO 27190 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-08-01 07:55:18.662 INFO 27190 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-08-01 07:55:18.667 INFO 27190 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-08-01 07:55:18.676 INFO 27190 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483547
2018-08-01 07:55:18.716 INFO 27190 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-08-01 07:55:18.720 INFO 27190 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 5.706 seconds (JVM running for 10.403)
^C2018-08-01 07:55:21.109 INFO 27190 --- [ Thread-4] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#70bb3cd: startup date [Wed Aug 01 07:55:13 CEST 2018]; root of context hierarchy
2018-08-01 07:55:21.118 INFO 27190 --- [ Thread-4] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 2147483547
2018-08-01 07:55:21.118 INFO 27190 --- [ Thread-4] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
2018-08-01 07:55:21.119 INFO 27190 --- [ Thread-4] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2018-08-01 07:55:21.120 INFO 27190 --- [ Thread-4] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
2018-08-01 07:55:21.120 INFO 27190 --- [ Thread-4] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2018-08-01 07:55:21.121 INFO 27190 --- [ Thread-4] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2018-08-01 07:55:21.128 INFO 27190 --- [ Thread-4] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.950 s
[INFO] Finished at: 2018-08-01T07:55:21+02:00
I tried Spring boot for a webapp. When I try to start my server I get an error message:
I couldn't find any similar posts online so I'm refering to stackoverflow.
Thanks in advance!!
2017-07-14 10:37:47.525 WARN 10452 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property lastName found for type User!
2017-07-14 10:37:47.525 INFO 10452 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-07-14 10:37:47.525 INFO 10452 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-07-14 10:37:47.540 INFO 10452 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-07-14 10:37:47.540 ERROR 10452 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [
Application.properties:
spring.datasource.url = jdbc:mysql://localhost:3306/test?verifyServerCertificate=false&useSSL=false&requireSSL=false
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.username=Stack0verFlow
spring.datasource.password=Stack0verFlow
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.thymeleaf.cache=false
Pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.flowcode</groupId>
<artifactId>WebApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>WebApp</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.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>
</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-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
As mentioned in the comments, some part of the exception is missing. However, the issue can also be found in the first line of the stacktrace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository
And:
org.springframework.data.mapping.PropertyReferenceException: No property lastName found for type User!
So, you should check your UserRepository, since you have a query or a method name that references a property called lastName even though you don't have one in your User entity.
I've created simple project that creates a tree of users in neo4j. Everything works well when I am using standard HTTP protocol. Once I switch to HTTPS application is unable to retrieve any object that has relations. Object looks like this:
#Indexed(indexType=IndexType.SIMPLE, unique=true, indexName="profileIdIDX")
private Long profileId;
// Country where this affiliate exists. -[:LIVESIN]->
#Fetch
#RelatedTo(direction=Direction.OUTGOING,type=RelationTypes.LIVESIN)
private Country country;
// Role of user in affiliate tree
private Integer role;
// Time till this user is eligible to earn affiliate's income
private Long affilElig;
// Time till this user is eligible to earn partner's income
private Long partnElig;
// If user is eligible to get partner's income we need to know his partner level
private Integer partnLvl;
// Direct reference to patron -[:SUPREME]->
#Fetch
#RelatedTo(direction=Direction.OUTGOING, type=RelationTypes.SUPREME)
private Affiliate patron;
// Collection of users registered in affiliate tree in first line of this user <-[:SUPREME]-
#RelatedTo(direction=Direction.INCOMING, type=RelationTypes.SUPREME, elementClass=Affiliate.class)
private Set<Affiliate> subAffilites;
// If user is a VAT payer we do not calculate VAT tax for his income (depends as well on
// country.vatRegime). Possible values are {0=do not calculate, 1=calculate}
#Min(value=0, message="calculateVAT cant be less then 0")
#Max(value=1, message="calculateVAT cant be greather then 1")
private Integer calculateVAT;
When trying to retrieve it through simple repository method:
#Query("start n=node:profileIdIDX(profileId={0}) return n")
public Affiliate findByProfileId(Long profileId);
JSON simply throws this exception:
Error reading as JSON '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /db/data/node/3/https://my.server.com:7473/db/data/node/3/relationships/out/SUPREME. Reason:
<pre> Not Found</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</body>
</html>
'" type="java.lang.RuntimeException">java.lang.RuntimeException: Error reading as JSON '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /db/data/node/3/https://my.server.com:7473/db/data/node/3/relationships/out/SUPREME. Reason:
<pre> Not Found</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</body>
</html>
'
at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:57)
at org.neo4j.rest.graphdb.util.JsonHelper.jsonToSingleValue(JsonHelper.java:62)
at org.neo4j.rest.graphdb.RequestResult.toEntity(RequestResult.java:114)
at org.neo4j.rest.graphdb.converter.RelationshipIterableConverter.convertFromRepresentation(RelationshipIterableConverter.java:45)
at org.neo4j.rest.graphdb.ExecutingRestAPI.wrapRelationships(ExecutingRestAPI.java:310)
at org.neo4j.rest.graphdb.ExecutingRestAPI.getRelationships(ExecutingRestAPI.java:480)
at org.neo4j.rest.graphdb.RestAPIFacade.getRelationships(RestAPIFacade.java:197)
at org.neo4j.rest.graphdb.entity.RestNode.getRelationships(RestNode.java:83)
at org.springframework.data.neo4j.fieldaccess.RelationshipHelper.getOtherNodes(RelationshipHelper.java:50)
at org.springframework.data.neo4j.fieldaccess.RelationshipHelper.getStatesFromEntity(RelationshipHelper.java:153)
at org.springframework.data.neo4j.fieldaccess.RelationshipHelper.createEntitySetFromRelationshipEndNodes(RelationshipHelper.java:127)
at org.springframework.data.neo4j.fieldaccess.RelatedToFieldAccessor.createEntitySetFromRelationshipEndNodes(RelatedToFieldAccessor.java:86)
at org.springframework.data.neo4j.fieldaccess.RelatedToSingleFieldAccessorFactory$RelatedToSingleFieldAccessor.getValue(RelatedToSingleFieldAccessorFactory.java:76)
at org.springframework.data.neo4j.fieldaccess.DefaultEntityState.getValue(DefaultEntityState.java:97)
at org.springframework.data.neo4j.support.mapping.SourceStateTransmitter.copyEntityStatePropertyValue(SourceStateTransmitter.java:90)
at org.springframework.data.neo4j.support.mapping.SourceStateTransmitter.access$000(SourceStateTransmitter.java:40)
at org.springframework.data.neo4j.support.mapping.SourceStateTransmitter$2.doWithAssociation(SourceStateTransmitter.java:61)
at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:252)
at org.springframework.data.neo4j.support.mapping.SourceStateTransmitter.copyPropertiesFrom(SourceStateTransmitter.java:57)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityConverterImpl.loadEntity(Neo4jEntityConverterImpl.java:100)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityConverterImpl.read(Neo4jEntityConverterImpl.java:92)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister$CachedConverter.read(Neo4jEntityPersister.java:170)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.createEntityFromState(Neo4jEntityPersister.java:189)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.projectTo(Neo4jEntityPersister.java:216)
at org.springframework.data.neo4j.support.Neo4jTemplate.projectTo(Neo4jTemplate.java:197)
at org.springframework.data.neo4j.support.conversion.EntityResultConverter.doConvert(EntityResultConverter.java:68)
at org.springframework.data.neo4j.conversion.DefaultConverter.convert(DefaultConverter.java:43)
at org.springframework.data.neo4j.support.conversion.EntityResultConverter.convert(EntityResultConverter.java:99)
at org.springframework.data.neo4j.conversion.DefaultConverter.convert(DefaultConverter.java:36)
at org.springframework.data.neo4j.rest.SpringRestGraphDatabase$SpringResultConverter.convert(SpringRestGraphDatabase.java:156)
at org.neo4j.rest.graphdb.util.QueryResultBuilder$1$1.underlyingObjectToObject(QueryResultBuilder.java:98)
at org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)
at org.neo4j.helpers.collection.IteratorUtil.singleOrNull(IteratorUtil.java:115)
at org.neo4j.helpers.collection.IteratorUtil.singleOrNull(IteratorUtil.java:260)
at org.springframework.data.neo4j.rest.SpringEndResult.singleOrNull(SpringEndResult.java:39)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:108)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:81)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:312)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy38.findByProfileId(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at com.sun.proxy.$Proxy40.findByProfileId(Unknown Source)
at com.adleritech.test.billing.data.repository.TestAffiliateRepo.test1_persistPatronToGraphDB(TestAffiliateRepo.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: java.io.StringReader#67ca3da6; line: 1, column: 2]
at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:442)
at org.codehaus.jackson.impl.ReaderBasedParser._handleUnexpectedValue(ReaderBasedParser.java:1198)
at org.codehaus.jackson.impl.ReaderBasedParser.nextToken(ReaderBasedParser.java:485)
at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2770)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2718)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:55)
... 88 more
I am using Neo4j 1.8.2 enterprise and here is a dependency tree from maven project:
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) # billing-data ---
[INFO] com.adleritech.billing:billing-data:jar:1.0-SNAPSHOT
[INFO] +- cglib:cglib:jar:2.2.2:compile
[INFO] | \- asm:asm:jar:3.3.1:compile
[INFO] +- org.springframework:spring-beans:jar:3.2.3.RELEASE:compile
[INFO] | \- org.springframework:spring-core:jar:3.2.3.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework.data:spring-data-neo4j-rest:jar:2.2.1.RELEASE:compile
[INFO] | +- org.springframework:spring-tx:jar:3.1.4.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-context:jar:3.1.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-asm:jar:3.1.4.RELEASE:compile
[INFO] | +- org.springframework:spring-aspects:jar:3.1.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-context-support:jar:3.1.4.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:3.1.4.RELEASE:compile
[INFO] | +- org.neo4j:neo4j-kernel:jar:1.8.1:compile
[INFO] | | \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] | +- org.neo4j:neo4j-rest-graphdb:jar:1.8.1:compile
[INFO] | | \- org.neo4j:server-api:jar:1.8.1:compile
[INFO] | | +- org.neo4j.3rdparty.javax.ws.rs:jsr311-api:jar:1.1.2.r612:compile
[INFO] | | +- commons-configuration:commons-configuration:jar:1.6:compile
[INFO] | | | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | | | +- commons-lang:commons-lang:jar:2.4:compile
[INFO] | | | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
[INFO] | | \- commons-digester:commons-digester:jar:1.8.1:compile
[INFO] | | \- commons-beanutils:commons-beanutils:jar:1.8.0:compile
[INFO] | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.7:compile
[INFO] | | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.7:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.7:compile
[INFO] | +- com.sun.jersey:jersey-client:jar:1.4:compile
[INFO] | | \- com.sun.jersey:jersey-core:jar:1.4:compile
[INFO] | +- org.neo4j:neo4j:jar:1.8.1:compile
[INFO] | | +- org.neo4j:neo4j-lucene-index:jar:1.8.1:compile
[INFO] | | | \- org.apache.lucene:lucene-core:jar:3.5.0:compile
[INFO] | | +- org.neo4j:neo4j-graph-algo:jar:1.8.1:compile
[INFO] | | +- org.neo4j:neo4j-udc:jar:1.8.1:compile
[INFO] | | +- org.neo4j:neo4j-graph-matching:jar:1.8.1:compile
[INFO] | | \- org.neo4j:neo4j-jmx:jar:1.8.1:compile
[INFO] | +- org.neo4j:neo4j-cypher:jar:1.8.1:compile
[INFO] | | +- org.scala-lang:scala-library:jar:2.9.1-1:compile
[INFO] | | \- com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:jar:1.3.1:compile
[INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.7.1:runtime
[INFO] +- org.springframework.data:spring-data-neo4j:jar:2.2.1.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:3.1.4.RELEASE:compile
[INFO] | +- org.aspectj:aspectjrt:jar:1.7.2:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.5.1.RELEASE:compile
[INFO] | \- org.neo4j:neo4j-cypher-dsl:jar:1.9.M04:compile
[INFO] +- org.hibernate:hibernate-validator-annotation-processor:jar:4.1.0.Final:compile
[INFO] | \- org.hibernate:hibernate-validator:jar:4.1.0.Final:compile
[INFO] | \- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] +- org.springframework:spring-test:jar:3.2.3.RELEASE:test
[INFO] +- junit:junit:jar:4.11:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:test (scope not updated to compile)
[INFO] \- org.slf4j:slf4j-jdk14:jar:1.6.1:test
Fixed in neo4j-rest-graphdb-1.9.2. There was a hardcoded "http" removed on 6/20/13
https://github.com/neo4j/java-rest-binding/commits/master/src/main/java/org/neo4j/rest/graphdb/ExecutingRestRequest.java
I have a simple Action class which I want to unit test:
package com.gam.action.test;
import org.apache.struts2.StrutsTestCase;
public class HelloWorldActionTest extends StrutsTestCase{
/**
* Test method for {#link com.gam.action.HelloWorldAction#execute()}.
*/
public void testExecute() {
fail("Not yet implemented");
}
}
I've created this test case using JUnit wizard in eclipse. I get the following error when I run the test:
Class: com.opensymphony.xwork2.spring.SpringObjectFactory
File: SpringObjectFactory.java
Method: getClassInstance
Line: 230 - com/opensymphony/xwork2/spring/SpringObjectFactory.java:230:-1
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:449)
at org.apache.struts2.util.StrutsTestCaseHelper.initDispatcher(StrutsTestCaseHelper.java:54)
at org.apache.struts2.StrutsTestCase.initDispatcher(StrutsTestCase.java:196)
at org.apache.struts2.StrutsTestCase.setUp(StrutsTestCase.java:182)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NullPointerException
at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:230)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:538)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:509)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:465)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:278)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:436)
... 17 more
The problem is I don't know which jar files should be provided. I'm not using spring in my project but if I don't provide spring jar files I get some error and when I provide it I get this one.
What combination of jar files are needed to simply run the test! (As you can see I've degraded my test method to a dummy method.)
The struts2-junit-plugin introduces its own dependencies, shown by this Maven output:
[INFO] +- org.apache.struts:struts2-junit-plugin:jar:2.3.1:compile
[INFO] | +- org.springframework:spring-test:jar:3.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO] | | +- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
[INFO] | | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | | +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
[INFO] | \- junit:junit:jar:4.8.2:compile
It sounds like you're not using Maven, which is almost certainly a Bad Idea. Managing transitive dependencies yourself is not terribly entertaining–save yourself some time and manual labor.