0

在将我的 portlet 战争部署到 Liferay 服务器时,我似乎抛出了 java.lang.ClassNotFoundException,这也发生在 eclipse(Indigo)中运行服务器。在将其转换为 Liferay portlet 之前,我确保我的 jersey 服务在 Tomcat 7.1 上工作。谢谢。

堆栈跟踪是

17-Oct-2013 14:13:33 org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /spike-jersey-new-portlet threw load() exception
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:527)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:509)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:137)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5407)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1636)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

我的 WebService 类看起来像

@Path("/mymessage")
public class WebService
{
       @GET
       @Path("hello")
       @Produces(MediaType.APPLICATION_JSON)
       public String myMethod()
      {   
             return "HELLO";
      }
}

我的 web.xml 看起来像

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>spike-jersey-new-portlet</display-name>

<jsp-config>
    <taglib>
        <taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri>
        <taglib-location>
            /WEB-INF/tld/liferay-portlet.tld
        </taglib-location>
    </taglib>
</jsp-config>

<servlet>
      <servlet-name>spike-jersey-new</servlet-name>
      <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
      <init-param>
                <param-name>com.sun.jersey.config.property.packages</param-name>
                <param-value>com.spike.jersey</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
   </servlet>

<servlet-mapping>
             <servlet-name>spike-jersey-new</servlet-name>
             <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

</web-app>

和 pom.xml 依赖项

<dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.8</version>
</dependency>

<dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.8</version>
</dependency>
4

1 回答 1

0

问题是我正在部署使用已转换为 Maven 项目的 Liferay 插件构建的 Liferay portlet,并且插件部署没有获取 Maven 依赖项。

于 2013-10-21T15:54:40.143 回答