Announcement Announcement Module
Collapse
No announcement yet.
Illegal type in constant pool Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Illegal type in constant pool

    I can't for the life of me figure this one out. When I enable LTW using:

    -javaagent:C:/temp/aspectjweaver-1.5.3.jar
    and by putting aop.xml in my webroot/META-INF

    Hibernate (and commons-logging) both throw a java.lang.VerifyError stating that the method: readResolve signature has an Illegal type in constant pool. The class in question is org.hibernate.impl.SessionFactoryImpl. I've checked and I only have one version of that class on the classpath. And if I turn off the LTW JVM flag the app starts without a hitch. (The exception is below). If I include jakarta commons-logging in my app it gives a similar error.

    Anyone seen this before? I really want/need AspectJ support but I'm stumped!

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'transactionManager' defined in class path resource [mshare/persist/hibernate/applicationContext-hibernate.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [mshare/persist/hibernate/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is java.lang.VerifyError: (class: org/hibernate/impl/SessionFactoryImpl, method: readResolve signature: ()Ljava/lang/Object Illegal type in constant pool
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [mshare/persist/hibernate/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is java.lang.VerifyError: (class: org/hibernate/impl/SessionFactoryImpl, method: readResolve signature: ()Ljava/lang/Object Illegal type in constant pool
    Caused by: java.lang.VerifyError: (class: org/hibernate/impl/SessionFactoryImpl, method: readResolve signature: ()Ljava/lang/Object Illegal type in constant pool
    at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1294)
    at org.springframework.orm.hibernate3.LocalSessionFac toryBean.newSessionFactory(LocalSessionFactoryBean .java:805)
    at org.springframework.orm.hibernate3.LocalSessionFac toryBean.buildSessionFactory(LocalSessionFactoryBe an.java:745)
    at org.springframework.orm.hibernate3.AbstractSession FactoryBean.afterPropertiesSet(AbstractSessionFact oryBean.java:134)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1143)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1110)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:431)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 54)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:144)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:251)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:163)

  • #2
    I've run into the same issue running under Tomcat 5.5. Adding the jars to the bootclasspath resolves the problem but that doesn't seem like the correct approach.
    Were you able to resolve the problem?
    Last edited by rjivan; Mar 27th, 2007, 12:29 PM.

    Comment


    • #3
      Could it be that different versions of the same jars are lying around somewhere? If putting them in the bootclasspath did resolve the problem, this could be because they are loaded first in any case.

      Regards,
      Andreas

      Comment


      • #4
        I verified that there are no other jars in the classpath. I believe Tomcat has a version of Common Logging that it uses internally which maybe conflicting with the version I have bundled in the war.

        Comment


        • #5
          What's in your aop.xml?

          Comment


          • #6
            This is it. I have pretty much followed the steps outline in the blog http://chris-richardson.blog-city.co...es_into_en.htm
            <aspectj>
            <weaver options="-verbose">
            <include within="com.xxxx.domain.*" />
            <exclude within="*..*CGLIB*" />
            </weaver>
            </aspectj>

            Comment


            • #7
              Try using the most up-to-date instructions on how to do that:
              Using AspectJ with Spring applications

              One difference is that the bean is defined with scope="prototype". In the blog the scope of the "pendingOrder" bean is left unspecified (defaults to "singleton").

              Comment


              • #8
                Found reason in my case

                Was just running into same problem with a lucene jar.

                We recently upgraded to 2.1 and started seeing this. It turns out if you have another jar version in another webapp Context it will cause this.

                We had another webapp with an older lucene jar. Killed the old webapp. New webapp deployed fine.

                This is somewhat suboptimal however. There may be cases when something like this is unavoidable. Is there anyway to avoid this classloader clashing? I'm not even sure if it's a aspectj, tomcat, spring or java thing. All I know is that I hate the whole java classloader framework completely now.

                We should certainly put this caveat in the docs, I'd recommend the Spring docs as it's probably where most people are first jumping into aspectj from these days.

                -kyri

                Comment


                • #9
                  The problem started reappearing for us. Even without jar version clashes between tomcat webapps. So if anyone else has any experience solving this Illegal type in Constant pool with deploying an AOP app using LTW in tomcat please add to this Thread. We've had to abandon our use of @Configurable, and my team has soured on AOP in general.

                  Comment


                  • #10
                    solution lies in aop.xml

                    Hi,

                    I just had the same problem, it was caused by the fact that I didn't have an aop.xml in my META-INF.

                    If you don't have this all classes will be instrumented while generally you will only be interested in instrumenting your domain classes. Apparantly the hibernate session factory doewn't like to be instrumented! ;-)

                    here is what i added to solve the problem (in META-INF/aop.xml):

                    <!DOCTYPE aspectj PUBLIC
                    "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">

                    <aspectj>
                    <!--<weaver
                    options="-showWeaveInfo
                    -XmessageHandlerClass:org.springframework.aop.aspec tj.AspectJWeaverMessageHandler">-->
                    <weaver>
                    <include within="com.<yourdomain>.<yourapp>.domain..*"/>
                    </weaver>
                    </aspectj>

                    Hope this helps other people

                    rgds

                    Joost

                    Comment


                    • #11
                      hello!

                      i have exactly the same problem! My aop.xml looks like that:
                      Code:
                      <?xml version="1.0" encoding="UTF-8"?>
                      <!--  <!DOCTYPE aspectj  SYSTEM "/home/devuser/workspace/NDBJS_Re7/WebContent/WEB-INF/aspectj.dtd"> -->
                      
                      <!DOCTYPE aspectj PUBLIC    
                        "-//AspectJ//DTD//EN"    "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">    
                      
                      <aspectj>   
                        <weaver 
                          options="-showWeaveInfo -XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler">
                          <include within="najsre7..*"/>
                        </weaver> 
                        
                        <aspects>
                          <include within="org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"/>
                        </aspects> 
                      </aspectj>
                      Exception:
                      Code:
                      java.lang.VerifyError: (class: org/hibernate/impl/SessionFactoryImpl, method: readResolve signature: ()Ljava/lang/Object;) Illegal type in constant pool
                      	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
                      	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:728)
                      Any ideas?
                      Angela

                      Comment


                      • #12
                        I do have a include within in there, but only in the META-INF of the main application war. In addition I have many other jar files that don't have aop.xml in their META-INFs and the war references these. I thought the main aop.xml from war would prevent the weaving of those too.

                        I try adding aop.xml to all my jars, and let you know what happens.

                        Comment


                        • #13
                          Hey there!

                          I have the same problem. First i had it with Log4j. Using the same log4j.jar file in ${catalina.home}/common/lib and in my webapp solved the problem with Log4j. But now i have the same error with hibernate as you have. Does anyone has found a solution for that? By now i'm sitting for three days on the error. Using a workaround instead of AspectJ would make my domain model very ugly. Maybe some of the Spring Guys have an answer?

                          Thanks in advance!

                          Regards Torben

                          Comment


                          • #14
                            Anybody got past this?

                            I'm using spring 2.1-m4 and getting the Illegal type in constant pool while creating the session factory.

                            Comment


                            • #15
                              jwijgerd,

                              Life saver answer I was missing the META-INF/aop.xml in my deployment and all the classes in the server were being process of course hibernate jar was different in the server. java.lang.VerificationError if you get that exception make sure your aop.xml is deployed.


                              Fabio

                              Comment

                              Working...
                              X