我得到了
java.lang.NoSuchMethodError: javax.persistence.EntityManager.createStoredProcedureQuery(Ljava/lang/String;)Ljavax/persistence/StoredProcedureQuery;
请帮助,我的配置有什么问题。
在我的代码中执行此行。
StoredProcedureQuery spq =em.createStoredProcedureQuery("User_pkg.Store_user_proc);
DB Procedure有5个输入和1个整数输出参数。
我试过了
How to enable Weblogic 12.1.2 JPA 2.1
并且
https://docs.oracle.com/middleware/1213/wls/EJBAD/using_toplink.htm#EJBAD1510
启动weblogic服务器时,我能够看到加载JPA2.1的jar文件
JAVA内存参数
JAVA Memory arguments: -Xms256m -Xmx512m -XX:CompileThreshold=8000
-XX:PermSize=128m -XX:MaxPermSize=256m
CLASSPATH
CLASSPATH = \ oracle_common \模块\ javax.persistence_2.1.jar; \ wlserver的\模块\ com.oracle.weblogic.jpa21support_1.0.0.0_2-1; C:\ PROGRA〜1 \爪哇\ JDK18〜1.0_1 \ lib中\的tools.jar; F:\的WebLogic \ wlserver的\服务器\ lib中\ weblogic_sp.jar; F:\的WebLogic \ wlserver的\服务器\ lib中\ weblogic.jar中; F:\的WebLogic \ oracle_common \模块\ net.sf。 antcontrib_1.1.0.0_1-0b3 \ lib中\蚂蚁contrib.jar; F:\的WebLogic \ wlserver的\模块\设有\ oracle.wls.common.nodemanager_2.0.0.0.jar; F:\的WebLogic \ oracle_common \模块\ com.oracle.cie.config-WLS-online_8.1.0.0.jar; F:\的WebLogic \ wlserver的\共同\德比\ lib中\ derbynet.jar; F:\的WebLogic \ wlserver的\共同\德比\ lib中\ derbyclient。罐; F:\的WebLogic \ wlserver的\共同\德比\ lib中\的derby.jar; F:\的WebLogic \ wlserver的\服务器\ lib中\ xqrl.jar
PATH
PATH =; F:\的WebLogic \ wlserver的\服务器\天然\赢\ 64; F:\的WebLogic \ wlserver的\服务器\ BIN; F:\的WebLogic \ oracle_common \模块\ org.apache.ant_1.9.2 \仓; C:\ PROGRA〜1 \爪哇\ JDK18〜1.0_1 \ JRE \ BIN; C:\ PROGRA〜1 \爪哇\ JDK18〜1.0_1 \ BIN; C:\ PROGRA〜3 \甲骨文\爪哇\ javapath; F: \ ORACLE \产品\ 112〜1.0 \ dbhome_1 \ BIN; C:\ PROGRA〜2 \ HPSIMP〜1 \ 64; C:\ PROGRA〜2 \ HPSIMP〜1 \; C:\ PROGRA〜2 \英特尔\ ICLSCL〜1 \; C:\ PROGRA〜1 \英特尔\ ICLSCL〜1 \; C:\ Windows \ System32下; C:\视窗; C:\ Windows \ System32下\ WBEM; C:\ Windows \ System32下\ WINDOW〜1个\ V1。 0 \; C:\ PROGRA〜2 \ WIC4A1〜1 \共享; C:\ PROGRA〜2 \英特尔\ OPENCL〜1个\ 3.0 \ BIN \ 86; C:\ PROGRA〜2 \英特尔\ OPENCL〜1 \ 3.0 \ BIN \ 64; C:\ PROGRA〜1 \英特尔\ INTEL(〜1 \ DAL; C:\ PROGRA〜1 \英特尔\ INTEL(〜1 \ IPT; C:\ PROGRA〜2 \英特尔\ INTEL(〜2 \ DAL; C:\ PROGRA〜2 \英特尔\ INTEL(〜2 \ IPT; C:\ PROGRA〜1 \腻子\; C:\ Android的; C:\ Windows \ System32下; F:\蚂蚁\ APACHE〜1.2-B \ APACHE〜1.2; C:\ PROGRA〜1 \ jEdit的; C:\ PROGRA〜1 \爪哇\ JDK18〜1.0_1 \ BIN; C:\用户\哈里斯〜1 \应用程序数据\本地\ MICROS〜1个\ WINDOW〜1 ; F:\蚂蚁\ APACHE〜1.2-B \ APACHE〜1.2 \ BIN; F:\的WebLogic \ wlserver的\服务器\天然\赢\ 64 \ oci920_8
JPA: EclipseLink 2.7.1
Weblogic Server配置。 版本:WebLogic Server 12.1.3.0.0 用Java版本启动weblogic: java版“1.8.0_144” Java(TM)SE运行时环境(版本1.8.0_144-b01) Java HotSpot(TM)64位服务器VM(版本25.144-b01,混合模式)
的pom.xml
<i>
{
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springmaven</groupId>
<artifactId>springfort</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>springfort Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Servlet Library -->
<!--http://mvnrepository.com/artifact/javax.servlet/javax.servletapi%20->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Spring dependencies -->
<!-- http://mvnrepository.com/artifact/org.springframework/spring-core%20-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-webmvc%20-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Spring EclipseLink JPA Dependency -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.7.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<build>
<finalName>springfort</finalName>
<plugins>
<!-- Config: Maven Tomcat Plugin -->
<!-- http://mvnrepository.com/artifact/org.apache.tomcat.maven/tomcat7-maven-plugin%20-->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<!-- Config: contextPath and Port (Default: /HelloSpringMVC : 8080) -->
<!--
<configuration>
<path>/</path>
<port>8899</port>
</configuration>
-->
</plugin>
</plugins>
</build>
</project>
}
</i>
的persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="SYSTEM" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>OracleJNDIDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<!-- List of JPA Class which has Implementation -->
<!-- <class>com.springfort.jpa.registerUserJpa</class> -->
<properties>
<property name="eclipselink.weaving" value="false"/>
<property name="eclipselink.jpa.uppercase-column-names" value="true"/>
<property name="eclipselink.logging.level" value="FINEST"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.query-results-cache" value="false"/>
<property name="eclipselink.cache.shared.default" value="false"/>
<property name="eclipselink.cache.type.default" value="NONE"/>
<property name="eclipselink.logging.level.sql" value="FINEST"/>
<property name="eclipselink.jdbc.batch-writing" value="JDBC"/>
<property name="eclipselink.jdbc.batch-writing.size" value="1000"/>
</properties>
</persistence-unit>
</persistence>
Web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>Archetype Created Web Application</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>springfort</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springfort</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
weblogic.xml中
<weblogic-web-app>
<context-root>/springfort</context-root>
<container-descriptor>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</container-descriptor>
</weblogic-web-app>
错误Stacktrace:
java.lang.NoSuchMethodError: javax.persistence.EntityManager.createStoredProcedureQuery(Ljava/lang/String;)Ljavax/persistence/StoredProcedureQuery;
at com.springfort.jpa.registerUserJpa.registerUserJpaImpl(registerUserJpa.java:40)
at com.springfort.dao.userRegistrationDaoImpl.register(userRegistrationDaoImpl.java:44)
at com.springfort.service.setUserRegistrationServiceImpl.setUserAttributes(setUserRegistrationServiceImpl.java:59)
at com.springfort.userRegistrationController.registerUser(userRegistrationController.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:180)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3432)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
答案 0 :(得分:0)
在persistence.xml中,schemaLocation是persistence_1_0.xsd
,并且对于存储过程的支持是从jpa 2.1开始的,并且这部分也在pom中:
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>