NewInstanceCreationException: Could not create a new instance of class [SpringSecurityCoreGrailsPlugin]! - spring

I have a grails application running which works fine locally in intelliJ but gets this stacktrace when the .war file is deployed to the production server
stacktrace
'2014-06-30 09:26:31,641 [localhost-startStop-6] ERROR context.ContextLoader - Context initialization failed
'org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [SpringSecurityCoreGrailsPlugin]!
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [SpringSecurityCoreGrailsPlugin]!
... 5 more
Caused by: java.lang.OutOfMemoryError: Java heap space
'2014-06-30 09:26:31,643 [localhost-startStop-6] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [SpringSecurityCoreGrailsPlugin]!
'org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [SpringSecurityCoreGrailsPlugin]!
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [SpringSecurityCoreGrailsPlugin]!
... 5 more
Caused by: java.lang.OutOfMemoryError: Java heap space
'2014-06-30 09:26:31,644 [localhost-startStop-6] ERROR context.GrailsContextLoader - Error initializing Grails: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [SpringSecurityCoreGrailsPlugin]!
'org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [SpringSecurityCoreGrailsPlugin]!
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of c...
build config
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenLocal()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// Allows connecting to MySQL DBs
runtime 'mysql:mysql-connector-java:5.1.22'
// For JodaTime plugin
compile "org.jadira.usertype:usertype.jodatime:1.9.1"
// So that spock can work with Grails 2.2
test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
// Fix for a missing class
compile "net.bull.javamelody:javamelody-core:1.43.0"
}
plugins {
// Server
build ":tomcat:$grailsVersion"
// Testing
test(":spock:0.7") {
exclude "spock-grails-support"
}
compile ":grails-melody:1.14"
compile ":runtime-logging:0.4"
compile ":console:1.2"
// Security
compile ":spring-security-core:1.2.7.3"
compile ":spring-security-ldap:1.0.6"
// Other
compile ':cache:1.0.1'
compile ":cache-headers:1.1.5"
compile ":joda-time:1.4"
compile ":mail:1.0.1"
// DB
runtime ":hibernate:$grailsVersion"
runtime ":database-migration:1.3.2"
// UI
runtime ":jquery:1.10.2"
compile ":jquery-ui:1.8.24"
runtime ":modernizr:2.6.2"
compile ":fields:1.3"
compile ":twitter-bootstrap:2.3.2"
compile ":font-awesome-resources:3.2.1.1"
runtime ":modernizr:2.6.2"
// Resources Plugin
runtime ":resources:1.1.6"
runtime ":zipped-resources:1.0"
runtime ":cached-resources:1.0"
}
}
I think it is a dependency issue based on other searches but not sure how to know for sure. Would appreciate any help.

Acutally, it looks like this is the real issue is:
Caused by: java.lang.OutOfMemoryError: Java heap space –

Related

org.springframework.aot.context.bootstrap.generator.BeanDefinitionGenerationException: Failed to handle bean with name 'xxx' and type 'xxx'

I want to try SpringNative. I have a custom Bean, but when I run "spring-aot:generate" or "spring-boot:build-image", I get the following exception. I don't know how to configure and add Hint Key exception information is as follows
org.springframework.aot.context.bootstrap.generator.BeanDefinitionGenerationException: Failed to handle bean with name 'devInfoHeaderFilter' and type 'tablo.jhin.application.filters.DevInfoHeaderFilter' at org.springframework.aot.context.bootstrap.generator.ApplicationContextAotProcessor.writeBeanDefinitions
...
Caused by: java.lang.IllegalStateException: Multiple privileged packages: [tablo.jhin.config, tablo.jhin.application.filters]at org.springframework.aot.context.bootstrap.generator.infrastructure.ProtectedAccessAnalysis.getPrivilegedPackageName
...
[ERROR]
org.apache.maven.plugin.MojoExecutionException: Could not exec java
at org.springframework.aot.maven.AbstractBootstrapMojo.forkJvm (AbstractBootstrapMojo.java:197)
...
Caused by: org.apache.maven.plugin.MojoExecutionException: Bootstrap code generator finished with exit code: 1
at org.springframework.aot.maven.AbstractBootstrapMojo.forkJvm (AbstractBootstrapMojo.java:190)
at org.springframework.aot.maven.GenerateMojo.execute (GenerateMojo.java:132)
....
In a internal class under the 'tablo.jhin.config', I configured such a Bean: ServiceTraceFilterConfiguration as an internal class
#ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
static class ServletTraceFilterConfiguration implements NativeConfiguration {
#Bean
public DevInfoHeaderFilter devInfoHeaderFilter() {
return new DevInfoHeaderFilter();
}
}

