您的位置:首页 > 移动开发 > Objective-C

JPA(Toplink) Error : Object: xxxxxx is not a known entity type. 解决

2009-07-28 12:37 344 查看
出错可能的原因如下:

<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中发布时会自动被加载到相应目录。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: