【发布时间】:2011-09-18 09:45:34
【问题描述】:
我正在尝试使用 tomcat 设置一个简单的 hbase webapp。据我所知,我需要包含 hbase jar 和 hadoop jar 才能将 hbase 与 zoopkeeper jar 一起使用。
问题是当我在我的 maven pom 中包含 hbase jar 时,它会下载我不想要的各种 od 传递依赖 jar(例如 jetty、servlet-api 等),因为 hbase 本身有自己的内置 jetty web 应用程序用于监控。我认为这与 tomcat 打包和启动冲突,导致我出现以下异常:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet jersey-serlvet threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:619)
root cause
com.sun.jersey.api.container.ContainerException: No WebApplication provider is present
com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:69)
com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:391)
com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.create(ServletContainer.java:306)
com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:607)
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
javax.servlet.GenericServlet.init(GenericServlet.java:212)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:619)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.28 logs.
当我从我的 pom 中注释掉 hbase jar 时(所有依赖于 hbase 的 jar 也按预期消失了),并且 tomcat 部署良好,我可以访问我的 rest/spring servlet。
我尝试使用排除项来排除 hbase 直接依赖项,具体如下:
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
<version>0.90.3-cdh3u1 </version>
<exclusions>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<!-- <version>1.4</version> -->
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<!-- <version>6.1.14</version> -->
</exclusion>
<exclusion>
<groupId>org.apache.thrift</groupId>
<artifactId>thrift</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-api-2.1</artifactId>
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api-2.5</artifactId>
</exclusion>
<exclusion>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.hadoop</groupId>
<artifactId>avro</artifactId>
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
</exclusion>
<exclusion>
<groupId>tomcat</groupId>
<artifactId>jasper-compiler</artifactId>
</exclusion>
<exclusion>
<groupId>tomcat</groupId>
<artifactId>jasper-runtime</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
但无济于事,我仍然有问题。
那么有没有人有一个退出的 pom,他们有包括 hbase 和 hadoop 并以某种方式让 tomcat 工作,也许也使用 jersey?
我知道上面不详细,我会添加更多详细信息。我将粘贴 maven full pom。
非常感谢
【问题讨论】:
-
如果有人有使用 maven 的示例 tomcat hbase 设置,请您建议如何在 tomcat web-inf lib 中适当地包含 hbase jar。
-
战争结果如何? (即其中包含哪些库?)您使用的是什么版本的 Jersey?据我所知,HBase 也依赖于 Jersey。也许使用 HBase,您正在使用另一个版本的 Jersey,这就是导致问题的原因?
-
嗨 Martin,我正在使用 tomcat 6。Jersey-server-1.8.jar、jersey-core-1.8.jar、jersey-spring-1.8.jar。我没有意识到 HBase 也依赖于泽西岛,也许我也需要排除这个?我会试一试。谢谢你的cmets。我会回来更新的。
-
嗨,马丁工作得很好。我排除了 Jersey hbase 依赖项并解决了它。非常感谢。阿马克
jersey-core com.sun.jersey -
好的,将其作为答案发布,以免其他人认为这仍然没有答案。你能接受答案吗?谢谢。