[jboss-jira] [JBoss JIRA] Created: (JBAS-4755) java.lang.IllegalArgumentException: repeated interface: java.io.Serializable while creating proxy in ExternalContext

Roland Räz (JIRA) jira-events at lists.jboss.org
Wed Sep 26 10:01:41 EDT 2007


java.lang.IllegalArgumentException: repeated interface: java.io.Serializable  while creating proxy in ExternalContext
---------------------------------------------------------------------------------------------------------------------

                 Key: JBAS-4755
                 URL: http://jira.jboss.com/jira/browse/JBAS-4755
             Project: JBoss Application Server
          Issue Type: Bug
      Security Level: Public (Everyone can see)
    Affects Versions: JBossAS-4.2.1.GA
            Reporter: Roland Räz


A java.lang.reflect.Proxy.getProxyClass may not be called with multiple identical class object. This could be ensured in ExternalContext$CachedContext.createProxyContext. Changing the signature of org.jboss.util.Classes form (List allIfaces, Class c) to (Set allIfaces, Class c) and refactoring all calls to this method could be even better.

This bug was probably caused by fixing JBAS-4048.

The following fix worked for me:

static Context createProxyContext(Context ctx)
{
 ClassLoader loader = Thread.currentThread().getContextClassLoader();
 ArrayList<Class> ifaces = new ArrayList<Class>();
 Classes.getAllInterfaces(ifaces, ctx.getClass());
 Set ifacesSet = new HashSet(ifaces);
 Class[] interfaces = new Class[ifacesSet.size()];
 ifacesSet.toArray(interfaces);
 InvocationHandler handler = new CachedContext(ctx);
 Context proxyCtx = (Context) Proxy.newProxyInstance(loader, interfaces, handler);
 return proxyCtx;
}

Exception:

java.lang.IllegalArgumentException: repeated interface: java.io.Serializable
	at java.lang.reflect.Proxy.getProxyClass(Proxy.java:370)
	at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
	at org.jboss.naming.ExternalContext$CachedContext.createProxyContext(ExternalContext.java:503)
	at org.jboss.naming.ExternalContext.rebind(ExternalContext.java:291)
	at org.jboss.naming.ExternalContext.startService(ExternalContext.java:208)
	at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
	at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:196)
	at com.winterthur.jackpot.jboss.jndi.JBossJndiUnbindTest.setUp(JBossJndiUnbindTest.java:190)
	at junit.framework.TestCase.runBare(TestCase.java:125)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       




More information about the jboss-jira mailing list