About the error I mentioned the exception it throws is:
Caused by: org.hibernate.LazyInitializationException: failed to lazily
initialize a collection of role:
com.level2crm.hibernate.generated.User.contactBasicDetails, no session
or session was closed
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at
org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97)
at
org.hibernate.collection.PersistentSet.isEmpty(PersistentSet.java:146)
at com.level2crm.portals.crm.wicket.customerdetail.pages.ViewModePage
$1.load(ViewModePage.java:54)
at
org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDetachableModel.java:122)
at
org.apache.wicket.Component.getDefaultModelObject(Component.java:1664)
at
org.apache.wicket.markup.html.list.ListView.getViewSize(ListView.java:221)
at
org.apache.wicket.markup.html.list.ListView.onPopulate(ListView.java:525)
at
org.apache.wicket.markup.repeater.AbstractRepeater.onBeforeRender(AbstractRepeater.java:131)
at
org.apache.wicket.Component.internalBeforeRender(Component.java:1061)
at org.apache.wicket.Component.beforeRender(Component.java:1095)
at
org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1751)
... 109 more
May this have something to do with selected configuration?
Thank you again.
El vie, 14-08-2009 a las 10:53 +0200, Gonzalo Aguilar Delgado escribió:
> Hi again,
>
> For a shake of completeness y will provide two of the working
> configurations I've found to work. I would know what's the one
> correct and why. Someone can throw a little bit light on this issue,
> please?
>
> -=[ First Choice ]=-
>
>
> -----------------------------------------
> web.xml
> -----------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <!--
> Licensed to the Apache Software Foundation (ASF) under one
> or more contributor license agreements. See the NOTICE file
> distributed with this work for additional information
> regarding copyright ownership. The ASF licenses this file
> to you under the Apache License, Version 2.0 (the
> "License"); you may not use this file except in compliance
> with the License. You may obtain a copy of the License at
>
> http://www.apache.org/licenses/LICENSE-2.0
>
> Unless required by applicable law or agreed to in writing,
> software distributed under the License is distributed on an
> "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> KIND, either express or implied. See the License for the
> specific language governing permissions and limitations
> under the License.
> -->
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
> <display-name>My Portlet Application</display-name>
>
> <!-- For deploying on Websphere: disable WebSphere default
> portletcontainer
> However: if you actually want to deploy on WebSphere Portal,
> comment the following out -->
>
> <context-param>
>
> <param-name>com.ibm.websphere.portletcontainer.PortletDeploymentEnabled</param-name>
> <param-value>false</param-value>
> </context-param>
>
> <!-- This is for Spring self configuration -->
> <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>
>
> <!-- Enable the filters for Hibernate (How to check it's working?)-->
>
> <filter>
> <filter-name>opensessioninview</filter-name>
>
> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
> </filter>
> <filter-mapping>
> <filter-name>opensessioninview</filter-name>
> <url-pattern>/hibernate/*</url-pattern>
> </filter-mapping>
> <!-- END hibernate filters -->
>
>
> <!-- Wicket filters -->
> <filter>
> <filter-name>CustomerListPortlet</filter-name>
>
> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
> <init-param>
> <param-name>applicationClassName</param-name>
>
> <param-value>com.level2crm.portals.crm.wicket.customerlist.WicketCustomerListApplication</param-value>
> <!-- Normally this should be
> org.apache.wicket.spring.SpringWebApplicationFactory, but why? -->
> </init-param>
> <init-param>
> <param-name>portletOnlyFilter</param-name>
> <param-value>true</param-value>
> </init-param>
> </filter>
> <filter-mapping>
> <filter-name>CustomerListPortlet</filter-name>
> <url-pattern>/CustomerListPortlet/*</url-pattern>
> <dispatcher>REQUEST</dispatcher>
> <dispatcher>INCLUDE</dispatcher>
> <dispatcher>FORWARD</dispatcher>
> </filter-mapping>
> <!-- END Wicket filters -->
>
> <context-param>
> <param-name>org.apache.wicket.detectPortletContext</param-name>
> <param-value>true</param-value>
> </context-param>
> <!-- END Wicket filters -->
>
>
> <!--
> Serves static resource content from .jar files such as
> spring-faces.jar
> -->
> <!--
> <servlet>
> <servlet-name>Resource Servlet</servlet-name>
>
> <servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
> <load-on-startup>0</load-on-startup>
> </servlet>
>
>
>
> <!-- Added when deployed with maven -->
> <servlet>
> <description>MVC Servlet for Jetspeed Portlet
> Applications</description>
> <display-name>Jetspeed Container</display-name>
> <servlet-name>JetspeedContainer</servlet-name>
>
> <servlet-class>org.apache.jetspeed.container.JetspeedContainerServlet</servlet-class>
> <init-param>
> <param-name>contextName</param-name>
> <param-value>crmportal-contact</param-value>
> </init-param>
> <load-on-startup>0</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>JetspeedContainer</servlet-name>
> <url-pattern>/container/*</url-pattern>
> </servlet-mapping>
> <jsp-config>
> <taglib>
> <taglib-uri>http://java.sun.com/portlet</taglib-uri>
>
> <taglib-location>/WEB-INF/tld/portlet.tld</taglib-location>
> </taglib>
> <taglib>
> <taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri>
>
> <taglib-location>/WEB-INF/tld/portlet_2_0.tld</taglib-location>
> </taglib>
> </jsp-config>
>
>
> </web-app>
>
>
> -----------------------------------------
> portlet.xml
> -----------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!--
> Licensed to the Apache Software Foundation (ASF) under one or
> more
> contributor license agreements. See the NOTICE file distributed
> with
> this work for additional information regarding copyright
> ownership.
> The ASF licenses this file to you under the Apache License,
> Version
> 2.0 (the "License"); you may not use this file except in
> compliance
> with the License. You may obtain a copy of the License at
>
> http://www.apache.org/licenses/LICENSE-2.0 Unless required by
> applicable law or agreed to in writing, software distributed
> under the
> License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
> OR
> CONDITIONS OF ANY KIND, either express or implied. See the
> License for
> the specific language governing permissions and limitations
> under the
> License.
> -->
> <portlet-app
> xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
> version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
> http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
>
> <portlet>
> <description>Customer viewer</description>
> <portlet-name>crm-customer-list</portlet-name>
> <display-name>Customer list viewer</display-name>
>
> <portlet-class>com.level2crm.portals.crm.wicket.customerlist.CustomerListPortlet</portlet-class>
> <init-param>
> <name>wicketFilterPath</name>
> <value>/CustomerListPortlet</value>
> </init-param>
>
> <supports>
> <mime-type>*/*</mime-type>
> <portlet-mode>VIEW</portlet-mode>
> <portlet-mode>EDIT</portlet-mode>
> </supports>
> <supported-locale>es</supported-locale>
> <portlet-info>
> <title>Customer list viewer</title>
> <short-title>Customer list viewer</short-title>
> <keywords>none</keywords>
> </portlet-info>
>
> <supported-public-render-parameter>crmportal:userId</supported-public-render-parameter>
> </portlet>
>
> </portlet-app>
>
> -----------------------------------------
> applicationContext.xml
> -----------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:tx="http://www.springframework.org/schema/tx"
> xmlns:aop="http://www.springframework.org/schema/aop"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://www.springframework.org/schema/tx
> http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
> http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
>
>
> <!-- Modules Includes -->
> <import resource="classpath:/conf/spring/hibernate-spring-beans.xml"/>
> <!-- Here comes the connection string and the pool -->
> <import
> resource="classpath:/conf/spring/transaction-spring-beans.xml"/>
> <!--
> Here comes the transaction management stuff -->
>
> <import
> resource="classpath:/conf/spring/address-dao-spring-beans.xml"/>
> <!--
> Here comes the basic data objects for DB management -->
> <import
> resource="classpath:/conf/spring/contact-dao-spring-beans.xml"/>
> <!--
> Here comes the basic data objects for DB management -->
>
> <import
> resource="classpath:/conf/spring/dao-manager-spring-beans.xml"/>
> <!--
> Here comes the manager objects for DB management, they implement the
> MODEL -->
>
> </beans>
>
>
> .----------------------------------------
> Comments
> -----------------------------------------
>
> I found this to work well. Spring gets initialized and everything works.
> The only problem I've found is that hibernate session does not start
> when needed.
> I have to check why. Maybe a problem with this configuration?
>
>
>
>
> -=[ First Option ]=-
>
>
> -----------------------------------------
> web.xml
> -----------------------------------------
>
> Same above, but filters:
>
>
>
> <!-- Wicket filters -->
> <filter>
> <filter-name>CustomerListPortlet</filter-name>
>
> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
> <init-param>
> <param-name>applicationFactoryClassName</param-name>
>
> <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
> </init-param>
> <init-param>
> <param-name>applicationBean</param-name>
> <param-value>customerListPortletBean</param-value>
> </init-param>
> </filter>
> <filter-mapping>
> <filter-name>CustomerListPortlet</filter-name>
> <url-pattern>/CustomerListPortlet/*</url-pattern>
> <dispatcher>REQUEST</dispatcher>
> <dispatcher>INCLUDE</dispatcher>
> </filter-mapping>
> <!-- END Wicket filters -->
>
> So the application is a bean that gets initialized by Spring.
>
> -----------------------------------------
> portlet.xml
> -----------------------------------------
>
> Same but portlet gets:
>
> <portlet>
> <description>Customer viewer</description>
> <portlet-name>crm-customer-list</portlet-name>
> <display-name>Customer details viewer</display-name>
>
> <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
> <init-param>
> <name>wicketFilterPath</name>
> <value>/CustomerListPortlet</value>
> </init-param>
> <supports>
> <mime-type>*/*</mime-type>
> <portlet-mode>VIEW</portlet-mode>
> </supports>
> <supported-locale>es</supported-locale>
> <portlet-info>
> <title>Customer viewer</title>
> <short-title>Customer viewer</short-title>
> <keywords>none</keywords>
> </portlet-info>
> </portlet>
>
> Now it's a wicket portlet but I really don't know why it uses the
> correct portlet class as is not defined anyplace...
>
>
>
> -----------------------------------------
> applicationContext.xml
> -----------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:tx="http://www.springframework.org/schema/tx"
> xmlns:aop="http://www.springframework.org/schema/aop"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://www.springframework.org/schema/tx
> http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
> http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
>
>
> <!-- Modules Includes -->
> <import resource="classpath:/conf/spring/hibernate-spring-beans.xml"/>
> <!-- Here comes the connection string and the pool -->
> <import resource="classpath:/conf/spring/transaction-spring-beans.xml"/>
> <!-- Here comes the transaction management stuff -->
>
> <import resource="classpath:/conf/spring/address-dao-spring-beans.xml"/>
> <!-- Here comes the basic data objects for DB management -->
> <import resource="classpath:/conf/spring/contact-dao-spring-beans.xml"/>
> <!-- Here comes the basic data objects for DB management -->
>
> <import resource="classpath:/conf/spring/dao-manager-spring-beans.xml"/>
> <!-- Here comes the manager objects for DB management, they implement
> the MODEL -->
>
> <!-- Portlet Beans -->
> <import resource="portlet-beans.xml"/>
> <!-- Here comes the wicket
> portlet beans -->
>
> </beans>
>
>
> -----------------------------------------
> portlet-beans.xml
> -----------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:tx="http://www.springframework.org/schema/tx"
> xmlns:aop="http://www.springframework.org/schema/aop"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://www.springframework.org/schema/tx
> http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
> http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
>
> <!-- setup wicket application -->
> <bean id="customerListPortletBean"
> class="com.level2crm.portals.crm.wicket.customerlist.CustomerListPortlet">
> </bean>
>
>
> </beans>
>
>
>
> .----------------------------------------
> Comments
> -----------------------------------------
>
> I think this option is darker than the other one. But I think none of
> both are right. So What's the correct way to do it?
>
>
> Thank you!