没有持久性提供者可用于“交易 - 可选”在尝试了以下发现的实现之后: [英] No persistence providers available for "transactions-optional" after trying the following discovered implementations:

查看:111
本文介绍了没有持久性提供者可用于“交易 - 可选”在尝试了以下发现的实现之后:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JPA 2.0创建一个Google App Engine - GAE,我已经遵循了所有需要的步骤,将正确的jar放入classpath并确保我的实体得到增强。
但是我在创建我的EntityManager时遇到了问题。

I am trying to create a Google App Engine - GAE with JPA 2.0, I have followed all I need to, putting the correct jars in classpath and making sure my Entities are enhanced. But I am having problems creating my EntityManager.

我的persistence.xml如下所示:

My persistence.xml looks like this:

<?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_1_0.xsd" version="1.0">
    <persistence-unit name="transactions-optional">    
        <provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>       
        <properties>
            <property name="datanucleus.NontransactionalRead" value="true"/>
            <property name="datanucleus.NontransactionalWrite" value="true"/>
            <property name="datanucleus.ConnectionURL" value="appengine"/>
        </properties>
    </persistence-unit>
</persistence>

我的Datanuclues pom依赖关系如下所示:

My Datanuclues pom dependecy looks like this:

  <datanucleus.version>3.1.1</datanucleus.version> 
            <!-- DN -->
    <dependency>
        <groupId>com.google.appengine.orm</groupId>
        <artifactId>datanucleus-appengine</artifactId>
        <version>2.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-core</artifactId>
        <version>${datanucleus.version}</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-api-jpa</artifactId>
        <version>${datanucleus.version}</version>
    </dependency>

    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-api-jdo</artifactId>
        <version>${datanucleus.version}</version>
    </dependency>

<plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>maven-datanucleus-plugin</artifactId>
                <version>${datanucleus.version}</version>
                <configuration>
                    <api>JPA</api>
                    <verbose>true</verbose>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

我得到:

I get:

