Topic
7 replies Latest Post - ‏2010-12-15T14:52:55Z by sutter
SystemAdmin
SystemAdmin
45 Posts
ACCEPTED ANSWER

Pinned topic NoClassDefFoundError for org.apache.openjpa.util.StringId from bean's pcNewObjectIdInstance method

‏2010-02-02T06:12:37Z |
Hi,

I am experiencing problems with an EAR deployed onto Websphere 7. The EAR
contains a web module and an ejb 3 module that uses openjpa 2 for
persistence.

More than half the time after redeploying the EAR, for each EJB3 class, I
would get the following kind of error the first time I invoke
EntityManager::find(beanclass, beanid)

java.lang.NoClassDefFoundError: org/apache/openjpa/util/StringId
at com.example.beans.MyEntity.pcNewObjectIdInstance(MyEntity.java)
at
org.apache.openjpa.enhance.PCRegistry.newObjectId(PCRegistry.java:142)
at
org.apache.openjpa.meta.MetaDataRepository.processRegisteredClass(MetaDataRepository.java:1595)
at
org.apache.openjpa.meta.MetaDataRepository.processRegisteredClasses(MetaDataRepository.java:1543)
at
org.apache.openjpa.meta.ClassMetaData.getPCSubclasses(ClassMetaData.java:358)
at
org.apache.openjpa.jdbc.meta.MappingRepository.findBaseClassMapping(MappingRepository.java:1471)
at
org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:364)
at
org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:753)
at
org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:646)
at
org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:411)
at
org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1199)
at
org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:286)
at
org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:471)
at
com.ibm.ws.jpa.management.JPATxEmInvocation.find(JPATxEmInvocation.java:211)
at
com.ibm.ws.jpa.management.JPAEntityManager.find(JPAEntityManager.java:215)
...

Curiously, this only happens upon most redeployments, but not all. However,
once I encounter this error, I would encounter it with all the other EJB 3
classes in the EAR as well. And, the error only occurs for the first
EntityManager::find invocation per ejb. Subsequent EntityManager::find
invocations would be able to work without exceptions.

