Error while Jersey REST service calling another Jersey REST service - java.lang.IllegalArgumentException: argument type mismatch - rest

I am getting following error while calling one Jersey REST service from another Jersey REST service.Both are deployed on diffrent tomcats.Called service is running on Jersey version 1.16 and calling service is running on 1.4
When I deploy my calling service on my local machin using Grizzly server,things works fine but when I deploy it on tomcat, I am facing this issue.
SEVERE: The provider class, class com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:198)
at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:169)
at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:166)
at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:256)
at com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:160)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initWriters(MessageBodyFactory.java:207)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:163)
at com.sun.jersey.api.client.Client.init(Client.java:326)
at com.sun.jersey.api.client.Client.access$000(Client.java:118)
at com.sun.jersey.api.client.Client$1.f(Client.java:189)
at com.sun.jersey.api.client.Client$1.f(Client.java:185)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:197)
at com.sun.jersey.api.client.Client.<init>(Client.java:185)
at com.sun.jersey.api.client.Client.<init>(Client.java:168)
at com.sun.jersey.api.client.Client.create(Client.java:638)
...
Loaded com.sun.jersey.client.urlconnection.HttpURLConnectionFactory from file:/fmrkut3/apps/UAT3/venture/lib/jersey-client-1.4.jar]
[Loaded com.sun.jersey.api.client.ClientRequest from file:/fmrkut3/apps/UAT3/venture/lib/jersey-client-1.4.jar]
Feb 17, 2014 4:15:08 AM com.sun.jersey.spi.inject.Errors processErrorMessages
SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.xml.SAXParserContextProvider(com.sun.jersey.core.util.FeaturesAndProperties) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.xml.XMLStreamReaderContextProvider(com.sun.jersey.core.util.FeaturesAndProperties) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.xml.DocumentBuilderFactoryProvider(com.sun.jersey.core.util.FeaturesAndProperties) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.xml.TransformerFactoryProvider(com.sun.jersey.core.util.FeaturesAndProperties) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$Text(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$App(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$Text(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$App(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$Text(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.DocumentProvider(com.sun.jersey.spi.inject.Injectable,com.sun.jersey.spi.inject.Injectable) at parameter index 0

As the bottom stack trace implies, you have a missing library; if I am not mistaken, it is
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.16</version>
</dependency>
This library might be present in your local configration (or bundled with Grizzly), and not with Tomcat.

Related

Getting WELD-001408 errors while doing jboss migration from 6.4EAP to 7.4EAP

Getting below errors after jboss migration from 6.4eap to 7.4eap
same EAR/WAR is working on 6.4eap but giving errors on 7.4eap.
As part of migration do we need to take care anything else to fix below issue?
Caused by: org.jboss.weld.exceptions.DeploymentException: Exception List with 2 exceptions:
Exception 0 :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Config with qualifiers #Named
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject public org.openscoring.service.NetworkSecurityContextFilter(#Named Config)
at org.openscoring.service.NetworkSecurityContextFilter.(NetworkSecurityContextFilter.java:0)
Exception 1 :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type MetricRegistry with qualifiers #Default
at injection point [UnbackedAnnotatedParameter] Parameter 2 of [UnbackedAnnotatedConstructor] #Inject private org.openscoring.service.MetricResource(ModelRegistry, MetricRegistry)
at org.openscoring.service.MetricResource.(MetricResource.java:0)
Suppressed: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Config with qualifiers #Named
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject public org.openscoring.service.NetworkSecurityContextFilter(#Named Config)

Spring Boot Geode Unsatisfied dependency expressed through method 'sessionRegion'

The correct dependencies for my gradle.build are driving me crazy!
In order to access an Apache Geode 1.10 server, I am using:
// Geode client dependency
implementation 'org.springframework.geode:spring-geode-starter:1.2.13.RELEASE'
implementation 'org.springframework.data:spring-data-geode:2.2.12.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-tomcat:2.2.13.RELEASE'
This fails with the error:
org.springframework.context.support.AbstractApplicationContext 596 refresh:
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'ClusteredSpringSessions' defined in class path resource
[org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.class]:
Unsatisfied dependency expressed through method 'sessionRegion' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.data.gemfire.config.annotation.ClientCacheConfiguration':
Initialization of bean failed; nested exception is java.lang.IllegalAccessError:
class org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$703/0x0000000801025d10
tried to access protected method 'boolean org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.hasValue(java.lang.Number)'
(org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$703/0x0000000801025d10
and org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport are in unnamed module of loader 'app')
What is there to tell me the dependency missing for the UnsatisfiedDependencyException for 'ClusteredSpringSessions'?
If I remove the #EnableGemFireHttpSession annotation then I get the error
2021-02-02T19:29:49,011 WARN [main] org.springframework.context.support.AbstractApplicationContext 596 refresh:
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'cacheManager' defined in class path resource [org/springframework/data/gemfire/cache/config/GemfireCachingConfiguration.class]:
Unsatisfied dependency expressed through method 'cacheManager' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.data.gemfire.config.annotation.ClientCacheConfiguration':
Initialization of bean failed; nested exception is java.lang.IllegalAccessError:
class org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$679/0x00000008010306b8
tried to access protected method 'boolean org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.hasValue(java.lang.Number)'
(org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$679/0x00000008010306b8
and org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport are in unnamed module of loader 'app')
What is there to tell me the dependency missing for the UnsatisfiedDependencyException for 'cacheManager'?
Thanks
UPDATE The App is run like Spring Boot #ComponentScan finds candidate component class but does not inject #Configuration beans but more specifically
#SpringBootApplication
#ComponentScan({"api", "rsocket", "pricing", "listeners", "dealing", "web"}) // scans packages for # components
#EnableLogging(logLevel="debug", logFile="geodeApi.log")
public class Api {
private static final Logger log = LogManager.getLogger(Api.class);
public static void main(String[] args) {
log.info("In Main");
SpringApplication app = new SpringApplication(Api.class);
app.setWebApplicationType(WebApplicationType.REACTIVE);
SpringApplication.run(Api.class, args);
log.info("Out Main");
}
}
The component scan finds various #Component annotated classes for example
#Component
#EnableClusterDefinedRegions(clientRegionShortcut=ClientRegionShortcut.PROXY)
public class ClientCache {
private static final Logger log = LogManager.getLogger(ClientCache.class);
#Resource
private Region<String, String> admin;
#Autowired
LQuote lQuote;
#Autowired
LReject lReject;
#Autowired
LDeal lDeal;
#Autowired
DealNumber dealNumber;
#Autowired
PriceService priceService;
#PreDestroy
public void onDestroy() throws Exception {
log.info("onDestroy");
String guid = UUID.randomUUID().toString().substring(0, 8).toUpperCase();
admin.put(guid, "API Shutdown");
// TODO: Cancel all open quote streams
log.traceExit();
}
#Bean
ApplicationRunner StartedUp(){
log.traceEntry("StartedUp");
return args -> {
String guid = UUID.randomUUID().toString().substring(0, 8).toUpperCase();
admin.put(guid, "API Started");
lQuote.addListener();
lReject.addListener();
lDeal.addListener();
// Get latest deal number
int currentId = dealNumber.readCurrentId();
// Set it + 1 in case the web server was reboot on the fly
priceService.setCurrentId(currentId + 1);
log.traceExit();
};
}
A lot of the problem was using Java JDK version 15.
The correct versions require Java 11.
// Geode client dependency
implementation 'org.springframework.geode:spring-geode-starter:1.2.8.RELEASE'
implementation 'org.springframework.data:spring-data-geode:2.2.8.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
Technically, it is not necessary to explicitly declare the SDG dependency.
The SBDG dependency (i.e. org.springframework.geode:spring-geode-starter) already includes SDG (org.springframework.data:spring-data-geode). You can follow the dependency trail starting here, then here and finally, here.
As the Version Compatibility Matrix for SBDG specifies, SBDG 1.2.13.RELEASE specifically includes, and is based on, SDG 2.2.12.RELEASE (already), which is (technically) based on Apache Geode 1.9.2.
However, if you need to use Apache Geode 1.10, then you could (recommended) simply declare dependency management to enforce the use of Apache Geode 1.10 in your Gradle build:
plugins {
id 'org.springframework.boot' version '2.2.13.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
dependencyManagement {
dependencies {
dependency 'org.apache.geode:geode-core:1.10.0'
dependency 'org.apache.geode:geode-cq:1.10.0'
dependency 'org.apache.geode:geode-lucene:1.10.0'
dependency 'org.apache.geode:geode-wan:1.10.0'
}
}
dependencies {
implementation 'org.springframework.geode:spring-geode-starter:1.2.13.RELEASE`
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
}
...
WARNING: SDG 2.2.12.RELEASE is officially based on Apache Geode 1.9.2, and though it should work reasonably well with Apache Geode 1.10, there could expectedly be limitations in certain use cases.
This is not unlike what Spring Initializer conveniently generates for you. Of course, Spring Initializer now uses the new SBDG BOM that makes managing individual SBDG module dependencies even easier, which is not unlike how Spring Boot's dependency management manages transitive dependencies, including 3rd party libs.
Regarding the Exceptions...
It really seems to me like you are having configuration problems rather than dependency problems, actually.
Of course, it is hard to say for certain given you shared very minimal Gradle build configuration and no code snippets from your Spring Boot application configuration, only mentions and what I am able to derive from the Exception messages. So, for now, I'll proceed based on what you provided and what I know or could derive.
Looking at this part of the (first) Exception message:
Error creating bean with name 'ClusteredSpringSessions' defined in class path resource
[org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.class]:
Unsatisfied dependency expressed through method 'sessionRegion' parameter 0
And, specifically:
Unsatisfied dependency expressed through method 'sessionRegion' parameter 0
This message refers to the (Spring Java) configuration provided by SSDG and imported/auto-configured by SBDG.
The "Unsatisfied dependency", or "parameter 0", is the 1st method parameter in the sessionRegion(..) (Spring JavaConfig-based) #Bean definition method declared in SSDG's configuration. It is the dependency on the GemFire cache instance (e.g. ClientCache) required to create the "ClusteredSpringSessions" Region.
So now, the question becomes, how is the cache created?
Well, this is what the framework is trying to do next... resolve the cache bean dependency (instance reference), which necessary triggers the cache creation first (due to dependency order)...
Error creating bean with name 'org.springframework.data.gemfire.config.annotation.ClientCacheConfiguration':
Initialization of bean failed; nested exception is java.lang.IllegalAccessError
We see that an IllegalAccessError occurred (O.o) which already smells like a version problem to me, but...
The ClientCacheConfiguration is provided by SDG.
Finally, we arrive at the underlying cause...
class org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$703/0x0000000801025d10
tried to access protected method 'boolean org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.hasValue(java.lang.Number)'
NOTE: ClientCacheConfiguration extends AbstractCacheConfiguration, which extends AbstractAnnotationConfigSupport, and therefore should have "access" to the protected hasValue(:Number) method.
The main Thread appears to be in one of these Lambdas where the AbstractAnnotationConfig.hasValue(:Number) method is used.
I am no entirely sure what this means...
org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$703/0x0000000801025d10
and org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport are in unnamed module of loader 'app'
Are you possibly using Spring Boot's new (Layered) Docker Image support by chance?
The 2nd Exception message (involving the cacheManager bean this time) leads to the same outcome, actually. It is no different, but simply involves another bean (i.e. cacheManager bean) with the same dependency on the cache instance:
Error creating bean with name 'cacheManager' defined in class path resource
[org/springframework/data/gemfire/cache/config/GemfireCachingConfiguration.class]
: Unsatisfied dependency expressed through method 'cacheManager' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.data.gemfire.config.annotation.ClientCacheConfiguration':
Initialization of bean failed; nested exception is java.lang.IllegalAccessError:
class org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$679/0x00000008010306b8
tried to access protected method 'boolean org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.hasValue(java.lang.Number)'
(org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$679/0x00000008010306b8
and org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport are in unnamed module of loader 'app')
And, specifically:
Initialization of bean failed; nested exception is java.lang.IllegalAccessError:
tried to access protected method 'boolean org.springframework.data.gemfire
.config.annotation.support.AbstractAnnotationConfigSupport
.hasValue(java.lang.Number)'
And:
(org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$679/0x00000008010306b8
and org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport
are in unnamed module of loader 'app')
I am not familiar with this error messages (basically, said class(es) "are in unnamed module of loader 'app'.") What?
How is this Spring Boot app being run?
Definitely providing a sample app, one or more tests, your configuration, logs, Stack Traces in addition to Exception messages, setup, runtime environment, etc, etc, will go along way in trying to understand the context of this problem.
At this point, I am really trying to point you in a direction to start untangling the problem.
Sorry, I cannot (currently) be of more help in this case.

Run webapp generated with JHipster : Mapper could not be found

When I run my webapp with Eclipse IDE (Right click + run as Java application)
I have the following error :
2018-08-14 15:58:17.381 WARN 7324 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'actionServiceImpl' defined in file [D:\dfsdfdsfdsfsfsfsf\target\classes\com\showyou\service\impl\ActionServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.showyou.service.mapper.ActionMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Does anybody has an idea ? I followed all the required steps : https://www.jhipster.tech/configuring-ide-eclipse/

Grails, Spring Security and Mongo

I try to configure Grails 3.1.4 rest-api aplication. I'd like to use Mongo and Spring Security for authentication, but when I erase from application.yml h2 datasource and hibernate and try to run application I get a lot of exceptions like:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistenceInterceptor':
Cannot create inner bean '(inner bean)#1b3bb287' of type [org.grails.orm.hibernate4.support.AggregatePersistenceContextInterceptor]
while setting constructor argument with key [0]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1b3bb287':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method:
public void org.grails.orm.hibernate4.support.AggregatePersistenceContextInterceptor.setHibernateDatastores(org.grails.orm.hibernate.AbstractHibernateDatastore[]); nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.grails.orm.hibernate.AbstractHibernateDatastore]
found for dependency [array of org.grails.orm.hibernate.AbstractHibernateDatastore]:
expected at least 1 bean which qualifies as autowire candidate for this dependency.
I can confirm this behavior with Grails 3.1.7 if you just comment out the default H2 and cache part in application.yml. However, it disappears for me, if I comment out the following:
// compile "org.grails.plugins:hibernate4"
For reference, I'm using the following plugin versions for mongoDB and spring-security-core:
compile 'org.grails.plugins:mongodb:5.0.6'
compile "org.mongodb:mongodb-driver:3.0.2"
runtime 'org.springframework.data:spring-data-mongodb:1.8.1.RELEASE'
compile 'org.grails.plugins:spring-security-core:3.1.1'
Cheers!

Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' [duplicate]

This question already has answers here:
javax.persistence.PersistenceException : [PersistenceUnit: vodPersistenceUnit] class or package not found
(4 answers)
Closed 5 years ago.
Error creating bean with name
'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in URL [file:/E:/source-files-healthentic/securityadmin/build/test/classes/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:/E:/source-files-healthentic/securityadmin/build/test/classes/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in URL [file:/E:/source-files-healthentic/securityadmin/build/test/classes/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:/E:/source-files-healthentic/securityadmin/build/test/classes/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:411)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:382)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:271)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:268)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:597)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:366)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
at org.apache.struts2.StrutsSpringTestCase.setupBeforeInitDispatcher(StrutsSpringTestCase.java:39)
at org.apache.struts2.StrutsTestCase.setUp(StrutsTestCase.java:208)
at healthentic.admin.action.StrutsSpringBase2Setup.setUp(StrutsSpringBase2Setup.java:128)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:/E:/source-files-healthentic/securityadmin/build/test/classes/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1330)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:411)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:382)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:271)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:268)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:174)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:309)
at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:266)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:122)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:78)
at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:97)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1318)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:475)
Caused by: java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver.addTransformer(InstrumentationLoadTimeWeaver.java:88)
at org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.addTransformer(SpringPersistenceUnitInfo.java:80)
at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:225)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:224)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1361)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1327)
I'm getting this error when running my application(using Struts2 spring3 integrated and jpa eclipse link ) junit test.... how can i resolve this problem................ kindly check ans suggest me....
To help others with this issue,
I have he same problem after including some of the APIS thst uses later Spring (3.x.) versions to the existing project.
My application was started up successfully in one machine but failed on another machine. After investigating carefully we found this,
On the machine it was failing, the PersistenceExceptionTranslationPostProcessor was loaded from spring-dao-2.0.8.jar
[Loaded org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor from file:/lib/spring-dao-2.0.8.jar]
Where as on the other machine it was loaded from spring-tx-3.1.1.RELEASE.jar
[Loaded org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor from file:/lib/spring-tx-3.1.1.RELEASE.jar]
Then I tried removing the spring-dao-2.0.8.jar from the class-path and tried, it worked.
spring-dao-2.0.8.jar was an unnecessary dependency.
Regards
Lyju
The error states,
"Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation."
so, you either need to use the Spring Java agent to start your JVM, or need to disable the InstrumentationLoadTimeWeaver.
See,
How to configure EclipseLink 2.0 and Spring 3.0.5 and Tomcat 6?
For JPA weaving with EclipseLink, you can also use the static weaver, then no agent or instrumentation is required.