JPA(Toplink) Error : Object: xxxxxx is not a known entity type. 解决
2009-07-28 12:37
344 查看
出错可能的原因如下:
问题出在:<property name="loadTimeWeaver">上。
更改配置方法:注掉loadTimeWeaver,使用<context:load-time-weaver/>标签即可。
注意:tomcat服务器下需要把Spring包下:spring-tomcat-weaver.jar拷贝到Tomcat的lib里,并在/conf/Catalina/localhost下追加形如下面的配置文件:xxxx(工程wen路径).xml
或者参考官方的配置方式:
测试过程中发现,当使用tomcat 6.0.20时,在工程目录(src同级)下META-INF中追加context.xml文件,文件内容即为上诉xxxx(工程wen路径).xml文件,在MyEclipse中发布时会自动被加载到相应目录。
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:dataSource-ref="dataSource" p:persistenceUnitName="jpaToplinkPersistenceUnit"> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter" p:showSql="true" p:generateDdl="true" p:databasePlatform="oracle.toplink.essentials.platform.database.HSQLPlatform" /> </property> <property name="loadTimeWeaver"> <bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver"/> </property> </bean>
问题出在:<property name="loadTimeWeaver">上。
更改配置方法:注掉loadTimeWeaver,使用<context:load-time-weaver/>标签即可。
注意:tomcat服务器下需要把Spring包下:spring-tomcat-weaver.jar拷贝到Tomcat的lib里,并在/conf/Catalina/localhost下追加形如下面的配置文件:xxxx(工程wen路径).xml
<Context path="/xxxx" reloadable="false"> <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false"/> </Context>
或者参考官方的配置方式:
3. JPA ON TOMCAT Notes on using the Java Persistence API (JPA) on Apache Tomcat 4.x or higher, with a persistence provider that requires class instrumentation (such as TopLink Essentials): To use JPA class instrumentation, Tomcat has to be instructed to use a custom class loader which supports instrumentation. See the JPA section of the Spring reference manual for complete details. The basic steps are: - Copy "spring-tomcat-weaver.jar" from the Spring distribution to "TOMCAT_HOME/server/lib". - If you're running on Tomcat 5.x, modify "TOMCAT_HOME/conf/server.xml" and add a new "<Context>" element for 'petclinic' (see below). You can alternatively deploy the WAR including "META-INF/context.xml" from this sample application's "war" directory. <Context path="/petclinic" docBase="/petclinic/location" ...> <!-- please note that useSystemClassLoaderAsParent is available since Tomcat 5.5.20; remove it if previous versions are being used --> <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false"/> ... </Context>
测试过程中发现,当使用tomcat 6.0.20时,在工程目录(src同级)下META-INF中追加context.xml文件,文件内容即为上诉xxxx(工程wen路径).xml文件,在MyEclipse中发布时会自动被加载到相应目录。
相关文章推荐
- Spring + toplink-essentials(JPA) is not a known entity type 问题解决
- Python 出现错误TypeError: ‘NoneType’ object is not iterable解决办法
- Sea.js出现Uncaught TypeError: object is not a function的解决方法
- 解决Uncaught TypeError: object is not a function
- chrome浏览器Uncaught TypeError: object is not a function问题解决
- python2.7web代码用python3.6运行时,浏览器发送请求报错TypeError: Object of type 'bytes' is not JSON serializable的解决办法
- chrome浏览器Uncaught TypeError: object is not a function问题解决
- chrome浏览器Uncaught TypeError: object is not a function问题解决
- [已解决]TypeError: 'module' object is not callable
- Hyperopt TypeError: 'generator' object is not subscriptable
- Uncaught TypeError: object is not a function
- error Type referred to is not an annotation type 一个解决办法
- Scrapy使用shell命令报错scrape shell TypeError: 'float' object is not iterable
- TypeError: 'bool' object is not callable
- chrome浏览器Uncaught TypeError: object is not a function问题
- chrome浏览器Uncaught TypeError: object is not a function问题
- TypeError: a bytes-like object is required, not 'str'
- TypeError: Object of type 'float32' is not JSON serializable
- python的exit退出时,提示TypeError: 'str' object is not callable
- jQuery Validation插件onfocosout/onkeyup出错的解决方法[Uncaught TypeError: undefined is not a function中文资料不好找]