Thanks for any advice or help, let me know if you need anymore information!
Updated on 2010-12-15T14:52:55Z at 2010-12-15T14:52:55Z by sutter
  • sutter
    sutter
    94 Posts
    ACCEPTED ANSWER

    Re: NoClassDefFoundError for org.apache.openjpa.util.StringId from bean's pcNewObjectIdInstance method

    ‏2010-02-02T15:26:27Z  in response to SystemAdmin
    Hi stellalok,
    Just to clarify... You are using the JPA 2.0 Open Alpha on top of WAS v7? Your statement indicated WAS v7 and you are attempting to use openjpa 2. I'm just trying to clarify the exact environment. As an example, you can not use openjpa 2 with base WAS v7. You have to use the JPA 2.0 Open Alpha environment. The other question is whether you are using the JPA solution as part of the Open Alpha, or are you attempting to embed openjpa 2 in the ear? Thanks for the clarifications.

    Are you attempting some new JPA 2 features? Or, is this an existing application that used to work with base WAS v7 (using JPA 1 features)?

    FYI, I am not aware of any issues in this area. I'm just trying to narrow down the environment and scenario so that we can get this resolved. Thanks for your help.

    Kevin
    • SystemAdmin
      SystemAdmin
      45 Posts
      ACCEPTED ANSWER

      Re: NoClassDefFoundError for org.apache.openjpa.util.StringId from bean's pcNewObjectIdInstance method

      ‏2010-02-11T06:21:35Z  in response to sutter
      Hi Kevin,

      Sorry for not being clear earlier, I was using JPA 2.0 Open Alpha (M3) on WAS v7.0.05, not embedding open jpa 2 in the ear.

      I do use some new JPA 2 features, such as EntityManager::detach

      I also tried upgrading to the WAS 7.0.07 fixpack, which automatically downgraded open jpa to openjpa 1.2.2, the StringId NoClassDefFoundError problem went away. However, this solution prevents me from using JPA 2 features.

      May I also ask if JPA 2 will be supported in future WAS fixpacks?

      Stella
      • sutter
        sutter
        94 Posts
        ACCEPTED ANSWER

        Re: NoClassDefFoundError for org.apache.openjpa.util.StringId from bean's pcNewObjectIdInstance method

        ‏2010-02-11T14:24:03Z  in response to SystemAdmin
        Thanks for the info, Stella,
        It sounds like your Alpha environment is valid. Thanks for the clarification.

        Like I mentioned previously, we are not aware of this situation. With your additional (accidental) testing on 7005, this defintely looks like some type of classloader issue. I will create an internal bug tracker for this problem and pursue a solution.

        The JPA 2.0 features will not become part of the service stream (fixpack). But, it is planned as a feature enhancement. Watch this space for additional information concerning specific release schedules.

        Thanks,
        Kevin
        • sutter
          sutter
          94 Posts
          ACCEPTED ANSWER

          Re: NoClassDefFoundError for org.apache.openjpa.util.StringId from bean's pcNewObjectIdInstance method

          ‏2010-03-12T16:58:35Z  in response to sutter
          Hi Stella,
          I logged this issue as soon as you posted it. Unfortunately, we have not been able to reproduce the problem. By any chance, have you moved up to either the Beta or Beta Refresh? If so, do you experience the same problem? If so, then we would probably like to get more details on your environment to figure out why we can't reproduce it.

          Thanks,
          Kevin
  • M_A_N
    M_A_N
    1 Post
    ACCEPTED ANSWER

    Re: NoClassDefFoundError for org.apache.openjpa.util.StringId from bean's pcNewObjectIdInstance method

    ‏2010-04-30T15:32:03Z  in response to SystemAdmin
    We are having a similar issue.
    We are using WebSphere 7 fixpack 7, Spring 3.0 with embedded JPA.

    This error happens only the firsttime when we hit application after it is updated, second time it works fine.
    org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/apache/openjpa/util/StringId
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1583)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:870)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:475)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3799)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:930)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:182)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
    Caused by: java.lang.NoClassDefFoundError: org/apache/openjpa/util/StringId
    at k12.gcps.saba.bo.Employee.pcNewObjectIdInstance(Employee.java)
    at org.apache.openjpa.enhance.PCRegistry.newObjectId(PCRegistry.java:142)
    at org.apache.openjpa.meta.MetaDataRepository.processRegisteredClass(MetaDataRepository.java:1438)
    at org.apache.openjpa.meta.MetaDataRepository.processRegisteredClasses(MetaDataRepository.java:1389)
    at org.apache.openjpa.meta.ClassMetaData.getPCSubclasses(ClassMetaData.java:342)
    at org.apache.openjpa.jdbc.meta.MappingRepository.findBaseClassMapping(MappingRepository.java:1286)
    at org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:325)
    at org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:662)
    at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:549)
    at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308)
    at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2427)
    at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2281)
    at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1021)
    at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:645)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
    at $Proxy384.persist(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
    at $Proxy384.persist(Unknown Source)
    at k12.gcps.saba.dao.CourseProposalDAO.create(CourseProposalDAO.java:95)
    at k12.gcps.saba.service.CourseProposalServiceImpl.create(CourseProposalServiceImpl.java:119)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.doInTransaction(TransactionInterceptor.java:130)
    at org.springframework.transaction.jta.WebSphereUowTransactionManager$UOWActionAdapter.run(WebSphereUowTransactionManager.java:337)
    at com.ibm.ws.uow.UOWManagerImpl.runUnderNewUOW(UOWManagerImpl.java:1066)
    at com.ibm.ws.uow.UOWManagerImpl.runUnderUOW(UOWManagerImpl.java:627)
    at org.springframework.transaction.jta.WebSphereUowTransactionManager.execute(WebSphereUowTransactionManager.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:125)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy391.create(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:124)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy392.create(Unknown Source)
    at k12.gcps.saba.handler.CourseProposalHandler.handleCreateCourseProposal(CourseProposalHandler.java:81)
    at k12.gcps.saba.controller.CourseProposalController.doCreateProposal(CourseProposalController.java:54)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
    ... 27 more
    Any help will be appreciated. Thanks
    • sutter
      sutter
      94 Posts
      ACCEPTED ANSWER

      Re: NoClassDefFoundError for org.apache.openjpa.util.StringId from bean's pcNewObjectIdInstance method

      ‏2010-04-30T17:10:17Z  in response to M_A_N
      Hmmm... As my last post indicated, we have had a difficult time reproducing this problem unless we went back to the level of code that originally produced the problem (7.0.0.5 + the JPA FeP Alpha). And, the original poster of the problem indicated the problem went away when using the 7.0.0.7 code base, which is what you are running with. One additional variable is that you are using Spring as a front end to using OpenJPA and there have been some anomalies with classloaders, Spring, and JPA...

      Since it doesn't sound like you are using the JPA 2.0 Feature Pack in your environment, and this forum is specific to the use of the JPA 2.0 Feature Pack, I would suggest a couple of alternatives...

      1) Post your problem on the Apache OpenJPA forum. Since you have the additional variable of using Spring, there may be some helpful advice from our Spring users to help get around this issue.

      2) Open a PMR for this problem. Since you are using WebSphere 7.0.0.7, there does seem to be some issue with classloading that is completely understood. At this point, I'm not sure if it's the WebSphere container, Spring, or OpenJPA. But, we should get to the bottom of it.

      3) Another alternative is a bit more work... Do you have an environment where you could test this out with the JPA FeP Beta Refresh code? The FeP requires 7.0.0.9, so you would have to upgrade a machine from 7.0.0.7. But, doing this experiment might help with narrowing down the issue.

      Thanks for your interest and patience,
      Kevin
  • sutter
    sutter
    94 Posts
    ACCEPTED ANSWER

    Re: NoClassDefFoundError for org.apache.openjpa.util.StringId from bean's pcNewObjectIdInstance method

    ‏2010-12-15T14:52:55Z  in response to SystemAdmin
    Just cleaning up some old postings...