Forums

RSS RSS
Problem with SpringMVC when I use Liferay Porlets Flat View
Threads
Hi everyone,
I've developed a Porlet using SpringMVC and Hibernate and Maven without any problem. But then I decided to integrate with Liferay Libreries (portal-service and portal-kernel) because I would like to use some methods as get the user login, the email and other things. The problem es when I modify my Pom.xml file and make the package again, withou modify any line of my code I have the follow mistake:

ationContext@10e35d5: display name [Root WebApplicationContext]; startup date [Mon May 18 17:36:13 GMT 2009]; root of context hierarchy
java.lang.IllegalStateException: Root context attribute is not of type WebApplicationContext: com.liferay.portal.spring.context.PortalApplicationContext@10e35d5: display name [Root WebApplic
ationContext]; startup date [Mon May 18 17:36:13 GMT 2009]; root of context hierarchy
at org.springframework.web.portlet.context.PortletApplicationContextUtils.getWebApplicationContext(PortletApplicationContextUtils.java:64)
at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:291)
at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:265)
at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:114)
at javax.portlet.GenericPortlet.init(GenericPortlet.java:107)
at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:250)
at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:245)
at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:135)
at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:47)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(PortletHotDeployListener.java:593)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:242)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:121)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:108)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:153)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:43)
at com.liferay.portal.kernel.servlet.PortletContextListener.portalInit(PortletContextListener.java:113)
at com.liferay.portal.kernel.util.PortalInitableUtil.init(PortalInitableUtil.java:48)
at com.liferay.portal.kernel.servlet.PortletContextListener.contextInitialized(PortletContextListener.java:109)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1117)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1215)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1306)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1570)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1559)
at java.lang.Thread.run(Thread.java:595)
17:49:34,129 INFO [PortletHotDeployListener:298] 1 portlet for firstPortlet is available for use
18/05/2009 05:49:34 PM org.apache.catalina.core.StandardContext start
GRAVE: Error listenerStart


This is my configuration

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gob.osinergmin.web.portlet</groupId>
<artifactId>firstPortlet</artifactId>
<packaging>war</packaging>
<name>${pom.artifactId}</name>
<version>0.1</version>
<description>Porlet para requerimientos using SpringMVC (JSR 168)</description>
<url>http://www.osinerg.gob.pe</url>
<properties>
<java-api.version>1.5</java-api.version>
<servlet-api.version>2.4</servlet-api.version>
<jstl.version>1.1.2</jstl.version>
<portlet-api.version>1.0</portlet-api.version>
<spring.version>2.0.7</spring.version>
<commons-fileupload.version>1.2.1</commons-fileupload.version>
<spring-mock.version>2.0.7</spring-mock.version>
<spring-aop.version>2.0.8</spring-aop.version>
<spring-dao.version>2.0.1</spring-dao.version>
<jstl.version>1.1.2</jstl.version>
<taglibs.version>1.1.2</taglibs.version>
<commons-io.version>1.4</commons-io.version>