Spring boot application gives "unable to start tomcat" exception with spring-boot-starter-actuator

I had my spring-boot application, with spring-boot-starter-web, then I added spring-boot-starter-actuator to gradle file. There is no compilation error. But when i try to run the server it gives the following exception.
my build.gradle content (only the main ones included )
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
} ...........
compile "org.springframework.boot:spring-boot-starter-actuator"
compile group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.1.3' .........
my application.properties content
server.port = 2128
spring.couchbase.env.timeouts.connect=10000
spring.couchbase.env.timeouts.query=180000
spring.couchbase.env.timeouts.view=20000
spring.couchbase.bootstrap-hosts=localhost
spring.couchbase.bucket.name=localdb
spring.couchbase.bucket.password=*****
spring.data.couchbase.repositories.type=auto
spring.data.couchbase.auto-index=true
server.compression.enabled=true
server.compression.mime-types=application/json,text/plain
spring.servlet.multipart.enabled=true
spring.servlet.multipart.maxFileSize=50MB
spring.servlet.multipart.maxRequestSize=50MB
my Application.java
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Gives the following exception while starting the server.
org.springframework.context.ApplicationContextException: Unable to start web server;
nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource
WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource
org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 1;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed
Any helpful hints?
I was finally able to start the application after I turned off default health checks via the following entry in application.properties file
management.health.defaults.enabled=false

spring boot: can't initialize a postgresql datasource

