[JBossCache] - PojoCache ClassCastException
by morisona
If this is a stupid question (ie the answer is to be found in the docs, examples, this forum, or the wiki) please tell me, and I will go back searching. Otherwise I would be very greatful if someone with experience of PojoCache anf JBoss classloading could give me their view.
I hava a PojoCache deployed on the JBoss As Server (4.0.5). I create and update objects from a Servlet. This works fine until I undeploy and deploy the Web App. I then get a ClassCastException here:
| Object obj = cache.getObject("/totos/" + nick);
| Toto toto = (toast.Toto) obj;
|
(The object concerned is a 'Toto')
I have "UseJBossWebLoader" in the Tomcat jboss-service.xml set to true. (Otherwise the cache in the 'other' server of the cluster can not find the object).
I have traced the classloaders being used. With the following code:
| Object obj = cache.getObject("/totos/" + nick);
| ...
| System.out.println("Object retrieved from cache class is: " + obj.getClass().getName() + ", Classloader is:" + obj.getClass().getClassLoader());
| System.out.println("Context Classloader is:" + Thread.currentThread().getContextClassLoader());
| System.out.println("Class loader of a new class is:" + new Toto().getClass().getClassLoader());
| Toto toto = (toast.Toto) obj;
|
This gives:
| Object retrieved from cache class is: toast.Toto, Classloader is:org.jboss.mx.loading.UnifiedClassLoader3@9c67db{ url=null ,addedOrder=57}
| Context Classloader is:org.jboss.web.tomcat.tc5.WebCtxLoader$ENCLoader@feb215
| Class loader of a new class is:org.jboss.mx.loading.UnifiedClassLoader3@bf4472{ url=file:/C:/jboss/jboss-4.0.5.GAejb3/server/default/tmp/deploy/tmp60992simple-exp.war/ ,addedOrder=58}
|
So the classloader used to load the object from the cache (UCL, addorder=57) is not the same as that used to create an object in this environment (UCL, addorder=58). So I can understand that I get a ClasscastException.
I have tried registering the classloader used by the servlet:
| MBeanServer server = MBeanServerLocator.locateJBoss();
| cache = (PojoCacheMBean) MBeanProxyExt.create(PojoCacheMBean.class, "jboss.cache:service=PojoCache", server);
| ClassLoader cl = new Toto().getClass().getClassLoader();
| cache.registerClassLoader("/totos", cl);
|
But this has had no effect.
I have also tried setting the ContextClassLoader to the ClassLoader used by the cache:
| ClassLoader cl = obj.getClass().getClassLoader();
| Thread.currentThread().setContextClassLoader(cl);
|
But that had no effect either.
Thank you.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4041023#4041023
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4041023
17 years, 8 months
[JBoss Seam] - Re: Exception when using entity-query CRUD framework
by smithbstl
Thanks Pete,
so instead of just letting EJB inject my entity manager automatically
| private EntityManager em
I should let Seam do it instead?
| @In
| private EntityManager em
By specifying @In it will always know to get the Seam EntityManager from the EntityManagerFactory?
As far as the Dialog stuff, what I like about Trinidad is the built in tr:inputListOfValues control which displays a popup to get values from. It is useful when a Select/DropDown box just won't do. It also does PPR to issue a refresh when the value returns to the calling page.
In Seam I can use an s:link to propagate the conversation to the popup and I guess some JavaScript to make it a new window (Trinidad has an attribute useWindow that does this). How would I go about getting the value back to the calling page? Bijection? How does the calling page know to refresh/ppr?
Thanks again!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4041016#4041016
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4041016
17 years, 8 months