2013-03-06 8 views
2

OpenJPA를 JPA 공급자로 사용하고 있습니다. JPA2.0을 지원하는 작은 OSGI 번들 프로젝트를 만들었습니다. 이 번들은 클라이언트에 지속성 기능을 제공합니다.JPA 지원을 사용하여 OSGI 번들에 액세스 할 때 java.lang.NoClassDefFoundError : javax/naming/NamingException이 발생 함

위의 지속성 서비스를 사용하기 위해 다른 클라이언트 번들을 만들었습니다. 나는 울부 짖는 오류를 얻고있다 펠릭스 프레임 워크를 사용하여 클라이언트 번들 서비스,

java.lang.NoClassDefFoundError가 시작할 때 : javax의/이름을/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** 

현재 벨로우즈 번들은 활성 상태 임

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 (서비스 번들)

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" 

MENIFEST.MF (클라이언트 번들)

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 

나는 OSGI 번들 발전에 아주 새로운 오전. 이 문제를 해결하도록 도와주세요.

+0

Apache Aries와 같은 JPA 서비스 공급자를 사용하고 있습니까? 여전히 OpenJPA를 사용할 수는 있지만 OSGi 환경에서 자체적으로 사용하면 대개 잘 작동하지 않습니다. –

답변

2

클라이언트 번들은 javax.naming 패키지를 가져와야합니다. Import-Package으로 표시된 가져온 패키지 목록에 추가하십시오.

그러나 javax.naming을 사용하여 문제를 해결 한 후에 추가 종속성이 누락 될 수 있습니다. 오류가 발생하기 쉽고 중복 된 정보가 포함되어 있으므로 MANIFEST.MF를 직접 작성해서는 안됩니다. bnd 또는 Bndtools과 같은 도구를 사용해야합니다.

업데이트 : 스택 트레이스의 아래 부분에 도시 된 바와 같이는 실제로는 OpenJPA 자체 패키지 javax.naming를 가져올 실패 "javax.naming.NamingException org.apache.openjpa가 [109]에서 찾을 수 없습니다."

따라서 OpenJPA가 손상되었습니다.

+0

답변을 주셔서 감사합니다 닐,하지만 여전히 같은 오류가 발생합니다. OSGI 응용 프로그램 용 IBM Rational Development 도구를 사용하고 있습니다. MANIFEST.MF를 직접 작성하지 않아도됩니다. 그것은 생성됩니다. 나는 이클립스 시장에서 그것을 얻었다. 현재 openJpa 번들 버전 1.2.1을 사용하고 있습니다. 이 JPA2.0에 대한 지원 doesst. 나는 오픈 JPA 번들 인 OpenJPA 버전 2를 찾았습니다. 내가 잘못한 곳에 조언 해주세요. –

+0

오 오류 메시지를 자세히 살펴보면 사실 OpenJPA 자체가'javax.naming' 패키지를 가져 오지 못합니다. 이 경우 OpenJPA가 손상됩니다. 버그를 신고하십시오. –

+1

어디서 잘못되었는지 ... 먼저, JPA를 사용하고 IBM Rational 도구를 사용했습니다 .-) –

1

종속성으로 javax.api를 추가하려고합니다.

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