Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取java.lang.NoClassDefFoundError:javax/naming/NamingException错误(当我使用JPA支持访问OSGI包时)_Java_Osgi_Openjpa_Apache Felix_Osgi Bundle - Fatal编程技术网

获取java.lang.NoClassDefFoundError:javax/naming/NamingException错误(当我使用JPA支持访问OSGI包时)

获取java.lang.NoClassDefFoundError:javax/naming/NamingException错误(当我使用JPA支持访问OSGI包时),java,osgi,openjpa,apache-felix,osgi-bundle,Java,Osgi,Openjpa,Apache Felix,Osgi Bundle,我使用OpenJPA作为JPA提供者。我已经创建了带有JPA2.0支持的小型OSGI捆绑包项目。此捆绑包为其客户端提供持久性功能 我创建了另一个客户端包来使用上述持久性服务。当我使用Felix framework启动客户端捆绑服务时,我遇到以下错误: java.lang.NoClassDefFoundError:javax/naming/NamingException 完成堆栈跟踪 org.osgi.framework.BundleException: Activator start error

我使用OpenJPA作为JPA提供者。我已经创建了带有JPA2.0支持的小型OSGI捆绑包项目。此捆绑包为其客户端提供持久性功能

我创建了另一个客户端包来使用上述持久性服务。当我使用Felix framework启动客户端捆绑服务时,我遇到以下错误:

java.lang.NoClassDefFoundError:javax/naming/NamingException

完成堆栈跟踪

org.osgi.framework.BundleException: Activator start error in bundle StudentServiceConsumer [120].
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:2027)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
        at org.apache.felix.gogo.command.Basic.start(Basic.java:729)
        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.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
        at org.apache.felix.gogo.shell.Console.run(Console.java:62)
        at org.apache.felix.gogo.shell.Shell.console(Shell.java:203)
        at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:128)
        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.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
        at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: javax/naming/NamingException
        at com.student.serviceprovider.serviceimpl.StudentDAOService.persist(StudentDAOService.java:19)
        at com.student.serviceconsumer.activator.Activator.start(Activator.java:30)
        at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
        ... 32 more
Caused by: java.lang.ClassNotFoundException: javax.naming.NamingException not found by org.apache.openjpa [109]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 36 more
**java.lang.NoClassDefFoundError: javax/naming/NamingException**
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: StudentServiceProvider
Bundle-SymbolicName: StudentServiceProvider
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.student.serviceprovider.activator.Activator
Import-Package: org.osgi.framework
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Meta-Persistence: META-INF/persistence.xml
Export-Package: com.student.serviceprovider.model,
 com.student.serviceprovider.service,
 com.student.serviceprovider.serviceimpl
Bundle-ClassPath: ../lib/com.ibm.ws.jpa.jar,
 ../lib/commons-collections-20040616.jar,
 ../lib/j2ee.jar,
 ../lib/mysql-connector-java-5.1.7-bin.jar,
 .
Require-Bundle: org.apache.openjpa;bundle-version="1.2.1",
 org.apache.commons.logging;bundle-version="1.0.4"
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: StudentServiceConsumer
Bundle-SymbolicName: StudentServiceConsumer
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.student.serviceconsumer.activator.Activator
Import-Package: com.student.serviceprovider.model,
 com.student.serviceprovider.service,
 com.student.serviceprovider.serviceimpl,
 org.osgi.framework
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.student.serviceconsumer.activator
当前波纹管捆绑包处于活动状态

 ID|State      |Level|Name
   0|Active     |    0|System Bundle (4.0.3)
   1|Active     |    1|file:/C:/Felix/felix-framework-4.0.3/bundle/junit.jar (0.0.0)
   2|Active     |    1|Apache Felix Bundle Repository (1.6.6)
   3|Active     |    1|Apache Felix Gogo Command (0.12.0)
   4|Active     |    1|Apache Felix Gogo Runtime (0.10.0)
   5|Active     |    1|Apache Felix Gogo Shell (0.10.0)
   7|Active     |    1|WS_J2EE_persistence (7.0.0)
 105|Active     |    1|file:/C:/Felix/felix-framework-4.0.3/bundle/commons-logging-4.0.6.jar (0.0.0)
 106|Active     |    1|Apache Commons Lang (2.6.0.v201205030909)
 107|Active     |    1|Apache Commons Logging Plug-in (1.0.4.v201101211617)
 109|Active     |    1|OpenJPA Plug-in (1.2.1.201001181728)
 114|Active     |    1|file:/C:/Felix/felix-framework-4.0.3/bundle/rt.jar (0.0.0)
 119|Active     |    1|StudentServiceProvider (1.0.0.201303061113)