I have the following bean configured.
#Bean
#Primary
#ConfigurationProperties(prefix="datasource.etlTarget")
public DataSource datasourceTest() {
System.out.println("************");
System.out.println("************");
return DataSourceBuilder.create().build();
}
Then error log is:
************
************
2014-12-14 21:12:35.718 WARN 21758 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Collection org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration.dataSources; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'datasourceTest' defined in class path resource [com/testcom/etc/ETLJobRepository.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'datasourceTest' threw exception; nested exception is java.lang.IllegalStateException: No supported DataSource type found
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
Key error message is
nested exception is java.lang.IllegalStateException: No supported DataSource type found
The gradle setting is
dependencies {
compile "org.springframework.boot:spring-boot-starter-batch:1.2.0.RELEASE"
compile "org.springframework:spring-jdbc:4.1.3.RELEASE"
compile 'org.postgresql:postgresql:9.3-1102-jdbc41'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
I tried hard to figure it out why it error out, but don't find out the root cause
The property is
datasource.etlTarget.url=jdbc:postgresql://localhost/example
datasource.etlTarget.driverClassNname=org.postgresql.Driver
datasource.etlTarget.username=postgres
datasource.etlTarget.password=test
You made a typo in your configuration:
datasource.etlTarget.driverClassNname=org.postgresql.Driver
Should be:
datasource.etlTarget.driverClassName=org.postgresql.Driver
(i.e. driverClassName instead of driverClassNname)

spring data neo4j version issue

I am trying to use spring-data-neo4j in my grails project but there are so many version conflicting.
I am using following dependency
compile org.springframework.data:spring-data-neo4j-rest:3.1.2.RELEASE
then if i run my neo4j server 2.1.2 then it is giving me error
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jMappingContext' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Invocation of init method failed; nested exception is java.lang.NullPointerException
... 4 more
Caused by: java.lang.NullPointerException
... 4 more
and if i run 1.8.3 neo4j server then it seems that it connects to server but again getting error
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'typeRepresentationStrategyFactory' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory org.springframework.data.neo4j.config.Neo4jConfiguration.typeRepresentationStrategyFactory() throws java.lang.Exception] threw exception; nested exception is org.neo4j.rest.graphdb.RestResultException: expected START or CREATE
"MATCH (ref:ReferenceNode {name:{name}}) RETURN ref"
^ at
SyntaxException
please let me know what i am missing or if someone could tell me exact versions which i should use.
Buildconfig.config :
//grails.plugin.location."neo4j" = "../grails-data-mapping/grails-plugins/neo4j"
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
grails.server.port.http = 7575
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the test-app JVM, uses the daemon by default
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the run-app JVM
// TODO: workaround, for Neo4j plugin forked mode is currently not working. Reason: Neo4jSpringConfigurer is using
// "as Classs" which causes ClassLoader issues
run: false, //[maxMemory: 768, minMemory: 64, debug: true, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
excludes 'xml-apis', 'netty', 'stax-api', 'slf4j-jdk14','log4j-over-slf4j', 'logback-classic'
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
//flatDir name:'myRepo', dirs:'/abc/def'
mavenRepo 'http://m2.neo4j.org/content/repositories/releases/'
}
neo4jVerison="1.9.8"
dependencies {
//compile("org.neo4j:neo4j-community:2.0.0-M06")
//compile(group: 'org.neo4j', name: 'neo4j', version: "$neo4jVersion")
//compile(group: 'org.neo4j.app', name: 'neo4j-server', version: "$neo4jVersion", classifier: 'static-web')
// this is required if DataSource.groovy uses url = "jdbc:neo4j:mem"
//runtime(group:"org.neo4j", name:"neo4j-kernel", version:neo4jVerison)
// next four lines are required if you're using embedded/ha *and* you want the webadmin available
//compile(group:"org.neo4j.app", name:"neo4j-server", version:neo4jVerison)
// grails dependencies do not properly support maven classifiers, therefor we'll copy that
// dependency to lib directory
//runtime(group:"org.neo4j.app", name:"neo4j-server", version:neo4jVerison, classifier:"static-web")
//runtime('com.sun.jersey:jersey-server:1.9')
//runtime('com.sun.jersey:jersey-core:1.9')
// add graphviz capabilities
//compile(group:"org.neo4j", name:"neo4j-graphviz", version: neo4jVerison)
//runtime (group:"org.neo4j", name:"neo4j-shell", version: neo4jVerison)
// uncomment following line if type=rest is used in DataSource.groovy
//compile 'org.neo4j:neo4j-rest-graphdb:2.0.0-M06'
/*compile 'org.springframework:spring-core:3.1.0.RELEASE'
compile 'org.springframework:spring-context:3.0.0.RELEASE'
compile 'org.springframework:spring-beans:3.0.2.RELEASE'
compile 'org.springframework.data:spring-data-neo4j:1.1.0.RELEASE'*/
compile 'javax.validation:validation-api:1.0.0.GA'
//compile 'org.neo4j:neo4j:2.0.3'
compile 'org.springframework.data:spring-data-neo4j-rest:3.1.2.RELEASE'
//compile 'org.springframework.data:spring-data-neo4j:3.1.2.RELEASE'
test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
}
plugins {
//compile ":neo4j:2.0.0-M02"
compile ":scaffolding:2.0.1"
runtime ":jquery:1.10.2.2"
runtime ":resources:1.2.1"
test(":spock:0.7") {
exclude "spock-grails-support"
}
// compile ":geb:0.9.0-RC-1"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:7.0.50"
// compile ':cloud-support:1.0.8'
// compile ':webxml:1.4.1'
}
}
and resources.xml for spring set up
<?xml version="1.0"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.2.xsd">
<!-- REST Connection to Neo4j server -->
<bean id="graphDatabaseService"
class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
<constructor-arg value="http://localhost:7474/db/data" />
</bean>
<!-- Neo4j configuration (template) -->
<neo4j:config graphDatabaseService="graphDatabaseService" />
<!-- Package w/ automagic repositories -->
<neo4j:repositories base-package="sample" />
</beans>
i am developing in grails and using neo4j 2.1.2 version which is running on localhost:7474 and i am using rest service for data base connection
so for neo4j 2.1.2 i am getting following exception.
14 [localhost-startStop-1] ERROR org.codehaus.groovy.grails.web.context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'communityCentreRepository': Cannot resolve reference to bean 'neo4jTemplate' while setting bean property 'neo4jTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jTemplate' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.Neo4jTemplate org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTemplate() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jMappingContext' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Invocation of init method failed; nested exception is java.lang.NullPointerException
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'communityCentreRepository': Cannot resolve reference to bean 'neo4jTemplate' while setting bean property 'neo4jTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jTemplate' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.Neo4jTemplate org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTemplate() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jMappingContext' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Invocation of init method failed; nested exception is java.lang.NullPointerException
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jTemplate' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.Neo4jTemplate org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTemplate() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jMappingContext' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Invocation of init method failed; nested exception is java.lang.NullPointerException
... 4 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.Neo4jTemplate org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTemplate() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jMappingContext' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Invocation of init method failed; nested exception is java.lang.NullPointerException
... 4 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jMappingContext' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Invocation of init method failed; nested exception is java.lang.NullPointerException
... 4 more
Caused by: java.lang.NullPointerException
... 4 more

The XMLInputFactory does not recognize the property "reuse-instance" : Spring MVC, JUnit, RAD & Web sphere server

