Announcement Announcement Module
Collapse
No announcement yet.
Issues with interface PersistenceUnitInfo in com.springsource.javax.persistence-1.0.0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issues with interface PersistenceUnitInfo in com.springsource.javax.persistence-1.0.0

    Hi All,
    I am using Struts 2 + Spring 3.0.2 + hibernate 3.5 final.
    I am getting following error while running the application.
    Exception comes while starting the application on server itself.

    It looks like this issue is in JIRA
    https://jira.springsource.org/browse/SPR-6408

    looks fixed but I am still getting this error.
    This error is coming due to com.springsource.javax.persistence-1.0.0.jar
    the interface PersistenceUnitInfo still doesnot have included the two methods

    public abstract SharedCacheMode getSharedCacheMode();

    public abstract ValidationMode getValidationMode();

    this error comes when Hibernate org.hibernate.ejb.util.LogHelper is trying to log PersistenceUnitInfo into the console.

    PHP Code:
    SEVEREException sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org
    .springframework.beans.factory.BeanCreationExceptionError creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failednested exception is java.lang.NoSuchMethodErrorjavax.persistence.spi.PersistenceUnitInfo.getSharedCacheMode()Ljavax/persistence/SharedCacheMode;
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        
    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:190)
        
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:546)
        
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
        
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
        
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
        
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
        
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
        
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
        
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
        
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
        
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
        
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        
    at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
        
    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:597)
        
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Caused byjava.lang.NoSuchMethodErrorjavax.persistence.spi.PersistenceUnitInfo.getSharedCacheMode()Ljavax/persistence/SharedCacheMode;
        
    at org.hibernate.ejb.util.LogHelper.logPersistenceUnitInfo(LogHelper.java:39)
        
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:509)
        
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
        
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
        
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
        ... 
    27 more 

    Please let me know if I am missing anything here.
    If we already have some fix please suggest

  • #2
    Try this

    I am not sure what Hibernate includes.

    But you probably need a jpa2 API:

    https://jira.springsource.org/browse...l#action_51542

    Assuming you are using pom:

    <dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>javax.persistence</artifactId>
    <version>2.0.0</version>
    </dependency>

    Or download this jar somewhere.

    I ran into a different problem after adding this (with OpenJPA 2, not Hibernate)...

    Comment


    • #3
      I got around this problem by replacing com.springsource.javax.persistence-1.0.0.jar with hibernate-jpa-2.0-api-1.0.0.Final.jar.

      If you have both jars in your classpath, simply remove com.springsource.javax.persistence-1.0.0.jar in other to rule out conflicts.

      Comment

      Working...
      X