1 Reply Latest reply on Apr 26, 2010 6:27 AM by kabirkhan

    JBREFLECT-6 Skipping compilation step

    flavia.rainone

      Adrian,

      As I was studying JBoss Reflect issues, I stumbled upon https://jira.jboss.org/jira/browse/JBREFLECT-6 and I got curious about it :)

      "adrian@jboss.org" wrote:
      The JavassistReflectionFactory builds up a source to compile the method, constructor and field accesors.
      These implementations are faster than the normal reflection equivalents, but using the compiler is slow.
      These methods should be optimized to generate the bytecode directly.


      Currently, the whole Javassist API uses Java code and compiles that code for instrumentation. So, do you mean to extend Javassist API so it accepts bytecode instructions as an option over Java code?

        • 1. Re: JBREFLECT-6 Skipping compilation step
          kabirkhan

          Having revisited how the classpools are set up (http://community.jboss.org/thread/151095) which became apparent after looking into (http://community.jboss.org/message/538568#538568) I got some problems when starting AS:

           

          10:59:48,915 WARN  [PropertyConfiguration] Factory: org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory@55ad6c98
          XmlRootElement java.net.URLClassLoader@9a082e2
          Failed to boot JBoss:
          java.lang.Exception: Encountered exception in server startup
          at org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase.bootstrapMcAndDescriptors(AbstractMCServerBase.java:360)
          at org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase.doStart(AbstractMCServerBase.java:292)
          at org.jboss.bootstrap.impl.as.server.AbstractJBossASServerBase.doStart(AbstractJBossASServerBase.java:381)
          at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:413)
          at java.lang.Thread.run(Thread.java:637)
          Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: java.lang.RuntimeException: Error retrieving annotation attribute values
          at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:195)
          at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:175)
          at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:161)
          at org.jboss.bootstrap.impl.mc.deployer.TempBasicXMLDeployer.deploy(TempBasicXMLDeployer.java:188)
          at org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase.bootstrapMcAndDescriptors(AbstractMCServerBase.java:345)
          ... 4 more
          Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Error retrieving annotation attribute values
          at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.getAnnotations(JavassistTypeInfoFactoryImpl.java:699)
          at org.jboss.reflect.plugins.javassist.JavassistInheritableAnnotationHolder.getAnnotations(JavassistInheritableAnnotationHolder.java:78)
          at org.jboss.reflect.plugins.javassist.JavassistTypeInfo.getAnnotations(JavassistTypeInfo.java:790)
          at org.jboss.reflect.plugins.javassist.JavassistInheritableAnnotationHolder.getAnnotation(JavassistInheritableAnnotationHolder.java:91)
          at org.jboss.reflect.plugins.AbstractAnnotatedInfo.getUnderlyingAnnotation(AbstractAnnotatedInfo.java:55)
          at org.jboss.xb.builder.JBossXBBuilder.initSchema(JBossXBBuilder.java:351)
          at org.jboss.xb.builder.JBossXBNoSchemaBuilder.build(JBossXBNoSchemaBuilder.java:271)
          at org.jboss.xb.builder.JBossXBBuilder.build(JBossXBBuilder.java:336)
          at org.jboss.xb.builder.JBossXBBuilder.build(JBossXBBuilder.java:222)
          at org.jboss.xb.builder.JBossXBBuilder.build(JBossXBBuilder.java:201)
          at org.jboss.xb.binding.resolver.AbstractMutableSchemaResolver.resolve(AbstractMutableSchemaResolver.java:315)
          at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:177)
          at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.startElement(SaxJBossXBParser.java:370)
          at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
          at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
          at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
          at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
          at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
          at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
          at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
          at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
          at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
          at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
          at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
          at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:191)
          ... 8 more
          Caused by: java.lang.RuntimeException: Error retrieving annotation attribute values
          at org.jboss.reflect.plugins.AnnotationValueFactory.createAnnotationValue(AnnotationValueFactory.java:124)
          at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.getAnnotations(JavassistTypeInfoFactoryImpl.java:693)
          ... 32 more
          Caused by: java.lang.RuntimeException: Error creating JavassistMethod for javax.xml.bind.annotation.XmlRootElement with classloader sun.misc.Launcher$AppClassLoader@517590db
          at org.jboss.reflect.plugins.javassist.bytecode.JavassistMemberFactory.toClass(JavassistMemberFactory.java:316)
          at org.jboss.reflect.plugins.javassist.bytecode.JavassistMemberFactory.makeClass(JavassistMemberFactory.java:289)
          at org.jboss.reflect.plugins.javassist.bytecode.JavassistMemberFactory.createJavassistMethod(JavassistMemberFactory.java:197)
          at org.jboss.reflect.plugins.javassist.JavassistReflectionFactory.createMethod(JavassistReflectionFactory.java:200)
          at org.jboss.reflect.plugins.javassist.JavassistMethodInfo.invoke(JavassistMethodInfo.java:114)
          at org.jboss.reflect.plugins.SecurityActions.invokeMethod(SecurityActions.java:78)
          at org.jboss.reflect.plugins.AnnotationValueFactory.createAnnotationValue(AnnotationValueFactory.java:117)
          ... 33 more
          Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError: org/jboss/reflect/plugins/javassist/JavassistMethod
          at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:169)
          at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:136)
          at org.jboss.reflect.plugins.javassist.bytecode.JavassistMemberFactory.toClass(JavassistMemberFactory.java:298)
          ... 39 more
          Caused by: java.lang.NoClassDefFoundError: org/jboss/reflect/plugins/javassist/JavassistMethod
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:698)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:544)
          at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at javassist.util.proxy.FactoryHelper.toClass2(FactoryHelper.java:181)
          at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:163)
          ... 41 more
          Caused by: java.lang.ClassNotFoundException: org.jboss.reflect.plugins.javassist.JavassistMethod
          at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
          ... 49 more
          
          
          

           

          This turned out to be due to javax.xml.bind.annotation.XmlRootElement coming from the system classloader while the jboss-reflect classes coming from a child classloader. It was set up to always use the classloader of the class we are creating an accessor for. I have changed it to still do that apart from if the class comes from a parent classloader of the jboss-reflect one, in which case we use the jboss-reflect classloader.