0

嗨,我是 liferay 中 json Web 服务的新手,我收到以下错误!我在 web.xml 中添加了 JSONWebServiceServlet。我必须将任何 jar 文件添加到类路径吗?

05:51:36,250 ERROR [PortalClassLoaderServlet:76] java.lang.ClassNotFoundException: com.liferay.portal.jsonwebservice.JSONWebServiceServlet
java.lang.ClassNotFoundException: com.liferay.portal.jsonwebservice.JSONWebServiceServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
    at com.liferay.portal.kernel.servlet.PortalClassLoaderServlet.portalInit(PortalClassLoaderServlet.java:70)
    at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:52)
    at com.liferay.portal.kernel.servlet.PortalClassLoaderServlet.init(PortalClassLoaderServlet.java:44)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1244)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1342)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
    at java.lang.Thread.run(Unknown Source)

在 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>pdfportlet-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>JSON Web Service Servlet</servlet-name>  
           <servlet-class>com.liferay.portal.kernel.servlet.PortalClassLoaderServlet</servlet-class>  
           <init-param>  
               <param-name>servlet-class</param-name>  
               <param-value>com.liferay.portal.jsonwebservice.JSONWebServiceServlet</param-value>  
           </init-param>  
           <load-on-startup>0</load-on-startup>  
       </servlet>  
      <servlet-mapping>  
          <servlet-name>JSON Web Service Servlet</servlet-name>  
          <url-pattern>/api/jsonws/*</url-pattern>  
      </servlet-mapping>  
      <servlet-mapping>  
          <servlet-name>JSON Web Service Servlet</servlet-name>  
          <url-pattern>/api/secure/jsonws/*</url-pattern>  
      </servlet-mapping>  

</web-app>
4

1 回答 1

0
 configure the servlet like this: some sysntax error i think. its working fine now.
   <?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>student-portlet</display-name>
    <servlet>
    <servlet-name>JSON Web Service Servlet</servlet-name>
    <servlet-class>
    com.liferay.portal.kernel.servlet.PortalClassLoaderServlet
    </servlet-class>
    <init-param>
    <param-name>servlet-class</param-name>
    <param-value>com.liferay.portal.servlet.JSONServlet</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>JSON Web Service Servlet</servlet-name>
    <url-pattern>/api/jsonws/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>JSON Web Service Servlet</servlet-name>
    <url-pattern>/api/secure/jsonws/*</url-pattern>
    </servlet-mapping>
        <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>
    </web-app>
于 2013-09-25T15:53:06.827 回答