我正在開發一個使用eclipselink的獨立Java應用程序。當我從eclipse IDE執行應用程序時,這一切都很好。但是我導出了一個可執行的JAR文件,因爲我無法使eclipseLink工作。 我也發現了類似的問題在Eclipse社區論壇here,但還沒有太順手:eclipselink可執行文件中的PersistenceUnitLoadingEception JAR
請幫幫忙,
我的例外是:
01 dec. 2010 22:47:31,199 INFO Configuration:97 - Iniciate database Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa der.java:56) Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.0.2.v 20100323-r6872): org.eclipse.persistence.exceptions.PersistenceUnitLoadingExcept ion Exception Description: An exception was thrown while searching for persistence a rchives with ClassLoader: [email protected] Internal Exception: Exception [EclipseLink-30004] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.PersistenceUnitLoad ingExceptionException Description: An exception was thrown while processing persistence.xml from URL: rsrc:../ Internal Exception: java.net.MalformedURLException at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.ex ceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126 ) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFa ctory(PersistenceProvider.java:133) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFa ctory(PersistenceProvider.java:65) at javax.persistence.Persistence.createEntityManagerFactory(Persistence. java:51) at javax.persistence.Persistence.createEntityManagerFactory(Persistence. java:33) at eu.agilelabs.pillAgent.db.dam.DataManagerImplJPA.(DataManagerIm plJPA.java:36) at eu.agilelabs.pillAgent.db.dam.DataManagerImplJPA.getInstance(DataMana gerImplJPA.java:47) at eu.agilelabs.configuration.Configuration.(Configuration.java:98 ) at eu.agilelabs.configuration.Configuration.getInstance(Configuration.ja va:119) at eu.agilelabs.pillAgent.core.Main.main(Main.java:15) ... 5 more Caused by: Exception [EclipseLink-30004] (Eclipse Persistence Services - 2.0.2.v 20100323-r6872): org.eclipse.persistence.exceptions.PersistenceUnitLoadingExcept ion Exception Description: An exception was thrown while processing persistence.xml from URL: rsrc:../ Internal Exception: java.net.MalformedURLException at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.ex ceptionProcessingPersistenceXML(PersistenceUnitLoadingException.java:117) at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProces sor.processPersistenceXML(PersistenceUnitProcessor.java:444) at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProces sor.processPersistenceArchive(PersistenceUnitProcessor.java:401) at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProces sor.getPersistenceUnits(PersistenceUnitProcessor.java:310) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPe rsistenceUnitInfoInArchive(JPAInitializer.java:149) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPe rsistenceUnitInfoInArchives(JPAInitializer.java:136) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPe rsistenceUnitInfo(JPAInitializer.java:125) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFa ctory(PersistenceProvider.java:98) ... 13 more Caused by: java.net.MalformedURLException at java.net.URL.(Unknown Source) at java.net.URL.(Unknown Source) at java.net.URL.(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrent Entity(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineD ocVersion(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U nknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U nknown Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So urce) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Un known Source) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.p arse(Unknown Source) at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProces sor.processPersistenceXML(PersistenceUnitProcessor.java:442) ... 19 more
我覺得這條線必須是關鍵:
Internal Exception: Exception [EclipseLink-30004] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.PersistenceUnitLoad ingExceptionException Description: An exception was thrown while processing persistence.xml from URL: rsrc:../
奇怪,錯誤總是會發生嗎?請包括你的persistence.xml。 JVM和OS與Eclipse運行相同嗎?你如何運行它? – James 2010-12-02 16:07:13
我已經設法解決它。我改變了eclipse導出jar文件的方式。如果它將所需的庫提取到jar中,一切都很好。不管怎樣,謝謝你! – GaDo 2011-01-07 14:37:08