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

浪子不回头ぞ 提交于 2019-12-01 21:04:48

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.

Mohamed Saligh

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:

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.

Jan Volf

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

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!