Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Model view controller java.lang.IllegalStateException:根上下文属性的类型不是WebApplicationContext_Model View Controller_Spring_Listener_Portlet - Fatal编程技术网

Model view controller java.lang.IllegalStateException:根上下文属性的类型不是WebApplicationContext

Model view controller java.lang.IllegalStateException:根上下文属性的类型不是WebApplicationContext,model-view-controller,spring,listener,portlet,Model View Controller,Spring,Listener,Portlet,我正在Tomcat 6上的Liferay 5.2.3上部署portlet。我只在一个portlet中得到这个错误 java.lang.IllegalStateException: Root context attribute is not of type WebApplicationContext 我做了一些研究,发现Spring在需要web应用程序上下文时正在实例化portlet应用程序上下文。但在我的web.xml中,我只定义了contextLoaderListner <lis

我正在Tomcat 6上的Liferay 5.2.3上部署portlet。我只在一个portlet中得到这个错误

 java.lang.IllegalStateException: Root context attribute is not of type WebApplicationContext
我做了一些研究,发现Spring在需要web应用程序上下文时正在实例化portlet应用程序上下文。但在我的web.xml中,我只定义了contextLoaderListner

  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

org.springframework.web.context.ContextLoaderListener
最重要的是,如果Spring正在查找一个不同的*.jar文件,那么除了一个之外,为什么还要部署我的其他portlet呢


经过几次重新部署后,我解决了这个问题。有人能给你点提示吗?

听起来你好像没有定义contextConfigLocation?在web.xml中,除了contextLoaderListener之外,还应该有类似的内容:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/applicationContext.xml     
    </param-value>

</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

上下文配置位置
/WEB-INF/applicationContext.xml
org.springframework.web.context.ContextLoaderListener
其中applicationContext.xml是Web应用程序的常规配置文件

如果使用spring portlet MVC,您的web.xml中也应该包含以下内容:

<servlet>
    <servlet-name>ViewRendererServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>ViewRendererServlet</servlet-name>
    <url-pattern>/WEB-INF/servlet/view</url-pattern>
</servlet-mapping>

ViewRenderServlet
org.springframework.web.servlet.viewRenderServlet
ViewRenderServlet
/WEB-INF/servlet/view
在您的portlet.xml中,我想您可以这样指定您的portlet:

<portlet>
<portlet-name>sample</portlet-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<supports>
    <mime-type>text/html</mime-type>
    <portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
    <title>Sample Portlet</title>
</portlet-info>
</portlet>

样品
org.springframework.web.portlet.DispatcherPortlet
文本/html
看法
示例Portlet
如果还没有,请参阅SpringPortletMVC参考


希望能有所帮助。

根本原因似乎是门户/应用程序服务器中的一个静态变量“挂起”portlet中的一个类实例。两个常见的罪魁祸首是log4j和java日志记录,这两个都是应用程序容器常用的

有关伐木工人的更多讨论,请参阅和。建议将SLF4J与logback一起使用,或者确保将log4j.jar放在WAR文件中,使其位于正确的类加载器中(尽管某些容器会阻碍此解决方案)

此外,容器中存在的其他类别也可能是原因。日志记录只是一个常见的问题