开发者

null pointer exception at org.hibernate.tuple.AbstractEntityTuplizer.createProxy

I am using hibernate 3.2 with struts 1.2 framework here is the details of versions hibenate3.2,asm-2.2.3,cglib-2.1.3 I got this exception when i m trying to load the object

I am using this code to load the object

public Currentprofile findById(java.lang.String id) {
    log.debug("getting Currentprofile instance with id: " + id);
    try {
        Currentprofile instance = (Currentprofile) getSession().get(
            "com.hibermappings.Currentprofile", id);
        return instance;
    } catch (RuntimeException re) {
        log.error("get failed", re);
        throw re;
    }
}

My hbm file is this

<hibernate-mapping>
    <class name="com.hibermappings.Currentprofile" table="currentprofile" catalog="naukrionphone">
    <id name="jobseekerId" type="java.lang.String">
        <column name="jobseekerId" length="50" />
        <generator class="assigned" />
    </id>

    <one-to-one name="referenceDb" lazy="proxy" class="com.hibermappings.ReferenceDb" cascade="all" constrained="false" /> 
    <one-to-one name="registration" lazy="proxy" class="com.hibermappings.Registration" cascade="all" constrained="false" /> 
    <one-to-one name="jobseekerpackagedetails" lazy="proxy" class="com.hibermappings.Jobseekerpackagedetails" cascade="all" constrained="false" /> 

    <property name="keyWords" type="java.lang.String">
        <column name="keyWords" length="5000" />
    </property>
    <property name="totalExp" type="java.lang.String">
        <column name="totalExp" length="100" />
    </property>
    <property name="hqualification" type="java.lang.String">
        <column name="hQualification" length="100" />
    </property>
    <property name="preferedLocation" type="java.lang.String">
        <column name="preferedLocation" length="100" />
    </property>
    <property name="functionalArea" type="java.lang.String">
        <column name="functionalArea" length="1000" />
    </property>
    <property name="expSalary" type="java.lang.String">
        <column name="expSalary" length="100" />
    </property>
    <property name="designation" type="java.lang.String">
        <column name="designation" length="100" />
    </property>
    <property name="resumeTitle" type="java.lang.String">
        <column name="resumeTitle" length="500" />
    </property>
    <property name="profileDetails" type="java.lang.String">
        <column name="profileDetails" length="65535" />
    </property>
    <property name="requiredProfile" type="java.lang.String">
        <column name="requiredProfile" length="65535" />
    </property>
    <property name="activatedOn" type="java.util.Date">
        <column name="activatedOn" length="0" />
    </property>

    <set name="resumes" inverse="true" cascade="save-update">
        <key>
            <column name="jobseekerId" length="50" />
        </key>
        <one-to-many class="com.hibermappings.Resume" />
    </set>

</class>
</hibernate-mapping>

the same code runs well when I m using in a simple java class within main method ..

full stack trace of exception is

java.lang.NullPointerException
 at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
 at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
 at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
 at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
 at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
 at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
 at org.hibernate.impl.SessionImpl.load(SessionImpl.java:781)
 at org.hibernate.impl.SessionImpl.load(SessionImpl.java:774)
 at com.DAOs.CurrentprofileDAO.getLoad(CurrentprofileDAO.java:71)
 at com.action.JobSekeerManage.viewProfile(JobSekeerManage.java:447)
 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 org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
 at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
 at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
 at com.filter.HibernateFilter.doFilter(HibernateFilter.java:24)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
 at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
 at java.lang.Thread.run(Thread.java:595)
Error::null

In my Log file I got this type of exception..

