Topic
1 reply Latest Post - ‏2013-01-10T22:10:53Z by sutter
SystemAdmin
SystemAdmin
45 Posts
ACCEPTED ANSWER

Pinned topic One to many error for Annotations based Spring-hibernate.

‏2013-01-10T06:36:59Z |
Hi,

I am getting OneToMany mapping issue while using the WAS7.0.0 and Spring 3.1 and Hibernate 4.1. Though problem gets resolved while posting the Hibernate-jpa2.0.final.jar in WASprofile's JVM ext folder ie. classload path. I am looking for an alternative otherthan posting the jar on this location as my other application is getting impacted. Here is attached logs for the same.
Key Logs traces are here:
  • Start Display Current Environment ************
WebSphere Platform 7.0.0.0 http://ND 7.0.0.0 r0835.03 running with process name delvmdev-trialNode01Cell\delvmdev-trialNode01\server1 and process id 10464
Host Operating System is Linux, version 2.6.32-131.0.15.el6.x86_64
Java version = 1.6.0, Java Compiler = j9jit24, Java VM name = IBM J9 VM
was.install.root = /opt/IBM/WebSphere/AppServer
user.install.root = /opt/IBM/WebSphere/AppServer/profiles/AppSrv01
Java Home = /opt/IBM/WebSphere/AppServer/java/jre
ws.ext.dirs = /opt/IBM/WebSphere/AppServer/java/lib:/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/classes:/opt/IBM/WebSphere/AppServer/classes:/opt/IBM/WebSphere/AppServer/lib:/opt/IBM/WebSphere/AppServer/installedChannels:/opt/IBM/WebSphere/AppServer/lib/ext:/opt/IBM/WebSphere/AppServer/web/help:/opt/IBM/WebSphere/AppServer/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime
Classpath = /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/properties:/opt/IBM/WebSphere/AppServer/properties:/opt/IBM/WebSphere/AppServer/lib/startup.jar:/opt/IBM/WebSphere/AppServer/lib/bootstrap.jar:/opt/IBM/WebSphere/AppServer/lib/jsf-nls.jar:/opt/IBM/WebSphere/AppServer/lib/lmproxy.jar:/opt/IBM/WebSphere/AppServer/lib/urlprotocols.jar:/opt/IBM/WebSphere/AppServer/deploytool/itp/batchboot.jar:/opt/IBM/WebSphere/AppServer/deploytool/itp/batch2.jar:/opt/IBM/WebSphere/AppServer/java/lib/tools.jar
Java Library path = /opt/IBM/WebSphere/AppServer/java/jre/lib/amd64/compressedrefs:/opt/IBM/WebSphere/AppServer/java/jre/lib/amd64:/opt/IBM/WebSphere/AppServer/bin::/usr/lib
  • End Display Current Environment *************
essor.java:507)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
... 127 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sourceCodeServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.was.trial.service.impl.SourceCodeServiceImpl.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource http://spring-hibernate.xml: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: **javax/persistence/OneToMany.orphanRemoval()Z**
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
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.findAutowireCandidates(DefaultListableBeanFactory.java:844)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
... 129 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.was.trial.service.impl.SourceCodeServiceImpl.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource http://spring-hibernate.xml: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax/persistence/OneToMany.orphanRemoval()Z

Any suggestion/advice is more welcome.
Updated on 2013-01-10T22:10:53Z at 2013-01-10T22:10:53Z by sutter
  • sutter
    sutter
    94 Posts
    ACCEPTED ANSWER

    Re: One to many error for Annotations based Spring-hibernate.

    ‏2013-01-10T22:10:53Z  in response to SystemAdmin
    Hi WebSpark,
    Your posting mentions WebSphere 7.0.0, but there is no mention of the OSGi / JPA 2.0 Feature Pack. Do you have that Feature Pack installed and configured (profiles augmented) for your environment? It looks like from the errors posted that your environment is still only getting resolved to the JPA 1.0 APIs, but you are expecting to use JPA 2.0 APIs (due to the missing orphanRemoval element).

    If you configured with the OSGi /JPA 2.0 Feature Pack, then you probably still have a classpath/classloader issue and you're pulling the javax.persistence.* classes from the wrong location. The use of isolated shared libraries or Parent_Last classloading normally resolves those type of issues.

    Good luck,
    Kevin Sutter, JPA Architect, IBM WebSphere