I have a Spring MVC project(contains Controller & jsp files) and DAO project(Contains DB operation related files) & both the project are configured using annotations. MVC project depends on DAO project. Now, I am writing JUnit test for MVC and DAO projects. Hence I have created a separate 'Test project' in which I have added MVC project as dependency(Java Build Path -> Projects tab -> Add -> MVC Project & ok) and included all needed jar files (JUnit & spring-test.jar). I am using RAD IDE, Spring 3, JUnit4 & Websphere application server (version 7).
My project structure:
MVCProject (Depends on DAOProject --> Web App project)
|
WebContent
|
WEB-INF
|
spring-context.xml
DAOProject (Java project)
|
src
TestProject(Depends on MVCProject --> Java project)
|
src
|
com.xyz.dao.test
|
DAOImplTest.java
|
config
|
test-spring-context.xml
I copied contents of spring-context.xml file into test-spring-context.xml.
Below is my JUnit test project code,
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(locations = {"classpath:config/test-spring-context.xml"})
public class DAOImplTest {
#Autowired
private DAO dao;
String id = null;
/**
* Test method for {#link com.xyz.core.dao.DAOImpl#getById(java.lang.String)}.
*/
#Test
public void testGetById() {
id = "Test12345";
try {
dao.getById(id);
} catch (Exception e) {
e.printStackTrace();
}
}
}
I am getting following error when try to run test case (The XMLInputFactory does not recognize the property "reuse-instance").
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'imageHandler' defined in file [D:\Workspace\MVCProjectName\WebContent\WEB-INF\classes\com\xyz\web\webservice\ImageHandlerImpl.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.xyz.webservice.ImageHandlerImpl]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: The XMLInputFactory does not recognize the property "reuse-instance".
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:435)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:409)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:541)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:147)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:297)
... 64 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.xyz.webservice.ImageHandlerImpl]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: The XMLInputFactory does not recognize the property "reuse-instance".
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
... 77 more
Caused by: java.lang.IllegalArgumentException: The XMLInputFactory does not recognize the property "reuse-instance".
at com.ibm.xml.xlxp.api.stax.msg.StAXMessageProvider.throwIllegalArgumentException(StAXMessageProvider.java:42)
at com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl.setProperty(XMLInputFactoryImpl.java:1870)
at org.apache.axiom.util.stax.dialect.SJSXPDialect.makeThreadSafe(SJSXPDialect.java:65)
at org.apache.axiom.om.util.StAXUtils$8.run(StAXUtils.java:544)
at java.security.AccessController.doPrivileged(AccessController.java:229)
at org.apache.axiom.om.util.StAXUtils.newXMLInputFactory(StAXUtils.java:517)
at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory_perClassLoader(StAXUtils.java:588)
at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory(StAXUtils.java:171)
at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory(StAXUtils.java:136)
at org.apache.axiom.om.util.StAXUtils.createXMLStreamReader(StAXUtils.java:223)
at org.apache.axiom.om.util.StAXUtils.createXMLStreamReader(StAXUtils.java:217)
at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:555)
at org.apache.axis2.deployment.DescriptionBuilder.buildOM(DescriptionBuilder.java:93)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:76)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:640)
at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:105)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:60)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:174)
at org.apache.axis2.jaxws.ClientConfigurationFactory.getClientConfigurationContext(ClientConfigurationFactory.java:51)
at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.createServiceDescription(DescriptionFactoryImpl.java:74)
at org.apache.axis2.jaxws.description.DescriptionFactory.createServiceDescription(DescriptionFactory.java:67)
at org.apache.axis2.jaxws.spi.ServiceDelegate.<init>(ServiceDelegate.java:84)
at org.apache.axis2.jaxws.spi.Provider.createServiceDelegate(Provider.java:45)
at javax.xml.ws.Service.<init>(Service.java:57)
at com.xyz.handler.broker.ImageHandlerService.<init>(ImageHandlerService.java:39)
at com.xyz.handler.broker.ImageHandlerProxy$Descriptor.<init>(ImageHandlerProxy.java:21)
at com.xyz.handler.broker.ImageHandlerProxy.<init>(ImageHandlerProxy.java:69)
at com.xyz.webservice.ImageHandlerImpl.<init>(ImageHandlerImpl.java:30)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
... 79 more
Kindly help me resolving this issue.
Thanks in Advance.
Folks,
I am able to resolve the issue.
This problem occurs when my RAD JRE System library set to jdk7 and so it is resolved by setting RAD 'JRE System library' to 'JavaSE-1.6' (Properties --> Libraries tab --> JRE System library --> Click edit & set JavaSE-1.6).
The reason might be jar conflict between sun jdk7, IBM(xml.jar) and apache axiom versions (Not sure but as far as I googled ended up with this assumption).
Hope it helps someone facing similar issue.
Happy learning.
This is an issue in Axiom that has been fixed in 1.2.15. See AXIOM-443 for more details.

Resources