MENIFEST.MF(服务包)

MENIFEST.MF(客户端包)


我对OSGI捆绑包开发非常陌生。请帮助我解决此问题。

您的客户端包需要导入包
javax.naming
。将其添加到由
Import Package
指示的导入包列表中

顺便说一句,在您解决
javax.naming
问题后,您可能会发现缺少其他依赖项。您确实不应该手工编写MANIFEST.MF,因为它容易出错,并且包含重复的信息。你应该使用像or这样的工具

更新:事实上,OpenJPA本身无法导入包
javax.naming
,如堆栈跟踪的以下部分所示:“javax.naming.NamingException not found by org.apache.OpenJPA[109]”


因此,OpenJPA被破坏。

您的客户端包需要导入包
javax.naming
。将其添加到由
Import Package
指示的导入包列表中

顺便说一句,在您解决
javax.naming
问题后,您可能会发现缺少其他依赖项。您确实不应该手工编写MANIFEST.MF,因为它容易出错,并且包含重复的信息。你应该使用像or这样的工具

更新:事实上,OpenJPA本身无法导入包
javax.naming
,如堆栈跟踪的以下部分所示:“javax.naming.NamingException not found by org.apache.OpenJPA[109]”


因此,OpenJPA被破坏了。

尝试添加javax.api作为依赖项

<dependencies>
    <module name="javax.api"/>
</dependencies>

尝试将javax.api添加为依赖项

<dependencies>
    <module name="javax.api"/>
</dependencies>

尝试使用-Dosgi.compatibility.bootdelegation=true
这有助于解决我的问题

尝试使用-Dosgi.compatibility.bootdelegation=true
这有助于解决我的问题

谢谢你的回答,尼尔,但我还是犯了同样的错误。我正在使用IBMRational开发工具进行OSGI应用。因此,无需手动编写MANIFEST.MF。它将产生新的影响。我从eclipse市场买的。目前我正在使用openJpa捆绑包版本1.2.1。希望这不支持JPA2.0。我想找到OpenJPA版本2的OpenJPA包。请告诉我哪里出错了。哦,我仔细检查了错误消息后发现,实际上是OpenJPA本身未能导入
javax.naming
包。在这种情况下,OpenJPA被破坏了。请报告一个错误。至于你哪里出错了。。。首先,你使用了JPA。。。然后您使用了IBMRational工具;-)谢谢,尼尔。我使用IBMRational开发工具创建了这个OSGI包。它支持使用JPA2.0支持创建捆绑包。正如您在上面提到的OpenJPA的问题。我会检查的。顺便说一下,我想问你另外一个问题。我从eclipse插件中获得了这个OpenJPA包。我认为,它不支持JPA2.0。(我将OpenJPA插件添加到eclipse,并从eclipse插件文件夹中获得了该捆绑包。)请告诉我在哪里可以安装支持JPA2.0的OpenJPA捆绑包
谢谢!工具假设启动了?谢谢你的回答,尼尔,但我还是得到了同样的错误。我正在使用IBMRational开发工具进行OSGI应用。因此,无需手动编写MANIFEST.MF。它将产生新的影响。我从eclipse市场买的。目前我正在使用openJpa捆绑包版本1.2.1。希望这不支持JPA2.0。我想找到OpenJPA版本2的OpenJPA包。请告诉我哪里出错了。哦,我仔细检查了错误消息后发现,实际上是OpenJPA本身未能导入
javax.naming
包。在这种情况下,OpenJPA被破坏了。请报告一个错误。至于你哪里出错了。。。首先,你使用了JPA。。。然后您使用了IBMRational工具;-)谢谢,尼尔。我使用IBMRational开发工具创建了这个OSGI包。它支持使用JPA2.0支持创建捆绑包。正如您在上面提到的OpenJPA的问题。我会检查的。顺便说一下,我想问你另外一个问题。我从eclipse插件中获得了这个OpenJPA包。我认为,它不支持JPA2.0。(我将OpenJPA插件添加到eclipse,并从eclipse插件文件夹中获得了该捆绑包。)请告诉我在哪里可以安装支持JPA2.0的OpenJPA捆绑包
ThanksPerhaps工具假设启动了bootdelegation?您是否使用类似ApacheAries提供的JPA服务提供商?您仍然可以使用OpenJPA,但在OSGi环境中单独使用OpenJPA通常效果不太好。您是否使用ApacheAries提供的JPA服务提供商?您仍然可以使用OpenJPA,但在OSGi环境中单独使用OpenJPA通常效果不佳。任何使用引导委派的人都应该阅读。任何使用引导委派的人都应该阅读。