-
1. Re: Trouble with aopc compiled class being loaded with a fac
brian.stansberry Jun 7, 2006 12:35 PM (in response to wildweasel)This is a total shot in the dark, so please just take it as such:
Have you tried:try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); clazz = cl.loadClass(className); } catch (Exception t) { log.fatal("Unable to load '" + key + "' implementation class: '" + className + "'" + ": " + t); log.fatal("Cause: " + t.getCause()); t.printStackTrace(System.err); }
-
2. Re: Trouble with aopc compiled class being loaded with a fac
ben.wang Jun 8, 2006 8:01 AM (in response to wildweasel)Have you tried to use it outside WL first? I meant try to load the "instrumented" class using your example in a standalone Java program.
Again, it is also a shot in the dark. :-) But can this be related to the WL classloader? -
3. Re: Trouble with aopc compiled class being loaded with a fac
wildweasel Jun 8, 2006 11:01 AM (in response to wildweasel)Thank you for the quick replies. I have removed weblogic from the equation and created the following unit test that gives me the same result.
Note that I originally posted this to the cache forum, because that is where we are headed, but if need be, I could repost this to the AOP forum. We are using jboss-aop-1.3.5.jar, btw. Also I forgor to mention that we are using compile time annotations and aopc.package com.gestalt.dmit.mcsoa.registrar.presence.jbosscache.impl; /** * A class that blah.... * * @@org.jboss.cache.aop.AopMarker * */ public class JeffImpl { private long _foo; private long _bar; public JeffImpl(long duration, long expires) { _foo = duration; _bar= expires; } }
package com.gestalt.dmit.mcsoa.registrar.presence; import com.gestalt.dmit.mcsoa.registrar.presence.jbosscache.impl.*; import junit.framework.TestCase; public class PresenceSubscriptionFactoryTest extends TestCase { public void testGetJeffInstance() { try { JeffImpl jps = new JeffImpl(Long.MAX_VALUE, Long.MIN_VALUE); assertTrue("JeffImpl came back as incorrect implementation! " + jps.getClass().getName(), jps instanceof JeffImpl); } catch (Exception e) { e.printStackTrace(); } } }
Which throws the following exception:
[gcpunit] ------------- Standard Error ----------------- [gcpunit] java.lang.ArrayIndexOutOfBoundsException: 1 [gcpunit] at com.gestalt.dmit.mcsoa.registrar.presence.jbosscache.impl.JeffImpl._foo_w_$aop(JeffImpl.java) [gcpunit] at com.gestalt.dmit.mcsoa.registrar.presence.jbosscache.impl.JeffImpl.<init>(JeffImpl.java:16) [gcpunit] at com.gestalt.dmit.mcsoa.registrar.presence.PresenceSubscriptionFactoryTest.testGetJeffInstance(PresenceSubscriptionFactory Test.java:12) [gcpunit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [gcpunit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [gcpunit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [gcpunit] at java.lang.reflect.Method.invoke(Method.java:324) [gcpunit] at junit.framework.TestCase.runTest(TestCase.java:154) [gcpunit] at junit.framework.TestCase.runBare(TestCase.java:127) [gcpunit] at junit.framework.TestResult$1.protect(TestResult.java:106) [gcpunit] at junit.framework.TestResult.runProtected(TestResult.java:124) [gcpunit] at junit.framework.TestResult.run(TestResult.java:109) [gcpunit] at junit.framework.TestCase.run(TestCase.java:118) [gcpunit] at junit.framework.TestSuite.runTest(TestSuite.java:208) [gcpunit] at junit.framework.TestSuite.run(TestSuite.java:203)
This is about the simpliest case I could distill our code down to and I am still baffled. -
4. Re: Trouble with aopc compiled class being loaded with a fac
ben.wang Jun 8, 2006 11:59 AM (in response to wildweasel)I have just tried out a similar test case like yours but still can't reproduce. Can you use load-time instrumentation option to see if the problem is there as well?
Here is the test case:public void testLoadingClass() { Address addr = new Address(); addr.getClass().getName(); }
Here is Address class that is under JBossCache testsuite.package org.jboss.cache.aop.test; /** * @@org.jboss.cache.aop.AopMarker */ public class Address { String street = null; String city = null; int zip = 0; public String getStreet() { return street; } public void setStreet(String street) { this.street = street; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public int getZip() { return zip; } public void setZip(int zip) { this.zip = zip; } public String toString() { return "street=" + getStreet() + ", city=" + getCity() + ", zip=" + getZip(); } }
-
5. Re: Trouble with aopc compiled class being loaded with a fac
wildweasel Jun 8, 2006 2:52 PM (in response to wildweasel)Ben and all,
Thank you for your reply and sample code. I have discovered the problem. My class had underscores prefixing the all the instance variable names. This will cause the ArrayIndexOutOfBoundsException.
I verified the same with the sample class Address below. Change all references ofstreet
to_street
and you should be able to duplicate the error.
I am new to JBoss products, so if you could tell me where to file this issue with JIRA, I will do so with reproduceable steps. -
6. Re: Trouble with aopc compiled class being loaded with a fac
ben.wang Jun 8, 2006 8:03 PM (in response to wildweasel)OK. then this is a bug with JBoss Aop. Please file the bug there and Kabir should be able to take care of it.