我正在尝试在 OSGI 中运行 Apache Wink 并使用 Felix Whiteboard 注册资源作为服务。在极简 OSGI 环境中,捆绑包按预期工作。但是,然后我将包移到了 Eclipse Equinox 环境中,我正在开发一个依赖它的插件。我开始收到此错误。
May 22, 2013 11:19:59 AM org.apache.wink.server.internal.application.ApplicationProcessor processWinkApplication
SEVERE: An exception occurred during processing of the com.yarcdata.rest.Repositories instance. This instance is ignored.
java.lang.IllegalArgumentException: interface javax.servlet.http.HttpServletRequest is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:461)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:690)
at org.apache.wink.common.internal.registry.ContextAccessor.getContextFromAccessor(ContextAccessor.java:92)
我想我已经安装了所有必需的包,如果我开始寻找导出 HttpServletRequest 的包,我会看到:
g! lb | grep ervlet
311|Resolved | 4|Servlet API Bundle (3.0.0.v201112011016)
394|Starting | 4|Http Services Servlet (1.1.300.v20120912-130548)
444|Resolved | 4|Jetty :: Servlet Handling (8.1.3.v20120522)
578|Resolved | 4|jersey-servlet (1.12.0)
580|Resolved | 4|jersey-servlet (1.17.1)
588|Active | 4|Java Servlet API (3.0.1)
589|Resolved | 4|javax.servlet.api (2.5.0)
590|Resolved | 4|javax.servlet.jstl (1.1.2)
622|Active | 4|Servlet Specification API (2.5.0)
678|Resolved | 4|Spring Web Servlet (2.5.6)
g! bundle 588
javax.servlet-api_3.0.1 [588]
Id=588, Status=ACTIVE Data Root=/wspaces/tbcPlugin/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/org.eclipse.osgi/bundles/588/data
"No registered services."
No services in use.
Exported packages
javax.servlet; version="3.0.0"[exported]
javax.servlet.descriptor; version="3.0.0"[exported]
javax.servlet.annotation; version="3.0.0"[exported]
javax.servlet.http; version="3.0.0"[exported]
No imported packages
No fragment bundles
Named class space
javax.servlet-api; bundle-version="3.0.1"[provided]
No required bundles
因此,由于 HttpServletRequest 的完整包是javax.servlet.http.HttpServletRequest
我希望捆绑 588 处于活动状态以解决 Wink 的问题。它是活动的,它会导出包,还有什么需要的吗?让我们检查一下它在寻找什么版本:
g! lb | grep mdatu
595|Resolved | 4|Amdatu Web - JAX RS (1.0.0)
596|Active | 4|Amdatu Web - Apache Wink Application (1.0.1)
g! bundle 596
org.amdatu.web.rest.wink_1.0.1 [596]
Id=596, Status=ACTIVE Data Root=/wspaces/tbcPlugin/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/org.eclipse.osgi/bundles/596/data
"Registered Services"
{org.amdatu.web.rest.jaxrs.JaxRsSpi}={service.id=139}
{javax.servlet.Servlet}={init.applicationConfigLocation=/conf/application.properties, alias=/myresource, service.id=140}
{javax.servlet.Servlet}={init.applicationConfigLocation=/conf/application.properties, alias=/protocol, service.id=141}
{javax.servlet.Servlet}={init.applicationConfigLocation=/conf/application.properties, alias=/repositories, service.id=142}
{org.osgi.service.cm.ManagedService}={service.pid=org.amdatu.web.rest.wink, org.amdatu.tenant.pid=org.amdatu.tenant.PLATFORM, service.id=143}
Services in use:
{java.lang.Object}={osgi.command.function=[confapply], osgi.command.scope=equinox, service.id=110}
...
No exported packages
Imported packages
javax.activation; version="0.0.0"<org.eclipse.osgi_3.8.2.v20130124-134944 [0]>
javax.annotation; version="0.0.0"<org.eclipse.osgi_3.8.2.v20130124-134944 [0]>
javax.servlet; version="3.0.0"<javax.servlet-api_3.0.1 [588]>
javax.servlet.http; version="3.0.0"<javax.servlet-api_3.0.1 [588]>