Hi Lukasz,

this is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="person" version="2.4" 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";>

    <display-name>Person</display-name>

        <!-- Points to the Spring Context -->
    <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/applicationContext*.xml</param-value>
        </context-param>

        <!-- Points to the Log4J Context -->
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value>
        </context-param>

        <mime-mapping>
                <extension>css</extension>
                <mime-type>text/css</mime-type>
        </mime-mapping>

    <filter>
                <filter-name>Acegi Filter Chain Proxy</filter-name>
                <filter-class>
                        org.acegisecurity.util.FilterToBeanProxy
                </filter-class>
                <init-param>
                        <param-name>targetClass</param-name>
                        <param-value>
                                org.acegisecurity.util.FilterChainProxy
                        </param-value>
                </init-param>
        </filter>

        <!-- Spring related filters -->
        <filter>
        <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
        <filter-class>
           
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
        </filter-class>
    </filter>

        <!-- Struts 2 Servlet-->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.FilterDispatcher
        </filter-class>
    </filter>

    <filter>
                <filter-name>sitemesh</filter-name>
                <filter-class>
                        com.opensymphony.module.sitemesh.filter.PageFilter
                </filter-class>
                <init-param>
                        <param-name>debug.pagewriter</param-name>
                        <param-value>true</param-value>
                </init-param>
        </filter>

        <filter-mapping>
                <filter-name>Acegi Filter Chain Proxy</filter-name>
                <url-pattern>/j_acegi_security_check</url-pattern>
        </filter-mapping>
        <filter-mapping>
                <filter-name>Acegi Filter Chain Proxy</filter-name>
                <url-pattern>/j_acegi_logout</url-pattern>
        </filter-mapping>
        <filter-mapping>
                <filter-name>Acegi Filter Chain Proxy</filter-name>
                <url-pattern>*.action</url-pattern>
        </filter-mapping>
        <filter-mapping>
                <filter-name>Acegi Filter Chain Proxy</filter-name>
                <url-pattern>*.jsp</url-pattern>
        </filter-mapping>
        <filter-mapping>
                <filter-name>struts2</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

    <filter-mapping>
        <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

        <filter-mapping>
                <filter-name>sitemesh</filter-name>
                <url-pattern>/*</url-pattern>
                <dispatcher>REQUEST</dispatcher>
                <dispatcher>FORWARD</dispatcher>
        </filter-mapping>

        <!-- Spring related listeners -->
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <listener>
                <listener-class>
                        org.acegisecurity.ui.session.HttpSessionEventPublisher
                </listener-class>
        </listener>

        <session-config>
                <session-timeout>180</session-timeout>
        </session-config>

        <!-- Add mappings for SiteMesh-related servlets here -->
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <error-page>
                <error-code>404</error-code>
                <location>/404.jsp</location>
        </error-page>
        <error-page>
                <error-code>500</error-code>
                <location>/error.jsp</location>
        </error-page>

    <jsp-config>
        <jsp-property-group>
                <url-pattern>*.jsp</url-pattern>
                <page-encoding>utf-8</page-encoding>
        </jsp-property-group>
    </jsp-config>
</web-app>

and this is my 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:aop="http://www.springframework.org/schema/aop";
    xmlns:tx="http://www.springframework.org/schema/tx";
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
    http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd";>

    <bean
       
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"
/>

    <bean id="entityManagerFactory"
       
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter">
            <bean
               
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="database" value="MYSQL" />
                <property name="showSql" value="false" />
            </bean>
        </property>
    </bean>

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost/persons" />
        <property name="username" value="root" />
        <property name="password" value="" />
    </bean>

    <bean id="transactionManager"
        class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />

        <bean id="personService" class="com.myapp.services.impl.UserServiceImpl"
/>

    <bean id="userAction" scope="prototype"
        class="com.myapp.actions.PersonAction">
        <constructor-arg ref="personService" />
    </bean>
...
</beans>

Do you need anything else ?

--
Thx, Milan


Lukasz Lenart wrote:
> 
> 2008/6/27 Milan Milanovic <[EMAIL PROTECTED]>:
>>
>> Hi Lukasz,
>>
>> great, thanks!
>>
>> Yes, I put this new mapping to my web.xml and now my application works.
>> But
>> again when I retrieve
>> person from database with: person = service.find(...); and call
>> person.getJobs() I again get:
>>
>>
>> org.hibernate.LazyInitializationException: could not initialize proxy -
>> no
> 
> That's strange, did you exactly follow configuration instructions in
> that example? Could you paste your config files? And also how did you
> configure person and job entity?
> 
> 
> Regards
> -- 
> Lukasz
> http://www.lenart.org.pl/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/LazyInitializationException-with-Struts-2-%2B-Spring-2-%2B-JPA-%2B-AJAX-application-tp18155823p18159227.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to