|
|
Problem forth porting examples from RC2 to 2.0
I have an implementation of the examples presented at:
1. mark...-in-spring-20/
2. 2006_08_01_archive.html (refer post of 13th August, 2006 [Extend Your Type Transparently using Spring Introductions])
3. 2006_07_01_archive.html (refer post of 16th July, 2006
[DAOs on Steroids - Fun Unlimited with Generic DAOs in Spring 2.0])
To sum up, my application has an architecture as:
(refer blog ucl 3 above)
* DAOBase - the base class for all the DAOs at the application level
* DAOImplBase - the underlying implementation
* DAOJPAImpl - Spring JPA implementation of DAOImplBase along with, call
back class (implementing org..orm.jpa.JpaCallback) implementation for executing native sql queries.
* DAOs, domain objects, applicationContext, and persistence.xml as in blog ucl 1 (with some minimal changes) with the following change for entity manager factory(LocalContainerEntityManagerFactoryBean):
Code: lt;bean id=quot;entityManagerFactoryquot; class=quot;org..orm.jpa.LocalContainerEntityManagerFactoryBeanquot;gt; ... ... lt;/beangt;
I was using spring-2.0-rc2, the aspect DAOExtension(as in the blog ucl 2) was weaved with the DAOs at the load time. Later on, the weaving process was changed to compile time(using aspectj maven plugin).
The test cases work fine with 2.0-rc2 but they fail for 2.0.
Following is the exception trace that I get when I use spring-2.0:Code:
Tests run: 22, Failures: 11, Errors: 0, Skipped: 0, Time elapsed: 3.188 sec lt;lt;lt; FAILURE!
testUpdate Time elapsed: 0.016 sec lt;lt;lt; FAILURE!
Local Exception Stack:
Exception [TOPLINK-6007] (Oracle TopLink Essentials - 2006.6 (Build 060608)): oracle.toplink.essentials.exceptions.QueryException
Exception Description: Missing descriptor for [class com.a.b.dao.provider.spring.jpa.domain.Entree].
Query: ReadAllQuery(com.a.b.dao.provider.spring.jpa.domain.Entree)
at oracle.toplink.essentials.exceptions.QueryException.descriptorIsMissing(QueryException.java:403)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.checkDescriptor(ObjectLevelReadQuery.java:397)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.checkPrePrepare(ObjectLevelReadQuery.java:479)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.checkEarlyReturn(ObjectLevelReadQuery.java:418)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:556)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:677)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:731)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2218)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:343)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:438)
at com.a.b.dao.provider.spring.jpa.DAOJPAImpl$PiJpaSqlCallback.doInJpa(DAOJPAImpl.java:381)
at org..orm.jpa.JpaTemplate.execute(JpaTemplate.java:183)
at org..orm.jpa.JpaTemplate.executeFind(JpaTemplate.java:150)
at com.a.b.dao.provider.spring.jpa.DAOJPAImpl.read(DAOJPAImpl.java:116)
at com.a.b.dao.DAOBase.read(DAOBase.java:181)
at com.a.b.dao.provider.spring.jpa.EntreeDaoTests.testUpdate(EntreeDaoTests.java:259)
The snippet from the aforesaid test method is as, where the test case fails:
Code: Listlt;Entreegt; res = entreeDao.read(factory, new SimpleCriteria(quot;name = 'Hamburger'quot;), Entree.class);
Apart from this no exception is thrown and this remains same for all the failed test cases.
Other than changing the spring version from 2.0-rc2 to 2.0, no other change was done in the application.
Any help would be appreciated.
Thanks,
Jayant
What type of LTW are you using? Try using the instrumentation LTW along with Toplink's java agent.
Hi Costin,
As per your suggestion, I changed the LTW to Instrumentation, and it worked fine if the test cases were run from eclipse using the -javaagent argument. Actually I have to weave my aspects at the load time and hence I am using the following command:Code:
-javaagent:aspectjweaver-1.5.2a.jar
In this case the test cases were executed without any failure, but when I tried using it with maven by configuring the jar in the pom as:
Code:lt;plugingt; lt;groupIdgt;org.apache.maven.pluginslt;/groupIdgt; lt;artifactIdgt;maven-surefire-pluginlt;/artifactIdgt; lt;configurationgt; lt;forkModegt;pertestlt;/forkModegt;
lt;argLinegt;-javaagent {user.home.location}\.m2\repository\aspectj\aspectjweaver\1.5.2a\aspectjweaver-1.5.2a.jarlt;/argLinegt; lt;/configurationgt;lt;/plugingt;
I got the following exception:
Code:
-------------------------------------------------------------------------------
Test set: test-methods
-------------------------------------------------------------------------------
Tests run: 66, Failures: 1, Errors: 0, Skipped: 65, Time elapsed: 6.5 sec lt;lt;lt; FAILURE!
setUp Time elapsed: 1,163,396,385.156 sec lt;lt;lt; FAILURE!
org..beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [application_context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
Caused by: java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org..instrument.classloading.InstrumentationLoadTimeWeaver.addTransformer(InstrumentationLoadTimeWeaver.java:51)
at org..orm.jpa.persistenceunit.SpringPersistenceUnitInfo.addTransformer(SpringPersistenceUnitInfo.java:69)
at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:155)
at org..orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:199)
at org..orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:237)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)
at org..beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
at org..beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
at org..beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
at org..context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
at org..context.support.ClassPathXmlApplicationContext.lt;initgt;(ClassPathXmlApplicationContext.java:92)
at org..context.support.ClassPathXmlApplicationContext.lt;initgt;(ClassPathXmlApplicationContext.java:77)
at org..test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:138)
at org..test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:125)
at org..test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:104)
at org..test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:318)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:152)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:361)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:778)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
at org.testng.TestRunner.privateRun(TestRunner.java:682)
at org.testng.TestRunner.run(TestRunner.java:566)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:220)
at org.testng.SuiteRunner.run(SuiteRunner.java:146)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:713)
at org.testng.TestNG.runSuitesLocally(TestNG.java:676)
at org.apache.maven.surefire.testng.TestNGExecutor.executeTestNG(TestNGExecutor.java:64)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:101)
at org.apache.maven.surefire.Surefire.run(Surefire.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:182)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:743)
I would like to mention it again that the very same configuration in maven was working when I was using 2.0-RC2 jars and the LTW weaving was achieved using SimpleLoadTimeWeaver. I don't know whether this is a sort of problem with maven since in my post here, I am experiencing problems in case of project built with maven, but in this case I could notice the entities being defaulted to the respective table names.
Please have a look at this and help me out with this.
Thanks,
Jayant
Hi,
Well after lots of scannig through the forum itself, I finally got my things to work. I would like to summarize the things. My intent was to use an Aspect which was used at Load Time, I wished to change it to Compile Time. Everything worked fine with the configurations changed in 2.0-RC2 but as I migrated to 2.0, there were problems. Initially it was thought as the problem with Maven 2.x integration, but this was not the case.
As in this post, Costin's suggestion of changing the toplink property for weaving, worked. I changed the toplink.weaving property to false and also removed the property quot;loadTimeWeaverquot; from my application context configuration.
I think prior of posting this, I should have minutely observed the contents in the post!
But then I tried implementing this here, but nothing changed in that case. I hope to find out the solution for this very soon.
Thanks,
Jayant |
|