我有一个侦听JMS队列的MDB,在onMessage()中我需要调用一个我正在使用SpringBeanAutowiringInterceptor的Spring bean。
当我将消息发布到JMS队列时,MDB实际上正在尝试加载spring应用程序上下文但是因以下错误而失败。
Caused By: org.springframework.beans.factory.access.BootstrapException:
Unable to initialize group definition. Group resource name [classpath*:beanRefContext.xml],
factory key [null]; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'parentBeanFactory' defined in URL
[zip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/factoryadaptor-1.0.0-api/4f4fxo/war/WEB-INF/lib/_wl_cls_gen.jar!/beanRefContext.xml]:
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException:
Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]:
Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'localEntityManagerFactory' defined in class path resource [beans/applicationContext-db.xml]: Invocation of init method failed;
nested exception is java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
Applicationcontext-db.xml的摘录
<tx:annotation-driven transaction-manager="jpaTransactionManager" />
<bean id="jpaTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" >
<property name="entityManagerFactory" ref="localEntityManagerFactory" />
</bean>
<bean id="localEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="DMS" />
<property name="persistenceXmlLocation" value="classpath*:config/persistence1.xml" />
</bean>
<bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
<property name="entityManagerFactory" ref="localEntityManagerFactory" />
</bean>
pom.xml的摘录如下
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc5</artifactId>
<version>11.2.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.0.Final</version>
</dependency>
正如我在hibernate-entitymanager-4.3.0.Final.jar的eclipse依赖层次结构中看到的那样,包括hibernate-jpa-2.1-api.jar。
当尝试使用Junit与DB进行交互时,相同的配置也能正常工作。当我在weblogic 12c中部署战争时,我正面临着上述问题。
有没有人面对类似的问题?
答案 0 :(得分:1)
我能够通过在weblogic.xml中提供以下内容来解决这个问题,告诉weblogic你要使用提供的hibernate(包括jpa):
<wls:prefer-application-packages>
<wls:package-name>org.hibernate.*</wls:package-name>
<wls:package-name>javax.persistence.*</wls:package-name>
<wls:package-name>javassist</wls:package-name>
</wls:prefer-application-packages>
答案 1 :(得分:0)
我认为您应该在weblogic.xml中尝试此选项
'#'