</properties>
<build>
<finalName>${pom.name}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java-api.version}</source>
<target>${java-api.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>${jstl.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>portlet-api</groupId>
<artifactId>portlet-api</artifactId>
<version>${portlet-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-portlet</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<!-- fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons-fileupload.version}</version>
</dependency>
<!-- spring mock, testing -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>${spring-mock.version}</version>
</dependency>
<!-- Spring AOP -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring-aop.version}</version>
</dependency>
<!-- Spring DAO -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-dao</artifactId>
<version>${spring-dao.version}</version>
</dependency>
<!-- JSTL, especialmente para Tomcat -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>

</dependency>
<!-- TagLib -->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>${taglibs.version}</version>
</dependency>

<!-- commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>

<!-- Hibernate -->

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.6.ga</version>
</dependency>

<!-- Mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.1</version>
</dependency>

<!-- commons-lang -->

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>

<!-- Spring Hibernate -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-hibernate</artifactId>
<version>1.2.9</version>
</dependency>

<!-- Spring -->
<!-- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
-->

<!-- MYSQL Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.5</version>
</dependency>

<dependency>
<groupId>com.liferay</groupId>
<artifactId>portal-service</artifactId>
<version>5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>portal-kernel</artifactId>
<version>5.2.2</version>
<scope>provided</scope>
</dependency>




</dependencies>

<!-- Repositorio adicional para Hibernate -->
<repositories>
<repository>
<id>maven-repository.dev.java.net</id>
<name>Java Dev Net Repository</name>
<url>http://download.java.net/maven/2/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>




</project>


-- web.xml --
<?xml version="1.0"?>

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<display-name>controlReq</display-name>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>org.springframework.web.portlet.sample</param-value>
</context-param>

<!-- Define the Spring cofiguration xml Files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context/application*.xml,
/WEB-INF/context/portlet/*.xml </param-value>
</context-param>

<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>



<!--
/////////////////////////////////////////////////////////////////////////
FILTERS
/////////////////////////////////////////////////////////////////////////
-->
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>

<!--
/////////////////////////////////////////////////////////////////////////
FILTER MAPPINGS
/////////////////////////////////////////////////////////////////////////
-->
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.htm</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>



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

<listener>
<listener-class>org.springframework.web.util.WebAppRootListener</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>


<servlet>
<servlet-name>ViewRendererServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

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

<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tags/c.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/tags/fmt.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/functions</taglib-uri>
<taglib-location>/WEB-INF/tags/fn.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://www.springframework.org/tags</taglib-uri>
<taglib-location>/WEB-INF/tags/spring.tld</taglib-location>
</taglib>

</web-app>

Anyone could help me?. Thank you so much.
Flag Flag
RE: Problem with SpringMVC when I use Liferay Porlets
7/15/09 8:54 AM as a reply to Omar Rosales ..
Did you ever find a solution for this? I have run into the same issue.
Flag Flag
RE: Problem with SpringMVC when I use Liferay Porlets
8/20/09 4:54 AM as a reply to alex ace.
I am getting the same error:

13:45:46,498 ERROR [PortletHotDeployListener:663] java.lang.IllegalStateException: Root context attribute is not of type WebApplicationContext: com.liferay.portal.spring.context.PortalApplicationContext@1d8dfbf: display name [Root WebApplicationContext]; startup date [Thu Aug 20 13:40:03 GMT+02:00 2009]; root of context hierarchy
java.lang.IllegalStateException: Root context attribute is not of type WebApplicationContext: com.liferay.portal.spring.context.PortalApplicationContext@1d8dfbf: display name [Root WebApplicationContext]; startup date [Thu Aug 20 13:40:03 GMT+02:00 2009]; root of context hierarchy
at org.springframework.web.portlet.context.PortletApplicationContextUtils.getWebApplicationContext(PortletApplicationContextUtils.java:72)
at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:290)
at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:264)
at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:115)
at javax.portlet.GenericPortlet.init(GenericPortlet.java:107)
at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:250)
at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:245)
at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:135)
at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:47)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(PortletHotDeployListener.java:660)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:250)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:127)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:108)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:153)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:43)
at com.liferay.portal.kernel.servlet.PortletContextListener.portalInit(PortletContextListener.java:113)
at com.liferay.portal.kernel.util.PortalInitableUtil.init(PortalInitableUtil.java:48)
at com.liferay.portal.kernel.servlet.PortletContextListener.contextInitialized(PortletContextListener.java:109)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3099)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:404)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1309)
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.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)

This error comes when I try to deploy my application. Any ideas why this kind of error may come?
Flag Flag
RE: Problem with SpringMVC when I use Liferay Porlets
8/26/09 6:41 AM as a reply to Janne Ohtonen.
I am getting exactly the same error:

08:23:50,052 INFO [TomcatDeployment] deploy, ctxPath=/userstats-portlet
08:23:50,121 INFO [[/userstats-portlet]] Set web app root system property: 'userstats.ROOT' = [/opt/jboss/liferay/jboss-5.1.0.GA/server/default/deploy/userstats-portlet.war/]
08:23:50,175 INFO [[/userstats-portlet]] Initializing Spring root WebApplicationContext
08:23:50,175 INFO [ContextLoader] Root WebApplicationContext: initialization started
08:23:50,245 INFO [XmlWebApplicationContext] Refreshing org.springframework.web.context.support.XmlWebApplicationContext@680cb295: display name [Root WebApplicationContext]; startup date [Wed Aug 26 08:23:50 COT 2009]; root of context hierarchy
08:23:50,314 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/context/applicationContext.xml]
08:23:50,419 INFO [XmlWebApplicationContext] Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@680cb295]: org.springframework.beans.factory.support.DefaultListableBeanFactory@3bc81588
08:23:50,552 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3bc81588: defining beans [org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,messageSource,jspViewResolver,defaultExceptionHandler,systemPlaceholderConfigurer,requiredAnnotationBeanPostProcessor]; root of factory hierarchy
08:23:50,575 INFO [ContextLoader] Root WebApplicationContext: initialization completed in 395 ms
08:23:50,939 INFO [STDOUT] 08:23:50,939 INFO [PortletHotDeployListener] Registering portlets for userstats-portlet
08:23:50,968 INFO [DispatcherPortlet] Initializing portlet 'UserStatistics'
08:23:50,979 INFO [DispatcherPortlet] FrameworkPortlet 'UserStatistics': initialization started
08:23:50,986 INFO [STDOUT] 08:23:50,984 ERROR [PortletHotDeployListener] java.lang.IllegalStateException: Root context attribute is not of type WebApplicationContext: com.liferay.portal.spring.context.PortalApplicationContext@7927963: display name [Root WebApplicationContext]; startup date [Wed Aug 26 08:22:58 COT 2009]; root of context hierarchy
java.lang.IllegalStateException: Root context attribute is not of type WebApplicationContext: com.liferay.portal.spring.context.PortalApplicationContext@7927963: display name [Root WebApplicationContext]; startup date [Wed Aug 26 08:22:58 COT 2009]; root of context hierarchy
at org.springframework.web.portlet.context.PortletApplicationContextUtils.getWebApplicationContext(PortletApplicationContextUtils.java:72)

...

I've attached some files to show my settings ...

Somebody can help us please ?

Regards
Attachments: UserStatisticsContext.xml (0.9k), applicationContext.xml (2.1k), web.xml (1.4k)
Flag Flag
RE: Problem with SpringMVC when I use Liferay Porlets
spring portlet mvc
9/1/09 5:52 AM as a reply to Omar Rosales ..
Hi,

I'm getting the same error - almost. I'm not using any liferay services and the error doesn't disappear during deployment but when I redirect the browser to a page with my portlet on it.

Also the error (usually) disappeares if I just re-deploy the portlet.

But stil, I find this quite alarming. If anyone out there knows the reason - please, please share your knowledge with us.

Best wishes,

Steffi
Flag Flag
RE: Problem with SpringMVC when I use Liferay Porlets
9/2/09 12:09 PM as a reply to Anonymous.
Please, Liferay People, we buy Liferay 5.2.5 EE and this problem persist. Can anybody help us ?
Flag Flag
RE: Problem with SpringMVC when I use Liferay Porlets
9/8/09 2:01 AM as a reply to Camilo Aguilar.
According to this issue from the spring issuetracker, this is a problem with hot-deployment of spring portlets.

It seems a restart of the server is the one safe way of getting this to work.

Regards.
Flag Flag
RE: Problem with SpringMVC when I use Liferay Porlets
9/11/09 4:04 AM as a reply to Omar Rosales ..
We're having the same problem.

It seems to only have begun occurring since upgrading to 5.2.3 though, 5.2.2 was fine.
Flag Flag
RE: Problem with SpringMVC when I use Liferay Porlets
9/25/09 2:37 AM as a reply to Omar Rosales ..
Have you tried adding this to your liferay-plugin-package.properties?
1
2portal-dependency-jars=\
3    spring.jar,\
4    spring-webmvc.jar,\


Just a thought.
Flag Flag
RE: Problem with SpringMVC when I use Liferay Porlets
10/7/09 5:50 AM as a reply to Gunnar Velle.
It didn't work for me... I have the same errors poping up.

Thanks for the suggestion,

Matthieu
Flag Flag
RE: Problem with SpringMVC when I use Liferay Porlets
10/7/09 6:13 AM as a reply to Matthieu Levesque.
Hi.

You could also try adding <scope>provided</scope> to your dependenices in pom.xml. Then the jars would not be added to the lib folder of your portlet and liferay would use the provided versions of the librarys.

Regards.
Flag Flag