如何在Eclipse可执行JAR中使用DataNucleus JPA运行独立的Google AppEngine项目?客户将运行它,因此需要打包。它访问本地文件系统,因此它不能是Web应用程序。我没有使用Maven,只是Eclipse Project>出口>可执行JAR(以及它制作的Ant脚本)。当然,它在Eclipse中运行时有效。当我运行JAR时,我收到以下DataNucleus错误:
引起:java.io.FileNotFoundException:rsrc:datanucleus-api-jdo-3.1.3.jar(系统找不到指定的文件)
引起:org.datanucleus.exceptions.NucleusException:读取清单文件“jar:rsrc:datanucleus-api-jdo-3.1.3.jar!/plugin.xml”时出错
javax.persistence.PersistenceException:尝试以下发现的实现后,“transactions-optional”发生显式持久性提供程序错误:org.datanucleus.api.jpa.PersistenceProviderImpl from provider:org.datanucleus.api.jpa。 PersistenceProviderImpl
javax.persistence.PersistenceException: Explicit persistence provider error(s) occurred for "transactions-optional" after trying the following discovered implementations: org.datanucleus.api.jpa.PersistenceProviderImpl from provider: org.datanucleus.api.jpa.PersistenceProviderImpl
at javax.persistence.Persistence.createPersistenceException(Persistence.java:242)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:184)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:70)
at com.mwv.pic.dao.EMF.getInstance(EMF.java:26)
at com.mwv.pic.dao.SecondaryDocumentsDao.isSecondaryDocumentUniqueByTitle(SecondaryDocumentsDao.java:80)
at com.mwv.pic.dao.SecondaryDocumentsDao.addSecondaryDocument(SecondaryDocumentsDao.java:53)
at com.mwv.Import.createSecondaryDocument(Import.java:294)
at com.mwv.Import.importAllFiles(Import.java:234)
at com.mwv.Main$6.run(Main.java:220)
at java.lang.Thread.run(Unknown Source)
Caused by: org.datanucleus.exceptions.NucleusException: Error reading manifest file "jar:rsrc:datanucleus-api-jdo-3.1.3.jar!/plugin.xml"
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:482)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensions(NonManagedPluginRegistry.java:219)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensionPoints(NonManagedPluginRegistry.java:160)
at org.datanucleus.plugin.PluginManager.<init>(PluginManager.java:65)
at org.datanucleus.plugin.PluginManager.createPluginManager(PluginManager.java:427)
at org.datanucleus.api.jpa.JPAEntityManagerFactory.<init>(JPAEntityManagerFactory.java:328)
at org.datanucleus.api.jpa.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:91)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:150)
... 8 more
Caused by: java.io.FileNotFoundException: rsrc:datanucleus-api-jdo-3.1.3.jar (The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:390)
... 15 more
instance = Persistence.createEntityManagerFactory("transactions-optional");
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.4
Created-By: 1.7.0_17-b02 (Oracle Corporation)
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
Rsrc-Main-Class: com.mwv.Main
Rsrc-Class-Path: ./ google-api-services-drive-v2-rev107-1.16.0-rc.jar
... a hundred JARs ...
Class-Path: .
答案 0 :(得分:0)
这不是一个理想的解决方案,但我使用7-Zip管理器编辑了JAR文件,添加了main.bat
和main.sh
,并使用.zip扩展名重命名。用户隐式假定解压缩并运行批处理或shell脚本。该脚本如下所示:
java -cp ./:google-api-services-drive-v2-rev107-1.16.0-rc.jar:...:forms-1.3.0.jar com.mwv.Main
.bat文件是相同的,:
替换为;
。我刚刚复制了MANIFEST.MF
(7-Zip中的 F4 编辑)并手动使用了一些Notepad ++ Kung Fu来制作巨型类路径。毫无疑问,Eclipse生成的Ant文件会被修改为自动包含脚本,但我还没有这样做。