Announcement Announcement Module
Collapse
No announcement yet.
spring-agent context level loading throws Unknown entity exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring-agent context level loading throws Unknown entity exception

    My spring/jpa web application which run in side tomcat server.
    It was run perfectly when we did loadtime weaving in tomcat catalina.sh file as global level.

    configurations as follows:
    .(-javaagent:"C:\apache-tomcat-6.0\spring-agent.jar)


    spring-config.xml

    <bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="persistenceUnitName"
    value="abpersists" />
    <property name="dataSource" ref="dataSource" />
    <property name="jpaVendorAdapter">
    <bean
    class="org.springframework.orm.jpa.vendor.TopLinkJ paVendorAdapter">
    <property name="showSql" value="true" />
    <property name="generateDdl" value="true" />
    <property name="databasePlatform"
    value="oracle.toplink.essentials.platform.database .MySQL4Platform" />
    </bean>
    </property>
    <property name="loadTimeWeaver">
    <bean
    class="org.springframework.instrument.classloading .InstrumentationLoadTimeWeaver" />
    </property>
    </bean>


    persistence.xml file :

    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">

    <persistence-unit name="abpersists" transaction-type="RESOURCE_LOCAL">
    <provider>oracle.toplink.essentials.ejb.cmp3.Entit yManagerFactoryProvider</provider>

    <class>com.abc.data.User</class>
    <class>com.abc.data.Customer</class>
    ....................................
    </persistence-unit>

    </persistence>



    Later i change the JAVA_OPT to application context level, so for it i did the following changes:


    1.catalina.sh JAVA_OPT for spring-agent.jar was removed. and bring it to context level

    2.<Context path="/abc-service" docBase="C:\apache-tomcat-6.0.20\abc\abc-service.war"
    debug="0" privileged="true">
    <Loader loaderClass="org.springframework.instrument.classl oading.tomcat.TomcatInstrumentableClassLoader"/>
    </Context>

    3.spring config file loadtime weaver changed to following:
    <property name="loadTimeWeaver">
    <bean class="org.springframework.instrument.classloading .ReflectiveLoadTimeWeaver"/>
    </property>

    All beans marked with @Entity annotation.

    @Entity
    @Table (name = "USER")
    public class User implements Serializable {

    ....

    }

    data base is mysql,it uses mysql-connector-java-5.1.13-bin.jar and uses spring 2 version.
    persistence.xml is inside META-INF of the jar which contains entity beans.
    after the change when application connect to db successfully and try to execute loading entities it throws the following error


    java.lang.IllegalArgumentException: Unknown entity bean class: class com.abc.data.User, please verify that this class has been marked with the @Entity annotation.

    Thanks in advance, any help highly appreciated.
Working...
X