C:\dev\projects\org\me\workspace\lottoshop>mvn gae:run
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building GWT Maven Archetype
[INFO]    task-segment: [gae:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing gae:run
[INFO] Preparing gae:unpack
[WARNING] Removing: unpack from forked lifecycle, to prevent recursive invocation.
[INFO] No goals needed for project - skipping
[INFO] artifact org.datanucleus:datanucleus-enhancer: checking for updates from nexus-releases-repository
[WARNING] repository metadata for: 'artifact org.datanucleus:datanucleus-enhancer' could not be retrieved from repository: nexus-releases-repository due to an error: Error transferring file: nexus.tatis.com
[INFO] Repository 'nexus-releases-repository' will be blacklisted
[INFO] artifact org.datanucleus:datanucleus-enhancer: checking for updates from nexus-snapshots-repository
[WARNING] repository metadata for: 'artifact org.datanucleus:datanucleus-enhancer' could not be retrieved from repository: nexus-snapshots-repository due to an error: Error transferring file: nexus.tatis.com
[INFO] Repository 'nexus-snapshots-repository' will be blacklisted
[INFO] [gae:unpack {execution: start-gae}]
[INFO] Found appengine-java-sdk 1.7.5.
[INFO] [gwt:i18n {execution: default}]
[INFO] [gwt:generateAsync {execution: default}]
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT\WEB-INF\classes
[INFO] [war:exploded {execution: default}]
[INFO] Exploding webapp
[INFO] Assembling webapp [lottoshop] in [C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\dev\projects\org\me\workspace\lottoshop\src\main\webapp]
[INFO] Webapp assembled in [225 msecs]
[INFO] artifact org.ow2.asm:asm: checking for updates from nexus-plugin-repository
[WARNING] repository metadata for: 'artifact org.ow2.asm:asm' could not be retrieved from repository: nexus-plugin-repository due to an error: Error transferring file: nexus.tatis.com
[INFO] Repository 'nexus-plugin-repository' will be blacklisted
[INFO] [datanucleus:enhance {execution: default}]
[INFO] DataNucleus Enhancer (version 3.1.1) : Enhancement of classes
DataNucleus Enhancer completed with success for 1 classes. Timings : input=208 ms, enhance=24 ms, total=232 ms. Consult the log for full details

[ERROR] --------------------
[ERROR]  Standard error from the DataNucleus tool + org.datanucleus.enhancer.DataNucleusEnhancer :
[ERROR] --------------------
[ERROR] Mar 13, 2013 11:48:42 PM org.datanucleus.enhancer.DataNucleusEnhancer <init>
INFO: DataNucleus Enhancer for API "JPA"
Mar 13, 2013 11:48:42 PM org.datanucleus.enhancer.DataNucleusEnhancer main
INFO: DataNucleus Enhancer (version 3.1.1) : Enhancement of classes
Mar 13, 2013 11:48:42 PM org.datanucleus.metadata.MetaDataManager loadFiles
WARNING: Metadata file -enhancerName not found in CLASSPATH
Mar 13, 2013 11:48:42 PM org.datanucleus.metadata.MetaDataManager loadFiles
WARNING: Metadata file ASM not found in CLASSPATH
Mar 13, 2013 11:48:43 PM org.datanucleus.enhancer.asm.ASMClassEnhancer enhance
INFO: Class "co.za.fwc.webapp.lottery.shared.dto.Player" is already enhanced.
Mar 13, 2013 11:48:43 PM org.datanucleus.enhancer.DataNucleusEnhancer addMessage
INFO: DataNucleus Enhancer completed with success for 1 classes. Timings : input=208 ms, enhance=24 ms, total=232 ms. Consult the log for full details

[ERROR] --------------------
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: C:\dev\projects\org\me\workspace\lottoshop\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] [gwt:compile {execution: default}]
[INFO] auto discovered modules [co.za.fwc.lottery.lottoshop.LottoShop, com.extjs.gxt.samples.resources.Resources]
[INFO] com.extjs.gxt.samples.resources.Resources has no EntryPoint - compilation skipped
[INFO] Compiling module co.za.fwc.lottery.lottoshop.LottoShop
[INFO]    Validating units:
[INFO]       Ignored 81 units with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO]    Computing all possible rebind results for 'com.google.gwt.useragent.client.UserAgentAsserter'
[INFO]       Rebinding com.google.gwt.useragent.client.UserAgentAsserter
[INFO]          Checking rule <generate-with class='com.google.gwt.editor.rebind.SimpleBeanEditorDriverGenerator'/>
[INFO]             [WARN] Detected warnings related to 'com.google.gwt.editor.client.SimpleBeanEditorDriver'.   Are validation-api-<version>.jar and validation-api-<version>-sources.jar on the classpath?
[INFO]             Specify -logLevel DEBUG to see all errors.
[INFO]             [WARN] Unknown type 'com.google.gwt.editor.client.SimpleBeanEditorDriver' specified in deferred binding rule
[INFO]    Compiling 6 permutations
[INFO]       Compiling permutation 0...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 3...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 1...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 2...
[INFO]       Compiling permutation 4...
[INFO]          Compiling
[INFO]             Compiling permutation 5...
[INFO]    Compile of permutations succeeded
[INFO] Linking into C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT\LottoShop
[INFO]    Link succeeded
[INFO]    Compilation succeeded -- 37.226s
[INFO] [war:war {execution: default-war}]
[INFO] Packaging webapp
[INFO] Assembling webapp [lottoshop] in [C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\dev\projects\org\me\workspace\lottoshop\src\main\webapp]
[INFO] Webapp assembled in [194 msecs]
[INFO] Building war: C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT.war
[INFO] [gae:run {execution: default-cli}]
Mar 13, 2013 11:49:25 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory 'C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT' is not an EAR directory. File C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT\appengine-application.xmlappengine-application.xml not detected.
Mar 13, 2013 11:49:25 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory 'C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT' is not an EAR directory. File C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT\appengine-application.xmlappengine-application.xml not detected.
Mar 13, 2013 11:49:25 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory 'C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT' is not an EAR directory. File C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT\appengine-application.xmlappengine-application.xml not detected.
Mar 13, 2013 11:49:25 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory 'C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT' is not an EAR directory. File C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT\appengine-application.xmlappengine-application.xml not detected.
Mar 13, 2013 11:49:25 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT\WEB-INF/appengine-web.xml
2013-03-13 23:49:25.382:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
Mar 13, 2013 11:49:25 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT\WEB-INF/web.xml
Mar 13, 2013 11:49:25 PM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
INFO: Overwriting system property key 'java.util.logging.config.file', value 'C:\Users\babajide.agbebiyi\.m2\repository\com\google\appengine\appengine-java-sdk\1.7.5\appengine-java-sdk-1.7.5\config\sdk\logging.properties' with value 'WEB-INF/logging.properties' from 'C:\dev\projects\org\me\workspace\lottoshop\target\lottoshop-0.0.1-SNAPSHOT\WEB-INF\appengine-web.xml'
2013-03-13 23:49:25.757:INFO::jetty-6.1.x
2013-03-13 23:49:26.919:INFO::Started SelectChannelConnector@127.0.0.1:8080
Mar 13, 2013 9:49:26 PM com.google.appengine.tools.development.AbstractServer startup
INFO: Server default is running at http://localhost:8080/
Mar 13, 2013 9:49:26 PM com.google.appengine.tools.development.AbstractServer startup
INFO: The admin console is running at http://localhost:8080/_ah/admin
Mar 13, 2013 9:49:26 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: Dev App Server is now running
Mar 13, 2013 9:49:52 PM com.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /favicon.ico
Mar 13, 2013 9:49:53 PM org.datanucleus.api.jpa.JPAEntityManagerFactory <init>
WARNING: No META-INF/persistence.xml files were found in the CLASSPATH of the current thread!
Mar 13, 2013 9:49:53 PM org.datanucleus.api.jpa.JPAEntityManagerFactory <init>
WARNING: No persistence unit of name "transactions-optional" is found in the CLASSPATH of the current thread!
Mar 13, 2013 9:49:53 PM com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String co.za.fwc.lottery.lottoshop.client.LottoService.greetServer(java.lang.String) throws java.lang.IllegalArgumentException' threw an unexpected exception: java.lang.ExceptionInInitializerError
        at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
        at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
        at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
        at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
        at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
        at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:61)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
        at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:409)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.ExceptionInInitializerError
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
        at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
        at co.za.fwc.lottery.lottoshop.server.LottoServiceImpl.greetServer(LottoServiceImpl.java:34)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
        at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
        ... 38 more
Caused by: javax.persistence.PersistenceException: No persistence providers available for "transactions-optional" after trying the following discovered implementations: org.datanucleus.api.jpa.PersistenceProviderImpl
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:182)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:72)
        at co.za.fwc.lottery.lottoshop.shared.EMF.<clinit>(EMF.java:6)
        ... 49 more

更新:添加图片以显示我拥有persistence.xml

Update: Added picture to show I have persistence.xml

推荐答案

我亲自会读取错误信息。 JPA非常清楚地定义 persistence.xml 必须位于何处,并且不存在。

I personally would read the error message. JPA defines very clearly where persistence.xml has to be, and it isn't there.


没有在
当前线程的CLASSPATH中找到META-INF / persistence.xml文件!

"No META-INF/persistence.xml files were found in the CLASSPATH of the current thread!"

这篇关于没有持久性提供者可用于“交易 - 可选”在尝试了以下发现的实现之后:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