These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Issue with CGLib and Hibernate
PostPosted: Wed Jan 30, 2008 2:41 am 
Newbie

Joined: Tue Jan 29, 2008 2:30 am
Posts: 7
Hi,

I am using Weblogic10, Hibernate-3.2.5.ga, Spring-2.5.1 and cglib-2.1_3.

My application is currently being deployed as an ear, containing a jar and a rar. The structure is as follows:

project.ear
|- project.jar
|- project.rar
|- spring.jar
|- hibernate.jar
|- cglib.jar

My Resource Adapter xml looks as follows:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<connector
  xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
  version="1.5">
  <display-name>GT_OUT</display-name>
  <vendor-name>Spring Framework</vendor-name>
  <eis-type>Spring Connector</eis-type>
  <resourceadapter-version>1.0</resourceadapter-version>
  <resourceadapter>
    <resourceadapter-class>org.springframework.jca.context.SpringContextResourceAdapter</resourceadapter-class>
    <config-property>
      <config-property-name>ContextConfigLocation</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>
        classpath:spring-applicationContext.xml,
        classpath:spring-datasources.xml,
        classpath:spring-messaging.xml,
        classpath:spring-persistence.xml,
        classpath:spring-transactions.xml
      </config-property-value>
    </config-property>
  </resourceadapter>
</connector>


The spring application contexts live in project.jar. The manifest files for both project.jar and project.rar looks as follows:

Code:
Manifest-Version: 1.0
Class-Path:
  hibernate-entitymanager-3.3.1.ga.jar
  hibernate-commons-annotations-3.0.0.ga.jar
  hibernate-annotations-3.3.0.ga.jar
  gtout-core-1.0-SNAPSHOT.jar
  concurrent-1.3.4.jar
  javassist-3.3.ga.jar
  hibernate-3.2.5.ga.jar
  cglib-2.1_3.jar
  asm-1.5.3.jar
  asm-attrs-1.5.3.jar
  spring-2.5.1.jar


When I deploy the EAR, the RAR is correctly loaded and configuration begins via spring. I have an EntityManager defined in a spring file as:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="jpaVendorAdapter"
    class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
    p:databasePlatform="org.hibernate.dialect.HSQLDialect"/>

  <bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
    p:dataSource-ref="datasource"
    p:jpaVendorAdapter-ref="jpaVendorAdapter"/>

</beans>


When this bean is being initialized I am receiving the following exception:
Code:
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
   at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
   at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
   at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:127)
   at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
   at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
   at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
   at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
   at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
   at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
   at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
   at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
   at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:221)
   at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1288)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1257)
   ... 59 more
Caused by: java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
   at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
   ... 80 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
   ... 86 more


I've looked around and noticed that CGLib perhaps runs in different classloader???
Looking at the stacktrace, it can be seen that Hibernate is on the classpath as some of its classes are being used, which in turn calls cglib. Cglib then tries to call Hibernate but cant find it!? I dont get it ...

Any help would be great!!

Cheers

Ryan


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.