OSGi example project injection problem
I'm having a problem with an example of OSGi as a maven project.
NetBeans: http://netbeans.org/kb/docs/javaee/maven-osgi-declarativeservices.html or there is a non-Netbeans version which yields identical results (blogs.oracle.com/arungupta/entry/totd_124_osgi_declarative_services)
I've tried going through both sets of instructions on two different platforms OSX/windows and I always end up with the same problem. I've been deploying to stable glassfish 3.1.
I've zipped up my projects that I created in one of my attempts and they can be found here: https://infra01.gimi.ox.ac.uk:8443/~douglas/problems/OSGiMavenProblem-20110616.zip
The only change I've made compared to the instructions is that I found I have to change the org.apache.felix.scr.annotations dependency to 1.4 because of:
Failed to execu开发者_如何学JAVAte goal org.apache.felix:maven-scr-plugin:1.7.0:scr (generate-scr-scrdescriptor) on project helloservice: Please use org.apache.felix:org.apache.felix.scr.annotations version 1.4.0 or newer.
All seems to go according to plan until the very end. I deploy the Web Client Application, but I get an injection problem:
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: PWC1392: Error instantiating servlet class com.mycompany.mavenhellowebclient.HelloClient root cause
com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class com.mycompany.mavenhellowebclient.HelloClient root cause
com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Env-Prop: com.mycompany.mavenhellowebclient.HelloClient/helloService@Field-Injectable Resource. Class name = com.mycompany.mavenhellowebclient.HelloClient Field name=helloService@java.lang.String@@@ into class com.mycompany.mavenhellowebclient.HelloClient root cause
javax.naming.NamingException: Lookup failed for 'java:comp/env/com.mycompany.mavenhellowebclient.HelloClient/helloService' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Lookup failed for 'hello-service' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/com.mycompany.mavenhellowebclient.HelloClient/helloService} [Root exception is javax.naming.NameNotFoundException: hello-service not found]] root cause
javax.naming.NamingException: Lookup failed for 'hello-service' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/com.mycompany.mavenhellowebclient.HelloClient/helloService} [Root exception is javax.naming.NameNotFoundException: hello-service not found] root cause
javax.naming.NameNotFoundException: hello-service not found
Any suggestions would be much appreciated as I'm really stuck in my tracks at the moment.
Douglas
精彩评论