[jboss-user] [EJB 3.0] - Classloader issue when persistence unit and ejb in different jars - how to solve?

Shri Shrimad do-not-reply at jboss.com
Sat Apr 10 09:10:19 EDT 2010


Shri Shrimad [http://community.jboss.org/people/shrimad] created the discussion

"Classloader issue when persistence unit and ejb in different jars - how to solve?"

To view the discussion, visit: http://community.jboss.org/message/536728#536728

--------------------------------------------------------------
Hello,

For example, I have two jars:

1. JpaLib.jar, which contain entity class (for example, Account) and persistence unit JpaLibPU.
2. JpaBean.jar, which contain ejb3 SLSB, which uses TestPU to get Account from database.


{{{
@Stateless
public class JpaTestBean implements ...
{
    @PersistenceContext(unitName="JpaLibPU")
    private EntityManager em;

    public Account getAccount( String id )
    {
         return em.find( Account.class, id );
    }
}}}


After deploy, all works ok.

When I redeploy JpaLib.jar (add another entity class, for example), JpaBean.jar is stopped and started again, when JpaLibPU becomes available.

But, when I invoke getAccount I get exception: "java.lang.ClassCastException: tst.entity.Account cannot be cast to tst.entity.Account". As I understand, this happens due Account in JpaBean.jar and Account in JpaLib.jar loaded using defferent classloaders.

If I manually "touch" JpaBean.jar - jboss redeploy it and all works fine again.

How can I force JBoss to automatically redeploy (not just dtop/start) JpaBean.jar when JpaLib.jar is redeployed?

Any ideas?

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/536728#536728]

Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100410/ec99dd98/attachment.html 


More information about the jboss-user mailing list