INFO - building session factory
WARN - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps/NewNaukriOnPhone/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
ERROR - CGLIB Enhancement failed: com.hibermappings.ReferenceDb
java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
 at net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)
 at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:173)
 at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
 at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
 at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
 at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
 at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
 at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
 at net.sf.cglib.proxy.Enhancer.(Enhancer.java:69)
 at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116)
 at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
 at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
 at org.hibernate.tuple.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:131)
 at org.hibernate.tuple.PojoEntityTuplizer.(PojoEntityTuplizer.java:55)
 at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
 at org.hibernate.tuple.EntityMetamodel.(EntityMetamodel.java:257)
 at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:412)
 at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:108)
 at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
 at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:216)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
 at com.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:66)
 at com.HibernateSessionFactory.getSession(HibernateSessionFactory.java:49)
 at com.DAOs.BaseHibernateDAO.getSession(BaseHibernateDAO.java:15)
 at com.DAOs.PostedprofileDAO.findByProperty(PostedprofileDAO.java:84)
 at com.admin.SendProfileAction.viewProfile(SendProfileAction.java:309)
 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 org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
 at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
 at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
 at com.filter.HibernateFilter.doFilter(HibernateFilter.java:24)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
 at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
 at java.lang.Thread.run(Thread.java:595)
WARN - could not create proxy factory for:com.hibermappings.ReferenceDb
org.hibernate.HibernateException: CGLIB Enhancement failed: com.hibermappings.ReferenceDb
 at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:132)
 at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
 at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
 at org.hibernate.tuple.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:131)
 at org.hibernate.tuple.PojoEntityTuplizer.(PojoEntityTuplizer.java:55)
 at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
 at org.hibernate.tuple.EntityMetamodel.(EntityMetamodel.java:257)
 at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:412)
 at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:108)
 at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
 at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:216)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
 at com.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:66)
 at com.HibernateSessionFactory.getSession(HibernateSessionFactory.java:49)
 at com.DAOs.BaseHibernateDAO.getSession(BaseHibernateDAO.java:15)
 at com.DAOs.PostedprofileDAO.findByProperty(PostedprofileDAO.java:84)
 at com.admin.SendProfileAction.viewProfile(SendProfileAction.java:309)
 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 org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
 at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
 at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
 at com.filter.HibernateFilter.doFilter(HibernateFilter.java:24)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
 at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
 at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
 at net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)
 at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:173)
 at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
 at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
 at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
 at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
 at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
 at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
 at net.sf.cglib.proxy.Enhancer.(Enhancer.java:69)
 at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116)
 ... 45 more
ERROR - CGLIB Enhancement failed: com.hibermappings.Companyprofile
java.lang.NoClassDefFoundError
 at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116)
 at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
 at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
 at org.hibernate.tuple.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:131)
 at org.hibernate.tuple.PojoEntityTuplizer.(PojoEntityTuplizer.java:55)
 at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
 at org.hibernate.tuple.EntityMetamodel.(EntityMetamodel.java:257)
 at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:412)
 at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:108)
 at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
 at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:216)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
 at com.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:66)
 at com.HibernateSessionFactory.getSession(HibernateSessionFactory.java:49)
 at com.DAOs.BaseHibernateDAO.getSession(BaseHibernateDAO.java:15)
 at com.DAOs.PostedprofileDAO.findByProperty(PostedprofileDAO.java:84)
 at com.admin.SendProfileAction.viewProfile(SendProfileAction.java:309)
 at开发者_JAVA技巧 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 org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
 at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
 at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
 at com.filter.HibernateFilter.doFilter(HibernateFilter.java:24)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
 at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.ru

here is the details of versions hibenate3.2,asm-2.2.3,cglib-2.1.3


If this works outside the web application, check that your mapping file is well packaged and found when the SessionFactory is created when running in container.

Update: You have a wrong version of ASM on the classpath (at least, not the one expected by CGLIB). What versions of Hibernate, ASM and CGLIB are using exactly? Are you using the JARs that ship with Hibernate? See if the solution given in this thread works for you. Another option would be to switch from CGLIB to Javassist.

Update: You need asm-1.5.3.jar with cglib-2.1.3.jar (or to replace both with cglib-nodep-2.1.3.jar, see HHH-2222). Use the JARs of Hibernate distribution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