You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Gonzalo Aguilar Delgado <ga...@eto-marketing.com> on 2009/08/14 10:53:52 UTC

CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

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!

Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
Hi again! 

I'm really lost on this toppic. It seems to not work. 

First of all. Can someone post a complete configuration of a wicket
portlet + spring, please?

I found several ways to do it but none seems to be correct.

Thank you.



El mar, 18-08-2009 a las 09:53 +0200, nino martinez wael escribió:

> Happy to help, please see further answers below.
> 
> 2009/8/17 Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>:
> >
> >
> >> I have several suggestions.
> >>
> >> The order of the web filters are important. You could also try with
> >> with the wicket spring managed apps, im not sure how that applies.
> >
> > Will check. I didn't know about filter order... Will also check it.
> > Thanks!
> >
> >
> >>
> >> And are you sure that your filter ( /hibernate/*), get's hit? What's
> >> your wicket filter url, the same or?
> >
> >
> > No, It's different. Can I set it to just "/*"? Should I do it that way?
> Well it depends, if the hibernate filter should be activated at the
> same url's as wicket.
> 
> I've never had a case where my wicket filter and osiw did not match.
> You might have performance increases if they differ, for example if
> you know that you willl never use hibernate on /myapp/ but always put
> in /myapp/pages/dynamic/*  for pages that use db lookup..
> >
> > Thank you very much for your answers...
> >
> >
> >
> >>
> >> 2009/8/17 Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>:
> >> > Ok. Maybe I don't understand...
> >> >
> >> > Let me show the situation. I have Spring + portlet + hibernate config
> >> > with transactions working with the current configuration:
> >> >
> >> > I have my DAO objects under package
> >> > com.level2crm.hibernate.enterprise.dao.contact
> >> > And model under com.level2crm.model
> >> >
> >> > I configured one advice:
> >> >        <tx:advice id="txAdvice" transaction-manager="txManager">
> >> >                <!-- the transactional semantics... -->
> >> >                <tx:attributes>
> >> >                        <!-- all methods starting with 'get' are read-only -->
> >> >                        <tx:method name="get*"  propagation="REQUIRED" read-only="true" />
> >> >                        <!-- other methods use the default transaction settings (see below)
> >> > -->
> >> >                        <tx:method name="*"  propagation="REQUIRED" /> <!--
> >> > propagation="SUPPORTS" -->
> >> >                </tx:attributes>
> >> >        </tx:advice>
> >> >
> >> > And several pointcuts:
> >> >        <aop:config>
> >> >                <aop:pointcut id="allModelOperation" expression="execution(*
> >> > com.level2crm.model..*+.*(..))"/>
> >> >                <aop:advisor advice-ref="txAdvice"
> >> > pointcut-ref="allModelOperation"/>
> >> >        </aop:config>
> >> >
> >> >        <aop:config>
> >> >                <aop:pointcut id="allDAO" expression="execution(*
> >> > com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
> >> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
> >> >        </aop:config>
> >> >
> >> >        <aop:config>
> >> >                <aop:pointcut id="TRG" expression="execution(*
> >> > com.trg.dao.hibernate.*+.*(..))"/>
> >> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="TRG"/>
> >> >        </aop:config>
> >> >
> >> > <!-- This one does not work -->
> >> >    <aop:config>
> >> >                <aop:pointcut id="portlets" expression="execution(*
> >> > com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
> >> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
> >> >        </aop:config>
> >> >
> >> > I tried to configure the open session in view (web.xml):
> >> >        <listener>
> >> >
> >> > <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
> >> >        </listener>
> >> >
> >> >        <!-- Enable the filters for Hibernate -->
> >> >
> >> >        <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 -->
> >> >
> >> >
> >> >
> >> > But I found that this does not work. Because:
> >> >
> >> >
> >> > public class ViewModePage extends org.apache.wicket.markup.html.WebPage
> >> > {
> >> > ...
> >> >
> >> >        @SpringBean(name = "userDAOBean")
> >> >        private UserDAO userDAO;
> >> >
> >> >
> >> >        IModel loadableUserModel = new LoadableDetachableModel() {
> >> >
> >> >                @Override
> >> >                protected Object load(){
> >> >                        User selectedUser = null;
> >> >                        String value =
> >> > ((PortletRequestContext)RequestContext.get()).getPortletRequest().getParameter("crmportal:userId");
> >> >                        if(value!=null)
> >> >                        {
> >> >                                UuidUserType uuid = UuidUserType.fromString(value); //Works!!
> >> >                                userDAO.testSessoion(uuid);//Works!!
> >> >
> >> >                                selectedUser = userDAO.find(uuid);//Works!!
> >> >
> >> >                                if(!userDAO.isAttached(selectedUser)) //Works!! But is not
> >> > attached!!!
> >> >                                {
> >> >
> >> >                                        userDAO.save(selectedUser); //Attach it     //Works!! It
> >> > saves/updates the object but it's still not attached
> >> >                                }
> >> >
> >> >
> >> >
> >> >                                Set<ContactBasicDetail> setDetails =
> >> > selectedUser.getContactBasicDetails(); //Works!! It gets the set
> >> >                                setDetails.isEmpty(); // FAIL FAIL Cannot load lazy
> >> >
> >> >                                return setDetails.toArray();
> >> >                        }
> >> >                        return null;
> >> >                }
> >> >
> >> >
> >> >        };
> >> > ...
> >> > }
> >> >
> >> >
> >> > This load() function does not work! It makes the exception. But:
> >> >
> >> >
> >> >        1.- It can get the User. Because the pointcut works inside the
> >> >        DAO?
> >> >        2.- It can save the object. Because the pointcut works inside
> >> >        the DAO?
> >> >        3.- It can get the Set. Because the pointcut works inside the
> >> >        DAO?
> >> >
> >> >
> >> > The  userDAO.testSessoion(uuid); function inside the DAO object works.
> >> > What I do is to get the Hibernate session, check that is ok. And check
> >> > also if the transaction was created and I can attach and use object.
> >> > Inside the userDAO.testSessoion function I do the same code that in the
> >> > load() function but this time everything works!
> >> >
> >> > I'm sure that it works because it has a session and a open transaction
> >> > due to the pointcut defined as follows works above:
> >> >
> >> >  <aop:config>
> >> >  <aop:pointcut id="allDAO" expression="execution(*
> >> > com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
> >> >  <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
> >> >  </aop:config>
> >> >
> >> >
> >> > What is not working is the pointcut that should provide a
> >> > transaction/session to the page:
> >> > <!-- This one does not work -->
> >> >    <aop:config>
> >> >  <aop:pointcut id="portlets" expression="execution(*
> >> > com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
> >> >  <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
> >> >  </aop:config>
> >> >
> >> > And I think this has something to do with the hibernate+wicket
> >> > configuration. As the page is not created by the Spring bean interface
> >> > it cannot
> >> > make a proxy around it. So it will never get the session/transaction.
> >> >
> >> >
> >> > Opening a session with the view manually will make my pointcuts not
> >> > usable so I will loose the control over what classes
> >> > will be managed and over transactions. Do will I?
> >> >
> >> >
> >> >
> >> >
> >> >> >> Yup so you should either use open session in view or more preferred
> >> >> >> AFAIK detachable models.
> >> >
> >> > Yep, I do it but it does not work. Indeed it fails inside the load()
> >> > function. That makes me thing something is wrong configured...
> >> >
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org

Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.

Hi again! 

I'm really lost on this toppic. It seems to not work. 

First of all. Can someone post a complete configuration of a wicket
portlet + spring, please?

I found several ways to do it but none seems to be correct.

Thank you.



El mar, 18-08-2009 a las 09:53 +0200, nino martinez wael escribió: 

> Happy to help, please see further answers below.
> 
> 2009/8/17 Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>:
> >
> >
> >> I have several suggestions.
> >>
> >> The order of the web filters are important. You could also try with
> >> with the wicket spring managed apps, im not sure how that applies.
> >
> > Will check. I didn't know about filter order... Will also check it.
> > Thanks!
> >
> >
> >>
> >> And are you sure that your filter ( /hibernate/*), get's hit? What's
> >> your wicket filter url, the same or?
> >
> >
> > No, It's different. Can I set it to just "/*"? Should I do it that way?
> Well it depends, if the hibernate filter should be activated at the
> same url's as wicket.
> 
> I've never had a case where my wicket filter and osiw did not match.
> You might have performance increases if they differ, for example if
> you know that you willl never use hibernate on /myapp/ but always put
> in /myapp/pages/dynamic/*  for pages that use db lookup..
> >
> > Thank you very much for your answers...
> >
> >
> >
> >>
> >> 2009/8/17 Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>:
> >> > Ok. Maybe I don't understand...
> >> >
> >> > Let me show the situation. I have Spring + portlet + hibernate config
> >> > with transactions working with the current configuration:
> >> >
> >> > I have my DAO objects under package
> >> > com.level2crm.hibernate.enterprise.dao.contact
> >> > And model under com.level2crm.model
> >> >
> >> > I configured one advice:
> >> >        <tx:advice id="txAdvice" transaction-manager="txManager">
> >> >                <!-- the transactional semantics... -->
> >> >                <tx:attributes>
> >> >                        <!-- all methods starting with 'get' are read-only -->
> >> >                        <tx:method name="get*"  propagation="REQUIRED" read-only="true" />
> >> >                        <!-- other methods use the default transaction settings (see below)
> >> > -->
> >> >                        <tx:method name="*"  propagation="REQUIRED" /> <!--
> >> > propagation="SUPPORTS" -->
> >> >                </tx:attributes>
> >> >        </tx:advice>
> >> >
> >> > And several pointcuts:
> >> >        <aop:config>
> >> >                <aop:pointcut id="allModelOperation" expression="execution(*
> >> > com.level2crm.model..*+.*(..))"/>
> >> >                <aop:advisor advice-ref="txAdvice"
> >> > pointcut-ref="allModelOperation"/>
> >> >        </aop:config>
> >> >
> >> >        <aop:config>
> >> >                <aop:pointcut id="allDAO" expression="execution(*
> >> > com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
> >> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
> >> >        </aop:config>
> >> >
> >> >        <aop:config>
> >> >                <aop:pointcut id="TRG" expression="execution(*
> >> > com.trg.dao.hibernate.*+.*(..))"/>
> >> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="TRG"/>
> >> >        </aop:config>
> >> >
> >> > <!-- This one does not work -->
> >> >    <aop:config>
> >> >                <aop:pointcut id="portlets" expression="execution(*
> >> > com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
> >> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
> >> >        </aop:config>
> >> >
> >> > I tried to configure the open session in view (web.xml):
> >> >        <listener>
> >> >
> >> > <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
> >> >        </listener>
> >> >
> >> >        <!-- Enable the filters for Hibernate -->
> >> >
> >> >        <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 -->
> >> >
> >> >
> >> >
> >> > But I found that this does not work. Because:
> >> >
> >> >
> >> > public class ViewModePage extends org.apache.wicket.markup.html.WebPage
> >> > {
> >> > ...
> >> >
> >> >        @SpringBean(name = "userDAOBean")
> >> >        private UserDAO userDAO;
> >> >
> >> >
> >> >        IModel loadableUserModel = new LoadableDetachableModel() {
> >> >
> >> >                @Override
> >> >                protected Object load(){
> >> >                        User selectedUser = null;
> >> >                        String value =
> >> > ((PortletRequestContext)RequestContext.get()).getPortletRequest().getParameter("crmportal:userId");
> >> >                        if(value!=null)
> >> >                        {
> >> >                                UuidUserType uuid = UuidUserType.fromString(value); //Works!!
> >> >                                userDAO.testSessoion(uuid);//Works!!
> >> >
> >> >                                selectedUser = userDAO.find(uuid);//Works!!
> >> >
> >> >                                if(!userDAO.isAttached(selectedUser)) //Works!! But is not
> >> > attached!!!
> >> >                                {
> >> >
> >> >                                        userDAO.save(selectedUser); //Attach it     //Works!! It
> >> > saves/updates the object but it's still not attached
> >> >                                }
> >> >
> >> >
> >> >
> >> >                                Set<ContactBasicDetail> setDetails =
> >> > selectedUser.getContactBasicDetails(); //Works!! It gets the set
> >> >                                setDetails.isEmpty(); // FAIL FAIL Cannot load lazy
> >> >
> >> >                                return setDetails.toArray();
> >> >                        }
> >> >                        return null;
> >> >                }
> >> >
> >> >
> >> >        };
> >> > ...
> >> > }
> >> >
> >> >
> >> > This load() function does not work! It makes the exception. But:
> >> >
> >> >
> >> >        1.- It can get the User. Because the pointcut works inside the
> >> >        DAO?
> >> >        2.- It can save the object. Because the pointcut works inside
> >> >        the DAO?
> >> >        3.- It can get the Set. Because the pointcut works inside the
> >> >        DAO?
> >> >
> >> >
> >> > The  userDAO.testSessoion(uuid); function inside the DAO object works.
> >> > What I do is to get the Hibernate session, check that is ok. And check
> >> > also if the transaction was created and I can attach and use object.
> >> > Inside the userDAO.testSessoion function I do the same code that in the
> >> > load() function but this time everything works!
> >> >
> >> > I'm sure that it works because it has a session and a open transaction
> >> > due to the pointcut defined as follows works above:
> >> >
> >> >  <aop:config>
> >> >  <aop:pointcut id="allDAO" expression="execution(*
> >> > com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
> >> >  <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
> >> >  </aop:config>
> >> >
> >> >
> >> > What is not working is the pointcut that should provide a
> >> > transaction/session to the page:
> >> > <!-- This one does not work -->
> >> >    <aop:config>
> >> >  <aop:pointcut id="portlets" expression="execution(*
> >> > com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
> >> >  <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
> >> >  </aop:config>
> >> >
> >> > And I think this has something to do with the hibernate+wicket
> >> > configuration. As the page is not created by the Spring bean interface
> >> > it cannot
> >> > make a proxy around it. So it will never get the session/transaction.
> >> >
> >> >
> >> > Opening a session with the view manually will make my pointcuts not
> >> > usable so I will loose the control over what classes
> >> > will be managed and over transactions. Do will I?
> >> >
> >> >
> >> >
> >> >
> >> >> >> Yup so you should either use open session in view or more preferred
> >> >> >> AFAIK detachable models.
> >> >
> >> > Yep, I do it but it does not work. Indeed it fails inside the load()
> >> > function. That makes me thing something is wrong configured...
> >> >
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org

Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by nino martinez wael <ni...@gmail.com>.
Happy to help, please see further answers below.

2009/8/17 Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>:
>
>
>> I have several suggestions.
>>
>> The order of the web filters are important. You could also try with
>> with the wicket spring managed apps, im not sure how that applies.
>
> Will check. I didn't know about filter order... Will also check it.
> Thanks!
>
>
>>
>> And are you sure that your filter ( /hibernate/*), get's hit? What's
>> your wicket filter url, the same or?
>
>
> No, It's different. Can I set it to just "/*"? Should I do it that way?
Well it depends, if the hibernate filter should be activated at the
same url's as wicket.

I've never had a case where my wicket filter and osiw did not match.
You might have performance increases if they differ, for example if
you know that you willl never use hibernate on /myapp/ but always put
in /myapp/pages/dynamic/*  for pages that use db lookup..
>
> Thank you very much for your answers...
>
>
>
>>
>> 2009/8/17 Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>:
>> > Ok. Maybe I don't understand...
>> >
>> > Let me show the situation. I have Spring + portlet + hibernate config
>> > with transactions working with the current configuration:
>> >
>> > I have my DAO objects under package
>> > com.level2crm.hibernate.enterprise.dao.contact
>> > And model under com.level2crm.model
>> >
>> > I configured one advice:
>> >        <tx:advice id="txAdvice" transaction-manager="txManager">
>> >                <!-- the transactional semantics... -->
>> >                <tx:attributes>
>> >                        <!-- all methods starting with 'get' are read-only -->
>> >                        <tx:method name="get*"  propagation="REQUIRED" read-only="true" />
>> >                        <!-- other methods use the default transaction settings (see below)
>> > -->
>> >                        <tx:method name="*"  propagation="REQUIRED" /> <!--
>> > propagation="SUPPORTS" -->
>> >                </tx:attributes>
>> >        </tx:advice>
>> >
>> > And several pointcuts:
>> >        <aop:config>
>> >                <aop:pointcut id="allModelOperation" expression="execution(*
>> > com.level2crm.model..*+.*(..))"/>
>> >                <aop:advisor advice-ref="txAdvice"
>> > pointcut-ref="allModelOperation"/>
>> >        </aop:config>
>> >
>> >        <aop:config>
>> >                <aop:pointcut id="allDAO" expression="execution(*
>> > com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
>> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
>> >        </aop:config>
>> >
>> >        <aop:config>
>> >                <aop:pointcut id="TRG" expression="execution(*
>> > com.trg.dao.hibernate.*+.*(..))"/>
>> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="TRG"/>
>> >        </aop:config>
>> >
>> > <!-- This one does not work -->
>> >    <aop:config>
>> >                <aop:pointcut id="portlets" expression="execution(*
>> > com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
>> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
>> >        </aop:config>
>> >
>> > I tried to configure the open session in view (web.xml):
>> >        <listener>
>> >
>> > <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>> >        </listener>
>> >
>> >        <!-- Enable the filters for Hibernate -->
>> >
>> >        <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 -->
>> >
>> >
>> >
>> > But I found that this does not work. Because:
>> >
>> >
>> > public class ViewModePage extends org.apache.wicket.markup.html.WebPage
>> > {
>> > ...
>> >
>> >        @SpringBean(name = "userDAOBean")
>> >        private UserDAO userDAO;
>> >
>> >
>> >        IModel loadableUserModel = new LoadableDetachableModel() {
>> >
>> >                @Override
>> >                protected Object load(){
>> >                        User selectedUser = null;
>> >                        String value =
>> > ((PortletRequestContext)RequestContext.get()).getPortletRequest().getParameter("crmportal:userId");
>> >                        if(value!=null)
>> >                        {
>> >                                UuidUserType uuid = UuidUserType.fromString(value); //Works!!
>> >                                userDAO.testSessoion(uuid);//Works!!
>> >
>> >                                selectedUser = userDAO.find(uuid);//Works!!
>> >
>> >                                if(!userDAO.isAttached(selectedUser)) //Works!! But is not
>> > attached!!!
>> >                                {
>> >
>> >                                        userDAO.save(selectedUser); //Attach it     //Works!! It
>> > saves/updates the object but it's still not attached
>> >                                }
>> >
>> >
>> >
>> >                                Set<ContactBasicDetail> setDetails =
>> > selectedUser.getContactBasicDetails(); //Works!! It gets the set
>> >                                setDetails.isEmpty(); // FAIL FAIL Cannot load lazy
>> >
>> >                                return setDetails.toArray();
>> >                        }
>> >                        return null;
>> >                }
>> >
>> >
>> >        };
>> > ...
>> > }
>> >
>> >
>> > This load() function does not work! It makes the exception. But:
>> >
>> >
>> >        1.- It can get the User. Because the pointcut works inside the
>> >        DAO?
>> >        2.- It can save the object. Because the pointcut works inside
>> >        the DAO?
>> >        3.- It can get the Set. Because the pointcut works inside the
>> >        DAO?
>> >
>> >
>> > The  userDAO.testSessoion(uuid); function inside the DAO object works.
>> > What I do is to get the Hibernate session, check that is ok. And check
>> > also if the transaction was created and I can attach and use object.
>> > Inside the userDAO.testSessoion function I do the same code that in the
>> > load() function but this time everything works!
>> >
>> > I'm sure that it works because it has a session and a open transaction
>> > due to the pointcut defined as follows works above:
>> >
>> >  <aop:config>
>> >  <aop:pointcut id="allDAO" expression="execution(*
>> > com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
>> >  <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
>> >  </aop:config>
>> >
>> >
>> > What is not working is the pointcut that should provide a
>> > transaction/session to the page:
>> > <!-- This one does not work -->
>> >    <aop:config>
>> >  <aop:pointcut id="portlets" expression="execution(*
>> > com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
>> >  <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
>> >  </aop:config>
>> >
>> > And I think this has something to do with the hibernate+wicket
>> > configuration. As the page is not created by the Spring bean interface
>> > it cannot
>> > make a proxy around it. So it will never get the session/transaction.
>> >
>> >
>> > Opening a session with the view manually will make my pointcuts not
>> > usable so I will loose the control over what classes
>> > will be managed and over transactions. Do will I?
>> >
>> >
>> >
>> >
>> >> >> Yup so you should either use open session in view or more preferred
>> >> >> AFAIK detachable models.
>> >
>> > Yep, I do it but it does not work. Indeed it fails inside the load()
>> > function. That makes me thing something is wrong configured...
>> >
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.

> I have several suggestions.
> 
> The order of the web filters are important. You could also try with
> with the wicket spring managed apps, im not sure how that applies.

Will check. I didn't know about filter order... Will also check it.
Thanks!


> 
> And are you sure that your filter ( /hibernate/*), get's hit? What's
> your wicket filter url, the same or?


No, It's different. Can I set it to just "/*"? Should I do it that way?

Thank you very much for your answers...



> 
> 2009/8/17 Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>:
> > Ok. Maybe I don't understand...
> >
> > Let me show the situation. I have Spring + portlet + hibernate config
> > with transactions working with the current configuration:
> >
> > I have my DAO objects under package
> > com.level2crm.hibernate.enterprise.dao.contact
> > And model under com.level2crm.model
> >
> > I configured one advice:
> >        <tx:advice id="txAdvice" transaction-manager="txManager">
> >                <!-- the transactional semantics... -->
> >                <tx:attributes>
> >                        <!-- all methods starting with 'get' are read-only -->
> >                        <tx:method name="get*"  propagation="REQUIRED" read-only="true" />
> >                        <!-- other methods use the default transaction settings (see below)
> > -->
> >                        <tx:method name="*"  propagation="REQUIRED" /> <!--
> > propagation="SUPPORTS" -->
> >                </tx:attributes>
> >        </tx:advice>
> >
> > And several pointcuts:
> >        <aop:config>
> >                <aop:pointcut id="allModelOperation" expression="execution(*
> > com.level2crm.model..*+.*(..))"/>
> >                <aop:advisor advice-ref="txAdvice"
> > pointcut-ref="allModelOperation"/>
> >        </aop:config>
> >
> >        <aop:config>
> >                <aop:pointcut id="allDAO" expression="execution(*
> > com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
> >        </aop:config>
> >
> >        <aop:config>
> >                <aop:pointcut id="TRG" expression="execution(*
> > com.trg.dao.hibernate.*+.*(..))"/>
> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="TRG"/>
> >        </aop:config>
> >
> > <!-- This one does not work -->
> >    <aop:config>
> >                <aop:pointcut id="portlets" expression="execution(*
> > com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
> >                <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
> >        </aop:config>
> >
> > I tried to configure the open session in view (web.xml):
> >        <listener>
> >
> > <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
> >        </listener>
> >
> >        <!-- Enable the filters for Hibernate -->
> >
> >        <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 -->
> >
> >
> >
> > But I found that this does not work. Because:
> >
> >
> > public class ViewModePage extends org.apache.wicket.markup.html.WebPage
> > {
> > ...
> >
> >        @SpringBean(name = "userDAOBean")
> >        private UserDAO userDAO;
> >
> >
> >        IModel loadableUserModel = new LoadableDetachableModel() {
> >
> >                @Override
> >                protected Object load(){
> >                        User selectedUser = null;
> >                        String value =
> > ((PortletRequestContext)RequestContext.get()).getPortletRequest().getParameter("crmportal:userId");
> >                        if(value!=null)
> >                        {
> >                                UuidUserType uuid = UuidUserType.fromString(value); //Works!!
> >                                userDAO.testSessoion(uuid);//Works!!
> >
> >                                selectedUser = userDAO.find(uuid);//Works!!
> >
> >                                if(!userDAO.isAttached(selectedUser)) //Works!! But is not
> > attached!!!
> >                                {
> >
> >                                        userDAO.save(selectedUser); //Attach it     //Works!! It
> > saves/updates the object but it's still not attached
> >                                }
> >
> >
> >
> >                                Set<ContactBasicDetail> setDetails =
> > selectedUser.getContactBasicDetails(); //Works!! It gets the set
> >                                setDetails.isEmpty(); // FAIL FAIL Cannot load lazy
> >
> >                                return setDetails.toArray();
> >                        }
> >                        return null;
> >                }
> >
> >
> >        };
> > ...
> > }
> >
> >
> > This load() function does not work! It makes the exception. But:
> >
> >
> >        1.- It can get the User. Because the pointcut works inside the
> >        DAO?
> >        2.- It can save the object. Because the pointcut works inside
> >        the DAO?
> >        3.- It can get the Set. Because the pointcut works inside the
> >        DAO?
> >
> >
> > The  userDAO.testSessoion(uuid); function inside the DAO object works.
> > What I do is to get the Hibernate session, check that is ok. And check
> > also if the transaction was created and I can attach and use object.
> > Inside the userDAO.testSessoion function I do the same code that in the
> > load() function but this time everything works!
> >
> > I'm sure that it works because it has a session and a open transaction
> > due to the pointcut defined as follows works above:
> >
> >  <aop:config>
> >  <aop:pointcut id="allDAO" expression="execution(*
> > com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
> >  <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
> >  </aop:config>
> >
> >
> > What is not working is the pointcut that should provide a
> > transaction/session to the page:
> > <!-- This one does not work -->
> >    <aop:config>
> >  <aop:pointcut id="portlets" expression="execution(*
> > com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
> >  <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
> >  </aop:config>
> >
> > And I think this has something to do with the hibernate+wicket
> > configuration. As the page is not created by the Spring bean interface
> > it cannot
> > make a proxy around it. So it will never get the session/transaction.
> >
> >
> > Opening a session with the view manually will make my pointcuts not
> > usable so I will loose the control over what classes
> > will be managed and over transactions. Do will I?
> >
> >
> >
> >
> >> >> Yup so you should either use open session in view or more preferred
> >> >> AFAIK detachable models.
> >
> > Yep, I do it but it does not work. Indeed it fails inside the load()
> > function. That makes me thing something is wrong configured...
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org

Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by nino martinez wael <ni...@gmail.com>.
Hmm

I have several suggestions.

The order of the web filters are important. You could also try with
with the wicket spring managed apps, im not sure how that applies.

And are you sure that your filter ( /hibernate/*), get's hit? What's
your wicket filter url, the same or?

2009/8/17 Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>:
> Ok. Maybe I don't understand...
>
> Let me show the situation. I have Spring + portlet + hibernate config
> with transactions working with the current configuration:
>
> I have my DAO objects under package
> com.level2crm.hibernate.enterprise.dao.contact
> And model under com.level2crm.model
>
> I configured one advice:
>        <tx:advice id="txAdvice" transaction-manager="txManager">
>                <!-- the transactional semantics... -->
>                <tx:attributes>
>                        <!-- all methods starting with 'get' are read-only -->
>                        <tx:method name="get*"  propagation="REQUIRED" read-only="true" />
>                        <!-- other methods use the default transaction settings (see below)
> -->
>                        <tx:method name="*"  propagation="REQUIRED" /> <!--
> propagation="SUPPORTS" -->
>                </tx:attributes>
>        </tx:advice>
>
> And several pointcuts:
>        <aop:config>
>                <aop:pointcut id="allModelOperation" expression="execution(*
> com.level2crm.model..*+.*(..))"/>
>                <aop:advisor advice-ref="txAdvice"
> pointcut-ref="allModelOperation"/>
>        </aop:config>
>
>        <aop:config>
>                <aop:pointcut id="allDAO" expression="execution(*
> com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
>                <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
>        </aop:config>
>
>        <aop:config>
>                <aop:pointcut id="TRG" expression="execution(*
> com.trg.dao.hibernate.*+.*(..))"/>
>                <aop:advisor advice-ref="txAdvice" pointcut-ref="TRG"/>
>        </aop:config>
>
> <!-- This one does not work -->
>    <aop:config>
>                <aop:pointcut id="portlets" expression="execution(*
> com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
>                <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
>        </aop:config>
>
> I tried to configure the open session in view (web.xml):
>        <listener>
>
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>        </listener>
>
>        <!-- Enable the filters for Hibernate -->
>
>        <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 -->
>
>
>
> But I found that this does not work. Because:
>
>
> public class ViewModePage extends org.apache.wicket.markup.html.WebPage
> {
> ...
>
>        @SpringBean(name = "userDAOBean")
>        private UserDAO userDAO;
>
>
>        IModel loadableUserModel = new LoadableDetachableModel() {
>
>                @Override
>                protected Object load(){
>                        User selectedUser = null;
>                        String value =
> ((PortletRequestContext)RequestContext.get()).getPortletRequest().getParameter("crmportal:userId");
>                        if(value!=null)
>                        {
>                                UuidUserType uuid = UuidUserType.fromString(value); //Works!!
>                                userDAO.testSessoion(uuid);//Works!!
>
>                                selectedUser = userDAO.find(uuid);//Works!!
>
>                                if(!userDAO.isAttached(selectedUser)) //Works!! But is not
> attached!!!
>                                {
>
>                                        userDAO.save(selectedUser); //Attach it     //Works!! It
> saves/updates the object but it's still not attached
>                                }
>
>
>
>                                Set<ContactBasicDetail> setDetails =
> selectedUser.getContactBasicDetails(); //Works!! It gets the set
>                                setDetails.isEmpty(); // FAIL FAIL Cannot load lazy
>
>                                return setDetails.toArray();
>                        }
>                        return null;
>                }
>
>
>        };
> ...
> }
>
>
> This load() function does not work! It makes the exception. But:
>
>
>        1.- It can get the User. Because the pointcut works inside the
>        DAO?
>        2.- It can save the object. Because the pointcut works inside
>        the DAO?
>        3.- It can get the Set. Because the pointcut works inside the
>        DAO?
>
>
> The  userDAO.testSessoion(uuid); function inside the DAO object works.
> What I do is to get the Hibernate session, check that is ok. And check
> also if the transaction was created and I can attach and use object.
> Inside the userDAO.testSessoion function I do the same code that in the
> load() function but this time everything works!
>
> I'm sure that it works because it has a session and a open transaction
> due to the pointcut defined as follows works above:
>
>  <aop:config>
>  <aop:pointcut id="allDAO" expression="execution(*
> com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
>  <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
>  </aop:config>
>
>
> What is not working is the pointcut that should provide a
> transaction/session to the page:
> <!-- This one does not work -->
>    <aop:config>
>  <aop:pointcut id="portlets" expression="execution(*
> com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
>  <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
>  </aop:config>
>
> And I think this has something to do with the hibernate+wicket
> configuration. As the page is not created by the Spring bean interface
> it cannot
> make a proxy around it. So it will never get the session/transaction.
>
>
> Opening a session with the view manually will make my pointcuts not
> usable so I will loose the control over what classes
> will be managed and over transactions. Do will I?
>
>
>
>
>> >> Yup so you should either use open session in view or more preferred
>> >> AFAIK detachable models.
>
> Yep, I do it but it does not work. Indeed it fails inside the load()
> function. That makes me thing something is wrong configured...
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
Ok. Maybe I don't understand...

Let me show the situation. I have Spring + portlet + hibernate config
with transactions working with the current configuration:

I have my DAO objects under package
com.level2crm.hibernate.enterprise.dao.contact
And model under com.level2crm.model

I configured one advice:
	<tx:advice id="txAdvice" transaction-manager="txManager">
		<!-- the transactional semantics... -->
		<tx:attributes>
			<!-- all methods starting with 'get' are read-only -->
			<tx:method name="get*"  propagation="REQUIRED" read-only="true" />
			<!-- other methods use the default transaction settings (see below)
-->
			<tx:method name="*"  propagation="REQUIRED" /> <!--
propagation="SUPPORTS" -->
		</tx:attributes>
	</tx:advice>

And several pointcuts:
	<aop:config>
  		<aop:pointcut id="allModelOperation" expression="execution(*
com.level2crm.model..*+.*(..))"/>
  		<aop:advisor advice-ref="txAdvice"
pointcut-ref="allModelOperation"/>
  	</aop:config>
  	
  	<aop:config>
  		<aop:pointcut id="allDAO" expression="execution(*
com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
  		<aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
  	</aop:config>
  	
  	<aop:config>
  		<aop:pointcut id="TRG" expression="execution(*
com.trg.dao.hibernate.*+.*(..))"/>
  		<aop:advisor advice-ref="txAdvice" pointcut-ref="TRG"/>
  	</aop:config>
  	
<!-- This one does not work -->  	
    <aop:config>
  		<aop:pointcut id="portlets" expression="execution(*
com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
  		<aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
  	</aop:config>

I tried to configure the open session in view (web.xml):
        <listener>

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

	<!-- Enable the filters for Hibernate -->

	<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 -->



But I found that this does not work. Because:


public class ViewModePage extends org.apache.wicket.markup.html.WebPage
{
...

	@SpringBean(name = "userDAOBean")
	private UserDAO userDAO;
	
	
	IModel loadableUserModel = new LoadableDetachableModel() {
		
		@Override
		protected Object load(){
			User selectedUser = null;
			String value =
((PortletRequestContext)RequestContext.get()).getPortletRequest().getParameter("crmportal:userId");
			if(value!=null)
			{
				UuidUserType uuid = UuidUserType.fromString(value); //Works!!
				userDAO.testSessoion(uuid);//Works!!
				
				selectedUser = userDAO.find(uuid);//Works!!
				
				if(!userDAO.isAttached(selectedUser)) //Works!! But is not
attached!!!
				{
					
					userDAO.save(selectedUser); //Attach it     //Works!! It
saves/updates the object but it's still not attached
				}
				
			
				
				Set<ContactBasicDetail> setDetails =
selectedUser.getContactBasicDetails(); //Works!! It gets the set
				setDetails.isEmpty(); // FAIL FAIL Cannot load lazy
				
				return setDetails.toArray();
			}
			return null;
		}
		
		
	};
...
}


This load() function does not work! It makes the exception. But:


        1.- It can get the User. Because the pointcut works inside the
        DAO?
        2.- It can save the object. Because the pointcut works inside
        the DAO?
        3.- It can get the Set. Because the pointcut works inside the
        DAO?
        

The  userDAO.testSessoion(uuid); function inside the DAO object works.
What I do is to get the Hibernate session, check that is ok. And check
also if the transaction was created and I can attach and use object.
Inside the userDAO.testSessoion function I do the same code that in the
load() function but this time everything works!

I'm sure that it works because it has a session and a open transaction
due to the pointcut defined as follows works above: 

  <aop:config>
  <aop:pointcut id="allDAO" expression="execution(*
com.level2crm.hibernate.enterprise.dao..*+.*(..))"/>
  <aop:advisor advice-ref="txAdvice" pointcut-ref="allDAO"/>
  </aop:config>


What is not working is the pointcut that should provide a
transaction/session to the page:
<!-- This one does not work -->  
    <aop:config>
  <aop:pointcut id="portlets" expression="execution(*
com.level2crm.portals.crm.wicket.customerlist.pages..*+.*(..))"/>
  <aop:advisor advice-ref="txAdvice" pointcut-ref="portlets"/>
  </aop:config>

And I think this has something to do with the hibernate+wicket
configuration. As the page is not created by the Spring bean interface
it cannot
make a proxy around it. So it will never get the session/transaction.


Opening a session with the view manually will make my pointcuts not
usable so I will loose the control over what classes
will be managed and over transactions. Do will I?




> >> Yup so you should either use open session in view or more preferred
> >> AFAIK detachable models.

Yep, I do it but it does not work. Indeed it fails inside the load()
function. That makes me thing something is wrong configured... 



Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by nino martinez wael <ni...@gmail.com>.
Why will you lose that?

2009/8/17 Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>:
> Sure?
>
>
> But I will loose control over how transactions are managed...
>
>
>
> El vie, 14-08-2009 a las 22:14 +0200, nino martinez wael escribió:
>
>> Yup so you should either use open session in view or more preferred
>> AFAIK detachable models.
>>
>> 2009/8/14 Russell Simpkins <ru...@hotmail.com>:
>> >
>> > Errors like those are caused when the hibernate session is closed too soon.
>> > https://www.hibernate.org/43.html
>> > Russ
>> >
>> >> Subject: Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)
>> >> From: gad@aguilardelgado.com
>> >> To: users@wicket.apache.org
>> >> Date: Fri, 14 Aug 2009 11:01:05 +0200
>> >>
>> >> 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!
>> >
>> > _________________________________________________________________
>> > Get your vacation photos on your phone!
>> > http://windowsliveformobile.com/en-us/photos/default.aspx?&OCID=0809TL-HM
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
Sure? 


But I will loose control over how transactions are managed...



El vie, 14-08-2009 a las 22:14 +0200, nino martinez wael escribió:

> Yup so you should either use open session in view or more preferred
> AFAIK detachable models.
> 
> 2009/8/14 Russell Simpkins <ru...@hotmail.com>:
> >
> > Errors like those are caused when the hibernate session is closed too soon.
> > https://www.hibernate.org/43.html
> > Russ
> >
> >> Subject: Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)
> >> From: gad@aguilardelgado.com
> >> To: users@wicket.apache.org
> >> Date: Fri, 14 Aug 2009 11:01:05 +0200
> >>
> >> 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!
> >
> > _________________________________________________________________
> > Get your vacation photos on your phone!
> > http://windowsliveformobile.com/en-us/photos/default.aspx?&OCID=0809TL-HM
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org

Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by nino martinez wael <ni...@gmail.com>.
Yup so you should either use open session in view or more preferred
AFAIK detachable models.

2009/8/14 Russell Simpkins <ru...@hotmail.com>:
>
> Errors like those are caused when the hibernate session is closed too soon.
> https://www.hibernate.org/43.html
> Russ
>
>> Subject: Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)
>> From: gad@aguilardelgado.com
>> To: users@wicket.apache.org
>> Date: Fri, 14 Aug 2009 11:01:05 +0200
>>
>> 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!
>
> _________________________________________________________________
> Get your vacation photos on your phone!
> http://windowsliveformobile.com/en-us/photos/default.aspx?&OCID=0809TL-HM

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by Russell Simpkins <ru...@hotmail.com>.
Errors like those are caused when the hibernate session is closed too soon.
https://www.hibernate.org/43.html
Russ

> Subject: Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)
> From: gad@aguilardelgado.com
> To: users@wicket.apache.org
> Date: Fri, 14 Aug 2009 11:01:05 +0200
> 
> 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!

_________________________________________________________________
Get your vacation photos on your phone!
http://windowsliveformobile.com/en-us/photos/default.aspx?&OCID=0809TL-HM

Re: CORRECT portlet+spring+hibernate configuration (Two options, what's right?)

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
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!