Results 1 to 4 of 4

Thread: Problem running AbstractJpaTests using spring-framework-2.1-m1+Maven2+JPA+Hibernate

  1. #1
    Join Date
    Sep 2004
    Posts
    2

    Default Problem running AbstractJpaTests using spring-framework-2.1-m1+Maven2+JPA+Hibernate

    Dear All,

    Same application described below runs very fine on ant build scripts taken from petclinic sample from spring-framework-2.1-m1 release.

    I am having problems running a very basic JUnit test case via Maven2. The application uses spring-framework-2.1-m1 release, and test case extends from org.springframework.test.jpa.AbstractJpaTests, uses org.springframework.orm.jpa.LocalContainerEntityMa nagerFactoryBean as entityManagerFactory, and uses
    org.springframework.orm.jpa.vendor.HibernateJpaVen dorAdapter as jpaVendorAdapter propery for entityManagerFactory.

    All the details are below including the exception stack trace, spring bean defination files, lib depenencies from pom.xml. persistence.xml, orm.xml etc are below and a complete project is attached with as zip file.

    I removed the Annotations based persistence, thought problem would have to be related to this, but no use.

    ====================================
    Exception stack trace
    ====================================
    testCreate(com.hc.tests.PersonServiceTest) Time elapsed: 0.734 sec <<< ERROR!
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/applicationContext-jpaCommon.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javassist.bytecode.ClassFile.getName()Ljava/lang/String;
    Caused by: java.lang.NoSuchMethodError: javassist.bytecode.ClassFile.getName()Ljava/lang/String;
    at org.hibernate.ejb.Ejb3Configuration.scanForClasses (Ejb3Configuration.java:652)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3 Configuration.java:350)
    at org.hibernate.ejb.HibernatePersistence.createConta inerEntityManagerFactory(HibernatePersistence.java :126)
    at org.springframework.orm.jpa.LocalContainerEntityMa nagerFactoryBean.createNativeEntityManagerFactory( LocalContainerEntityManagerFactoryBean.java:218)
    at org.springframework.orm.jpa.AbstractEntityManagerF actoryBean.afterPropertiesSet(AbstractEntityManage rFactoryBean.java:251)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1201)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1171)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:425)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 51)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:156)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:248)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeansOfType(DefaultListableB eanFactory.java:247)
    at org.springframework.beans.factory.BeanFactoryUtils .beansOfTypeIncludingAncestors(BeanFactoryUtils.ja va:257)
    at org.springframework.dao.support.PersistenceExcepti onTranslationInterceptor.detectPersistenceExceptio nTranslators(PersistenceExceptionTranslationInterc eptor.java:121)
    at org.springframework.dao.support.PersistenceExcepti onTranslationInterceptor.<init>(PersistenceExcepti onTranslationInterceptor.java:77)
    at org.springframework.dao.annotation.PersistenceExce ptionTranslationAdvisor.<init>(PersistenceExceptio nTranslationAdvisor.java:70)
    at org.springframework.dao.annotation.PersistenceExce ptionTranslationPostProcessor.setBeanFactory(Persi stenceExceptionTranslationPostProcessor.java:96)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1162)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:425)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 51)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:156)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:248)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
    at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:733)
    at org.springframework.context.support.AbstractApplic ationContext.registerBeanPostProcessors(AbstractAp plicationContext.java:496)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:337)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.test.jpa.AbstractJpaTests.runB are(AbstractJpaTests.java:229)
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.junit.JUnitTestSet.execu te(JUnitTestSet.java:213)
    at org.apache.maven.surefire.suite.AbstractDirectoryT estSuite.executeTestSet(AbstractDirectoryTestSuite .java:138)
    at org.apache.maven.surefire.suite.AbstractDirectoryT estSuite.execute(AbstractDirectoryTestSuite.java:1 25)
    at org.apache.maven.surefire.Surefire.run(Surefire.ja va:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.booter.SurefireBooter.ru nSuitesInProcess(SurefireBooter.java:290)
    at org.apache.maven.surefire.booter.SurefireBooter.ma in(SurefireBooter.java:818)
    at org.apache.maven.surefire.booter.SurefireBooter.ma in(SurefireBooter.java:818)
    =========================================
    applicationContext-hibernateAdapter.xml
    ===============================
    <beans>
    <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
    <property name="database" value="HSQL"/>
    <property name="showSql" value="true"/>
    <property name="generateDdl" value="true" />
    </bean>
    </beans>
    ==========================
    applicationContext-jpaCommon.xml
    ==========================
    <beans>
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
    <property name="url" value="jdbc:hsqldb:hsql://localhost:9001"/>
    <property name="username" value="sa"/>
    <property name="password" value=""/>
    </bean>
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="loadTimeWeaver">
    <bean class="org.springframework.instrument.classloading .InstrumentationLoadTimeWeaver"/>
    </property>
    <!-- Specific "jpaAdapter" bean sits in adapter context file -->
    <property name="jpaVendorAdapter" ref="jpaAdapter"/>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionM anager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>
    </beans>
    ============================
    applicationContext-entityManager.xml
    ============================
    <aop:aspectj-autoproxy/>
    <tx:annotation-driven/>
    <bean class="org.springframework.dao.annotation.Persiste nceExceptionTranslationPostProcessor"/>
    <bean class="org.springframework.orm.jpa.support.Persist enceAnnotationBeanPostProcessor"/>

    <bean id="patientDaoImpl" class="com.hc.services.patientmanagement.PersonDao Impl" />
    <bean id="patientServiceImpl" class="com.hc.services.patientmanagement.PersonSer viceImpl" />
    ===========================
    persistence.xml
    ===========================<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="acme" transaction-type="RESOURCE_LOCAL"/>
    </persistence>
    ==========================
    ormxml
    ==========================
    <persistence-unit-metadata>
    <xml-mapping-metadata-complete/>
    <persistence-unit-defaults>
    <access>PROPERTY</access>
    </persistence-unit-defaults>
    </persistence-unit-metadata>
    <package>com.hc.model.common</package>
    <entity class="Person">
    <table name="Person"/>
    <attributes>
    <id name="id">
    <generated-value strategy="AUTO"/>
    </id>
    <basic name="firstName"/>
    <basic name="lastName"/>
    <basic name="middleName"/>
    </attributes>
    </entity>
    Complete project is present in the attached zip file. pom.xml can be verified for the dependencies that i imported from spring-framework-2.1-m1\lib to maven local rep.
    Waiting for anxious response from great spring team!
    Attached Files Attached Files
    Last edited by softengg; Jun 18th, 2007 at 08:25 PM. Reason: subscribed for email notification

  2. #2
    Join Date
    Aug 2004
    Posts
    1,104

    Default

    Take a look at this blog entry and see if the suggestions there solve your issue:

    http://blog.interface21.com/main/200...ith-hibernate/
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  3. #3
    Join Date
    Sep 2004
    Posts
    2

    Default Tried soln 1 from blog with no result. Can this be a Conflict with javassit???

    Thanx for the reply. I have tried his solution #1 and excluded explicitly the dependency for hibernate on asm libs and added for spring as described in the blog. But the exception remains the same. One important thing i want to highilght is that i am also putting javassist lib as depenedncy as when i dont add it, i get javassist is not in the classpath. And as soon as i add it, this exception starts coming. But strange thing is that same app runs fine with ant build script used in spring's example petclinic.

  4. #4
    Join Date
    Jun 2007
    Location
    The Netherlands
    Posts
    5

    Default

    I've tried your project on my machine and it actually just worked.
    Looking at your stacktrace though I think there is still a jar lingering on your classpath that has the wrong version.

    I don't know much about maven but maybe you could try running
    Code:
    mvn clean
    .
    I love deadlines. I like the whooshing sound they make as they fly by.

    -- Douglas Adams --

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •