Gre*_*reg 10 java jersey java-ee openejb apache-tomee
我正在升级使用Jersey JAX-RS在Apache TomEE服务器上运行的代码.不幸的是,当我尝试将Jersey与TomEE一起使用时,它会抛出错误.
我正在使用eclipse并打开了JAX-RS项目方面.它指向泽西图书馆.我还将Jersey库移动到/ lib /目录中以尝试解决问题无济于事.服务器抛出以下错误:
May 14, 2012 6:26:44 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Provider classes found:
class org.codehaus.jackson.jaxrs.JsonParseExceptionMapper
class org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider
class org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper
class org.codehaus.jackson.jaxrs.JacksonJsonProvider
May 14, 2012 6:26:44 AM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.RuntimeException: javax.naming.NameNotFoundException: Name [com] is not bound in this Context. Unable to find [com].
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:177)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(CDIComponentProviderFactory.java:92)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:75)
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:576)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:311)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:608)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.naming.NameNotFoundException: Name [com] is not bound in this Context. Unable to find [com].
at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.sun.jersey.server.impl.cdi.CDIExtension$2.stepInto(CDIExtension.java:290)
at com.sun.jersey.server.impl.cdi.CDIExtension.diveIntoJNDIContext(CDIExtension.java:267)
at com.sun.jersey.server.impl.cdi.CDIExtension.lookupJerseyConfigJNDIContext(CDIExtension.java:287)
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:175)
... 22 more
Run Code Online (Sandbox Code Playgroud)
web.xml中:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>tomeeTest3</display-name>
<servlet>
<description>JAX-RS Tools Generated - Do not modify</description>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/jaxrs/*</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
有谁知道我怎么做这个工作?我也考虑使用tomEE + Jax-rs服务器,但似乎没有认识到杰克逊的注释.
编辑:我认为问题是openEJB CDI与泽西岛附带的CDI相冲突.我不知道如何解决这个问题.
小智 11
复活!以防任何人仍然遇到这个问题.
我有一个运行在Tomcat peachy敏锐的Jersey应用程序,并且当我将它移动到TomEE时以这种方式爆炸.问题是TomEE已经有了自己的JAX-RS实现(在撰写本文时为tomee-jaxrs-1.5.0),这与jersey-bundle jar冲突.
我要摆脱这个问题所要做的就是删除jersey jars并注释掉web.xml中的servlet声明和映射
重新开始,中提琴!请记住,URL会略有不同.例如,在您可能拥有的默认平针织安装上http://localhost/rest/represent/me,当您将同一个应用程序移动到TomEE时,它将是http://localhost/represent/me
如果您正在使用像eclipse这样的IDE,可能会因为无法找到jar而咆哮,只需进入项目属性并将目标运行时设置为TomEE(您将不得不添加服务器实例),您应该是很高兴.
分享和享受.
我也遇到了这个问题,但是不幸的是grauwulf的答案对我不起作用.
在我的情况下,我有Tomee + 1.5.2,Jersey 1.1x,我也使用Spring 3.x.
修复实际上非常简单:
system.properties文件({tomee}/conf/system.properties默认情况下).com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true从那里开始,它对我有用.为了给予应有的信用,我在这篇博客文章中找到了它.
有趣的是,我也更喜欢避免{tomee}/lib使用war的依赖项来混乱我的文件夹,所以我还发现你可以通过修改{tomee}/conf/tomee.xml和添加以下节点(在<tomee />根节点内)轻松添加额外的lib :
<tomee>
<Service
id="extra-libs-enricher"
class-name="org.apache.openejb.assembler.classic.enricher.AdditionalLibClassLoaderEnricherObserver">
path = /path/to/your/libs
</Service>
</tomee>
Run Code Online (Sandbox Code Playgroud)
有了它Service,其名称是任意的,你不能传递path,默认为此时"additional-lib".默认情况下将使用传入的路径,但如果它不是目录,则它将回退到系统属性,该属性可以添加到system.properties文件中.系统属性是:openejb.enricher.additional-lib.
openejb.enricher.additional-lib=/fallback/path/to/your/libs
Run Code Online (Sandbox Code Playgroud)
仅当传递到的路径Service或其默认值不起作用且仅当a Service放置在tomee.xml文件中时,才会检查此系统属性.它id是无关紧要的.
| 归档时间: |
|
| 查看次数: |
10389 次 |
| 最近记录: |