[jboss-user] [JBoss Microcontainer Development] - Issues using Javassist TypeInfoFactory in other projects
Kabir Khan
do-not-reply at jboss.com
Tue Mar 30 07:05:19 EDT 2010
Kabir Khan [http://community.jboss.org/people/kabir.khan%40jboss.com] replied to the discussion
"Issues using Javassist TypeInfoFactory in other projects"
To view the discussion, visit: http://community.jboss.org/message/534602#534602
--------------------------------------------------------------
Another issue is that dynamically created classes are not found in the classpools.
Dynamic proxies are not found at all:
0 DEBUG [JDKLazyInstantiationTestCase] ==== setUp org.jboss.test.kernel.lazy.test.JDKLazyInstantiationTestCase ====
5 DEBUG [JDKLazyInstantiationTestCase] ==== Starting testLazy ====
20 DEBUG [KernelFactory] Starting JBoss Kernel construction...
53 WARN [PropertyConfiguration] Factory: org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory at 4393722c
466 DEBUG [KernelFactory] Completed JBoss Kernel construction. Duration: 446 milliseconds
568 ERROR [AbstractKernelController] Error installing to Instantiated: name=beanProxy state=Described
java.lang.RuntimeException: Class not found: $Proxy0
at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.get(JavassistTypeInfoFactoryImpl.java:311)
at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.getTypeInfo(JavassistTypeInfoFactoryImpl.java:519)
at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory.getTypeInfo(JavassistTypeInfoFactory.java:51)
at org.jboss.classadapter.plugins.BasicClassAdapterFactory.getClassAdapter(BasicClassAdapterFactory.java:54)
Neither are the javassist ProxyFactory proxies, since they just define the class in the classloader with no way to find them from the pools:
0 DEBUG [JavassistLazyInstantiationTestCase] ==== setUp org.jboss.test.kernel.lazy.test.JavassistLazyInstantiationTestCase ====
3 DEBUG [JavassistLazyInstantiationTestCase] ==== Starting testLazy ====
18 DEBUG [KernelFactory] Starting JBoss Kernel construction...
47 WARN [PropertyConfiguration] Factory: org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory at 4393722c
514 DEBUG [KernelFactory] Completed JBoss Kernel construction. Duration: 496 milliseconds
618 ERROR [AbstractKernelController] Error installing to Instantiated: name=beanProxy state=Described
java.lang.RuntimeException: Class not found: org.jboss.test.kernel.lazy.support.IRare_$$_javassist_0
at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.get(JavassistTypeInfoFactoryImpl.java:311)
at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.getTypeInfo(JavassistTypeInfoFactoryImpl.java:519)
at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory.getTypeInfo(JavassistTypeInfoFactory.java:51)
at org.jboss.classadapter.plugins.BasicClassAdapterFactory.getClassAdapter(BasicClassAdapterFactory.java:54)
In AOP what we did was to write the class bytes to the in memory vfs location from the aop classpools, so that when trying to look up the CtClass later there is a resource path for the class bytes:
URL outputURL = new URL(tempURL.toString() + "/" + classFileName);
//Write the classfile to the temporary url
synchronized (tmplock)
{
if (trace) logger.trace(this + " " + pool + ".toClass() myloader:" + myloader + " writing bytes to " + tempURL);
ByteArrayOutputStream byteout = new ByteArrayOutputStream();
BufferedOutputStream out = new BufferedOutputStream(byteout);
out.write(cc.toBytecode());
out.flush();
out.close();
byte[] classBytes = byteout.toByteArray();
MemoryContextFactory factory = MemoryContextFactory.getInstance();
factory.putFile(outputURL, classBytes);
Going to check with Chiba, but I'll see if I can modify javassist to allow ProxyFactory and ProxyFactoryHelper to accept an interface like
interface ByteRecorder{
void writeBytes(String classname, byte[]) throws IOException
}
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/534602#534602]
Start a new discussion in JBoss Microcontainer Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2115]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100330/ae00f23b/attachment.html
More information about the jboss-user
mailing list