Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Illegal type in constant pool

  1. #1
    Join Date
    Nov 2004
    Posts
    17

    Default 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. #2
    Join Date
    Mar 2007
    Posts
    13

    Default

    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 at 12:29 PM.

  3. #3
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    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

  4. #4
    Join Date
    Mar 2007
    Posts
    13

    Default

    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.

  5. #5
    Join Date
    Aug 2006
    Location
    Brooklyn
    Posts
    556

    Default

    What's in your aop.xml?

  6. #6
    Join Date
    Mar 2007
    Posts
    13

    Default

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

  7. #7
    Join Date
    Aug 2006
    Location
    Brooklyn
    Posts
    556

    Default

    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").

  8. #8

    Default 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

  9. #9

    Default

    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.

  10. #10
    Join Date
    May 2007
    Posts
    17

    Default 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •