OSGi示例项目注入问题

发布于 2024-11-16 18:26:40 字数 3353 浏览 1 评论 0 原文

我在使用 OSGi 作为 Maven 项目的示例时遇到问题。

NetBeans:http://netbeans.org/kb/docs/javaee/maven -osgi-declarativeservices.html 或者有一个非 Netbeans 版本会产生相同的结果(blogs.oracle.com/arungupta/entry/totd_124_osgi_declarative_services)

我尝试在两个不同的平台 OSX/windows 上查看两组指令,但总是遇到同样的问题。我一直在部署到稳定的 glassfish 3.1。

我已经压缩了我在一次尝试中创建的项目,可以在这里找到它们: https://infra01.gimi.ox.ac.uk:8443/~douglas/problems/OSGiMavenProblem-20110616.zip

与说明相比,我所做的唯一更改是发现我必须将 org.apache.felix.scr.annotations 依赖项更改为 1.4,因为:

执行目标失败 org.apache.felix:maven-scr-plugin:1.7.0:scr (生成-scr-scrdescriptor) 上 项目helloservice:请使用 org.apache.felix:org.apache.felix.scr.annotations 版本 1.4.0 或更高版本。

一切似乎都按计划进行,直到最后。我部署了 Web 客户端应用程序,但遇到注入问题:

HTTP 状态 500 -

输入异常报告

消息

描述服务器遇到了 阻止它的内部错误 () 从满足这个要求。

异常

javax.servlet.ServletException: PWC1392:实例化 servlet 时出错 班级 com.mycompany.mavenhellowebclient.HelloClient 根本原因

com.sun.enterprise.container.common.spi.util.InjectionException: 创建托管对象时出错 班级 com.mycompany.mavenhellowebclient.HelloClient 根本原因

com.sun.enterprise.container.common.spi.util.InjectionException: 尝试注入异常 环境属性: com.mycompany.mavenhellowebclient.HelloClient/helloService@Field-Injectable 资源。班级名称= com.mycompany.mavenhellowebclient.HelloClient 场地 [电子邮件受保护]@@@ 进入课堂 com.mycompany.mavenhellowebclient.HelloClient 根本原因

javax.naming.NamingException:查找 失败了 'java:comp/env/com.mycompany.mavenhellowebclient.HelloClient/helloService' 在 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} [根异常是 javax.naming.NamingException:查找 'hello-service' 失败 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.ologicalName=java:comp/env/com.mycompany.mavenhellowebclient.HelloClient/helloService} [根异常是 javax.naming.NameNotFoundException: 找不到 hello-service]] 根本原因

javax.naming.NamingException:查找 'hello-service' 失败 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.ologicalName=java:comp/env/com.mycompany.mavenhellowebclient.HelloClient/helloService} [根异常是 javax.naming.NameNotFoundException: 找不到你好服务]根本原因

javax.naming.NameNotFoundException: 找不到你好服务

任何建议将不胜感激,因为我现在真的陷入困境。

道格拉斯

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 execute 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
[email protected]@@@
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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文