Announcement Announcement Module
Collapse
No announcement yet.
Portlet,Facelets,MyFaces LazyInitializationException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Portlet,Facelets,MyFaces LazyInitializationException

    Hallo,

    i am using portlets 2.0, facelets and myfaces (on liferay 5.2) and want to store and then access data. The storage works fine, but the access not. I get an Object (flight) and wenn i want to have flight.getDestination() there is the following exception:
    Code:
    ERROR: org.hibernate.LazyInitializationException - could not initialize proxy - no Session
    org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:11
            at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
            at manuel.myapp.vo.Flight$$EnhancerByCGLIB$$7ad7f7f9.getDestination(<generated>)
            at manuel.myapp.FlightBackingBean.getDestination(FlightBackingBean.java:74)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:457)
            at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:85)
            at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:141)
            at com.sun.el.parser.AstValue.getValue(AstValue.java:117)
            at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
            at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
            at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
            at javax.faces.component.UIOutput.getValue(UIOutput.java:80)
            at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:223)
    here is my applicationContext.xml
    Code:
    <?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:context="http://www.springframework.org/schema/context"
    	xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    
    	<!-- Scan for annotations -->
    	<context:component-scan base-package="myapp"></context:component-scan>
    	<context:component-scan base-package="myapp.dao"></context:component-scan>
    	<context:component-scan base-package="myapp.vo"></context:component-scan>
    
    	<bean id="propertyConfigurer"
    		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="locations">
    			<list>
    				<value>classpath:myapp/dao/jdbc.properties
    				</value>
    			</list>
    		</property>
    	</bean>
    
    	<bean id="dataSource"
    		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="url">
    			<value>${database.url}</value>
    		</property>
    		<property name="driverClassName">
    			<value>${database.driver}</value>
    		</property>
    		<property name="username">
    			<value>${database.user}</value>
    		</property>
    		<property name="password">
    			<value>${database.password}</value>
    		</property>
    	</bean>
    
    	<!-- Adding the Transaction Support -->
    	<bean id="txManager"
    		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    
    	<!-- The session factory for hibernate and the hibernate config file -->
    	<bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref bean="dataSource" />
    		</property>
    		<property name="configLocation" value="classpath:myapp/dao/hibernate.cfg.xml" />
    		<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
    	</bean>
    
    	<!-- The Hibernate Template for Hibernate transactions -->
    	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    		<property name="sessionFactory">
    			<ref bean="sessionFactory" />
    		</property>
    		<property name="allowCreate">
    			<value>true</value>
    		</property>
    	</bean>
    </beans>
    and my web.xml

    Code:
    <?xml version="1.0"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    	version="2.4">
    	<context-param>
    		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    		<param-value>.xhtml</param-value>
    	</context-param>
    	<context-param>
    		<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    		<param-value>client</param-value>
    	</context-param>
    	<context-param>
    		<param-name>javax.faces.application.CONFIG_FILES</param-name>
    		<param-value>/WEB-INF/faces-config.xml</param-value>
    	</context-param>
    
    	<listener>
    		<listener-class>
    			org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    	</listener>
    
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    
    	<listener>
    		<listener-class>
    			org.springframework.web.context.request.RequestContextListener</listener-class>
    	</listener>
    
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>/WEB-INF/applicationContext.xml</param-value>
    	</context-param>
    	
    	<servlet>
    		<servlet-name>FacesServlet</servlet-name>
    		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>FacesServlet</servlet-name>
    		<url-pattern>/facelets/*</url-pattern>
    	</servlet-mapping>
    	<security-constraint>
    		<web-resource-collection>
    			<web-resource-name>Page Sources</web-resource-name>
    			<url-pattern>*.jsp</url-pattern>
    			<url-pattern>*.jspx</url-pattern>
    			<url-pattern>*.xhtml</url-pattern>
    		</web-resource-collection>
    		<auth-constraint>
    			<role-name>nobody</role-name>
    		</auth-constraint>
    	</security-constraint>
    	<security-role>
    		<role-name>nobody</role-name>
    	</security-role>
    
    	<!--Welcome files -->
    	<welcome-file-list>
    		<welcome-file>index.jsp</welcome-file>
    		<welcome-file>index.html</welcome-file>
    	</welcome-file-list>
    
    </web-app>
    when i put the following to my web.xml
    Code:
    <filter>
    		<filter-name>hibernateSessionFilter</filter-name>
    		<filter-class>
    			org.springframework.orm.hibernate.support.OpenSessionInViewFilter</filter-class>
    	</filter>
    	<filter-mapping>
    		<filter-name>hibernateSessionFilter</filter-name>
    		<url-pattern>/facelets/*</url-pattern>
    	</filter-mapping>
    there is an error by installing the portlets

    Code:
    26.05.2009 13:48:59 org.apache.catalina.core.StandardContext start
    SCHWERWIEGEND: Error filterStart
    26.05.2009 13:48:59 org.apache.catalina.core.StandardContext start
    SCHWERWIEGEND: Context [/testportlet5] startup failed due to previous errors
    13:49:09,050 WARN  [PluginPackageUtil:1298] Unable to reindex unistalled package testportlet5: Unable to commu
    nicate with repository http://plugins.liferay.com/official
    13:49:09,050 INFO  [PortletHotDeployListener:333] Unregistering portlets for testportlet5
    13:49:09,050 INFO  [PortletHotDeployListener:367] 4 portlets for testportlet5 was unregistered
    INFO : org.springframework.web.context.support.XmlWebApplicationContext - Closing org.springframework.web.cont
    ext.support.XmlWebApplicationContext@180b40d: display name [Root WebApplicationContext]; startup date [Tue May
     26 13:48:55 GMT 2009]; root of context hierarchy
    INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.spr
    [email protected]5e91: defining beans [myservice,flightDao,use
    rManager,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.con
    text.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnno
    tationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,propertyConfigurer,
    dataSource,txManager,sessionFactory,hibernateTemplate]; root of factory hierarchy
    INFO : org.springframework.orm.hibernate3.LocalSessionFactoryBean - Closing Hibernate SessionFactory
    INFO : org.hibernate.impl.SessionFactoryImpl - closing
    I am new in spring, so can someone say me what i have to do additionly to solve the problem.

  • #2
    Please help

    Can nobudy help me?

    Comment


    • #3
      Please help

      Please help me someone!!!!!!!!!!!!!!!!!!!

      Comment

      Working...
      X