Mybatis延迟加载问题( Cannot enable lazy loading because CGLIB is not available)
2017-02-28 07:24
681 查看
错误原因:
Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.
详细描述:
org.apache.ibatis.exceptions.PersistenceException:
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:105)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:88)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:77)
… 25 more
Caused by: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.
at org.apache.ibatis.session.Configuration.setLazyLoadingEnabled(Configuration.java:211)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.settingsElement(XMLConfigBuilder.java:197)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:99)
… 27 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: net.sf.cglib.proxy.Enhancer
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:188)
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:87)
at org.apache.ibatis.io.Resources.classForName(Resources.java:250)
at org.apache.ibatis.session.Configuration.setLazyLoadingEnabled(Configuration.java:209)
… 29 more
解决方案:
原因是因为少了cglib.jar,而cglib.jar有引入了asm.jar,所以,这两个jar包都需要导入。然后再次编译测试就可以了。
Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.
详细描述:
org.apache.ibatis.exceptions.PersistenceException:
Error building SqlSession.
The error may exist in SQL Mapper Configuration
Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:79) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:63) at cn.wzk.mapper.OrdersMapperCustomTest.setUp(OrdersMapperCustomTest.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:105)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:88)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:77)
… 25 more
Caused by: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.
at org.apache.ibatis.session.Configuration.setLazyLoadingEnabled(Configuration.java:211)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.settingsElement(XMLConfigBuilder.java:197)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:99)
… 27 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: net.sf.cglib.proxy.Enhancer
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:188)
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:87)
at org.apache.ibatis.io.Resources.classForName(Resources.java:250)
at org.apache.ibatis.session.Configuration.setLazyLoadingEnabled(Configuration.java:209)
… 29 more
解决方案:
原因是因为少了cglib.jar,而cglib.jar有引入了asm.jar,所以,这两个jar包都需要导入。然后再次编译测试就可以了。
相关文章推荐
- mybatis 异常处理Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not
- Cannot proxy target class because CGLIB is not available. Add CGLIB to the class path or specify pr
- 在MOSS2007上加载工作流出现以下错误:“The form cannot be displayed because session state is not available”
- FW:BIZTALK: Cannot perform encryption or decryption because the secret is not available from the master secret server
- The request lifetime scope cannot be created because the HttpContext is not available
- Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space.
- Microsoft Office Excel cannot open or save any more documents because there is not enough available
- FW: BIZTALK: Cannot perform encryption or decryption because the secret is not available from the master secret server
- mybatis 错误CGLIB is not available
- Python3下的ssl certificate:Can't connect to HTTPS URL because the SSL module is not available.问题解决
- BIZTALK: Cannot perform encryption or decryption because the secret is not available from the master secret server
- [转]BIZTALK: Cannot perform encryption or decryption because the secret is not available from the master secret server
- "is not fixed because of errors" 表索引问题处理
- Servlet action is not available问题
- The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the ser
- "The requested resource (... processLogin.action) is not available"的问题所在及解决办法
- hibernate延迟加载的传说级错误org.hibernate.LazyInitializationException: could not initialize proxy - no Session
- Servlet action is not available 问题解决
- The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 010
- [Resolution]Your search cannot be completed because this site is not assigned to an indexer