weblogic上的spring数据jpa抛出:java.lang.illegalargumentexception:本地化消息键:类型未管理

llycmphe  于 2021-07-23  发布在  Java
关注(0)|答案(0)|浏览(265)

我以前也看到过类似的问题,但没有解决我的问题。
你可以从github派生这个项目
我使用的是weblogic12.4.2、spring 4.0.4、maven 3.6、openjpa2.4.2、springdata 1.1.6和eclipseide2020-06。
我必须在weblogic(完全JavaEE环境)上部署我的应用程序,因此,正如SpringDocks 13.5.1.2从jndi获得entitymanagerfactory所说,我使用,

<jee:jndi-lookup jndi-name="java:comp/env/persistence/batchEntityManagerFactory" id="emf" />

并宣布

<persistence-unit-ref>
    <persistence-unit-ref-name>persistence/batchEntityManagerFactory</persistence-unit-ref-name>
    <persistence-unit-name>batch</pe

rsistence单位名称>
在web.xml in war项目中。
这是my persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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_2_0.xsd"
            version="2.0">

            <persistence-unit name="batch" transaction-type="JTA" > 
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl </provider>
    <jta-data-source>jdbc/datasource</jta-data-source>
    <class>com.smartsoft.persistence.Person</class>
    <validation-mode>NONE</validation-mode>
      <properties>
      <property name="openjpa.jdbc.DBDictionary" value="derby(NextSequenceQuery=VALUES NEXT VALUE FOR {0})"/>
    <!--  <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>-->
      <property name="openjpa.Log" value="DefaultLevel=TRACE"/>
      <property name="openjpa.TransactionMode" value="managed"/>
     <property name="openjpa.Connection2UserName" value="app"/>
    <property name="openjpa.Connection2Password" value="app"/>
    <property name="openjpa.Connection2URL" value="jdbc:derby://localhost:1527/testdb;create=false"/>
    <property name="openjpa.Connection2DriverName" value="org.apache.derby.jdbc.ClientDriver"/>
    </properties>
  </persistence-unit>
</persistence>

这是spring的xml配置:

<beans
//xml name spaces
<context:component-scan base-package="com.smartsoft.persistence"/>
<context:annotation-config/>
<aop:aspectj-autoproxy/>
<tx:annotation-driven/>
<tx:jta-transaction-manager/>
  <jee:jndi-lookup jndi-name="java:comp/env/persistence/batchEntityManagerFactory" id="emf" />
<jpa:repositories base-package="com.smartsoft.persistence" entity-manager-factory-ref="entityManagerFactory" consider-nested-repositories="true"  />
</beans>

在用@startup注解的单例ejb中,我初始化spring上下文。

context = new ClassPathXmlApplicationContext("applicationContext.xml");

我有一个人实体:

@Entity
public class Person {
    @SequenceGenerator(name="sec1", sequenceName="mysequence" )
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="sec1")
    private long id;
    private String firstName;
    private String lastName;
private int age;
// simple getters and setters

}
以及一个简单的dao存储库,它扩展了spring的jpa存储库。

public interface DaoRepository<T, ID extends Serializable> extends JpaRepository<T, Serializable> {

}

在另一个bean中,我调用daosrepository.save并向其传递一个新人。

public Person savePerson(Person person) {
    logger.info("person has been persisted successfully");
    return repo.save(person);
}

weblogic.application.ModuleException: java.lang.IllegalArgumentException: localized message key: type-not-managed; substitutions: [class java.lang.Object]
    at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
    Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalArgumentException: localized message key: type-not-managed; substitutions: [class java.lang.Object]
    at org.apache.openjpa.persistence.meta.MetamodelImpl.managedType(MetamodelImpl.java:192)
    at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:67)
    at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:65)
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:149)
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:88)
    Truncated. see log file for complete stacktrace
>

任何帮助都将受到感谢。谢谢你。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题