[Design of Messaging on JBoss (Messaging/JBoss)] - ClassLoader behaviour on remote clustering tests
by flavia.rainone@jboss.com
We are seeing an unexpected class loader behaviour in the remote clustering tests, which is resulting in a RuntimeException thrown by JBoss AOP, when aop is run in classical instrumentation mode.
The cause of this exception is that JBoss AOP is trying to create a class that has already been created and loaded... JBoss AOP tries to create such a class because the class loader that defined the class is not able of loading the same class, which is totally unexpected.
Look at the pseudocode below:
ClassLoader myLoader = ....;
| Class class = myLoader.defineClass(....);
| System.out.println("Same class loader: " + (myLoader == class.getClassLoader()));
| System.out.println("I wanted to use this loader: " + loader);
| System.out.println("I got a class with this loader: " + loadedClass.getClassLoader());
| myLoader.load(class.getName());
|
The call you can see at the second line is actually made by Javassist, through reflection... the code above is a simplification.
The result of the code above, when run by JBoss AOP during class generation. is a ClassNotFoundException preceeded by the messages:
| Same class loader: false
| I wanted to use this loader: sun.misc.Launcher$AppClassLoader@1a5ab41
| I got a class with this loader: org.jboss.test.messaging.tools.container.ClassLoaderJMXWrapper@6fa9fc
|
Since the call defineClass has been made to sun.misc.Launcher$AppClassLoader@1a5ab41, we need this class to be able of loading the class later, instead of throwing a ClassNotFoundException.
Does anybody know why we are seeing this behaviour?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4142731#4142731
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4142731
18 years
[Design of JCA on JBoss] - Re: JBPAPP-750 - Integration between AS and JBossMessaging 1
by vickyk
"adrian(a)jboss.org" wrote :
| Why? What's the use case?
|
I am considering the following jsp as the use case , it contains the similar code what was present in the testcase that failed ;)
<%@page import="javax.naming.*,javax.jms.*,org.jboss.tm.TransactionManagerLocator,javax.transaction.*,org.jboss.tm.TxUtils"%>
| <%
| Queue queue = (Queue) new InitialContext().lookup("queue/testQueue");
| ConnectionFactory cf = (ConnectionFactory) new InitialContext().lookup("java:TestJmsLocal");
| TransactionManager tm = TransactionManagerLocator.getInstance().locate();
| tm.begin();
|
| try
| {
| out.println(tm.getTransaction()+"Transaction status --->"+TxUtils.getStatusAsString(tm.getTransaction().getStatus())+"<br>");
| Connection c = cf.createConnection();
| out.println(tm.getTransaction()+"Transaction status --->"+TxUtils.getStatusAsString(tm.getTransaction().getStatus())+"<br>");
| try
| {
| c.start();
| out.println(tm.getTransaction()+"Transaction status --->>>>>>>>"+TxUtils.getStatusAsString(tm.getTransaction().getStatus())+"<br>");
| Session s = c.createSession(true, Session.SESSION_TRANSACTED);
|
| out.println(tm.getTransaction()+"Transaction status -------->"+TxUtils.getStatusAsString(tm.getTransaction().getStatus())+"<br>");
| }
| finally
| {
| try
| {
| c.close();
| }
| catch (Exception ignored)
| {
| }
| }
| }
| finally
| {
| out.println(tm.getTransaction()+"Transaction status --->"+TxUtils.getStatusAsString(tm.getTransaction().getStatus())+"<br>");
| try{
| tm.commit();
| }
| catch(Exception exp)
| {
| out.println("EXP is "+exp+"caused by: "+exp.getCause());
| exp.printStackTrace();
| }
| out.println(tm.getTransaction());
| }
| %>
Should the above jsp work for the following CF definition ?
<tx-connection-factory>
| <jndi-name>TestJmsLocal</jndi-name>
| <rar-name>jms-ra.rar</rar-name>
| <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
| <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
| <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/TestJMSLocalProvider</config-property>
| <max-pool-size>20</max-pool-size>
| <application-managed-security/>
| </tx-connection-factory>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4142718#4142718
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4142718
18 years