Unknown entity bean class after hot deploy: netbeans 6.9 + glassfish 2.1 + eclipselink jpa 2.0

后端 未结 5 1577
挽巷
挽巷 2021-01-19 06:39

When I deploy my app, it works perfectly until I make a change, save, and netbeans hot deploys the application. At this point I get an unknown entity bean class error on a c

相关标签:
5条回答
  • 2021-01-19 07:01

    I also got this problem in a web service that fetches data from database. I opted two solutions:- (1) Solution was to put a method in webservice like @PreDestroy public void destruct()==> Here i closed EntityManagerFactory (2) Introduced a listener ServletContextListener and closed open emf here also in case webservice method could not work due to any reason.

    Because server-restart for re-deployment is not acceptable, I wanted to be on safer side,closing emf twice in case it remains open it has chance to get closed in listener.

    Thanks Nitin

    0 讨论(0)
  • 2021-01-19 07:02

    Turns out we weren't needing any of the JPA 2.0 features at this time and eclipselink support for glassfish v2 is a bit spotty. So the solution for us was to switch back to toplink and JPA 1.0 . Not the best solution but it solved our deployment issues. We'll be looking at eclipselink when we switch over to glassfish v3.

    0 讨论(0)
  • 2021-01-19 07:12

    Your problem is quite interesting one. So, I just continue to read more about it. I found a thread at SO itself which is still do not have any solution JPA - Unknown entity bean class. Not only in SO, also some of the forums outside like:

    • "Unknown entity bean class" when accessing from a swing-app
    • EJB: Unknown entity bean class

    After a while I found an another thread at SO itself "Java Persistance Issue"

    Questioned & Answered by James itself:

    So as the comments above suggest this seems to be an issue with the eclipse plug in for glassfish. I am having no problems when deploying the ear manually.

    Thanks all for the help.

    James

    Finally, that sounds as an issue :) http://java.net/jira/browse/GLASSFISHPLUGINS-307

    Hope, James message would help.

    0 讨论(0)
  • 2021-01-19 07:13

    Although it is not apparent from the posted code if this is the solution but symptoms are the same.

    It seems to happen when creating entity manager from entity manager factory outside of the container. The factory needs to be closed on un-deploying. That is why it works only first time when deployed and not on redeploy. See: Unknown entity bean class issue with glassfish v3

    0 讨论(0)
  • 2021-01-19 07:15

    The issue is the old persistence unit with references to the old classes is remaining after your redeploy. Ensure the old EntityManagerFactory is getting closed. Glassfish should handle this for any managed factories such as in a SessionBean, but if you are managing your own factories you need to ensure these are closed.

    0 讨论(0)
提交回复
热议问题