Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

user Digest 29 Jun 2008 15:06:22 -0000 Issue 8116

user-digest-help

2008-06-29


Author LoginPost Reply

user Digest 29 Jun 2008 15:06:22 -0000 Issue 8116

Topics (messages 188262 through 188285):

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application
 188262 by: Milan Milanovic
 188263 by: Milan Milanovic
 188264 by: Lukasz Lenart
 188265 by: Milan Milanovic
 188266 by: Lukasz Lenart
 188267 by: Milan Milanovic
 188269 by: Lukasz Lenart
 188270 by: Milan Milanovic
 188272 by: Milan Milanovic
 188273 by: Lukasz Lenart
 188274 by: Milan Milanovic
 188276 by: Milan Milanovic
 188277 by: Lukasz Lenart
 188278 by: Milan Milanovic
 188279 by: Lukasz Lenart

Re: <s:fielderror /> - how to provide an understandable error message to the enduser?
 188268 by: xianwinwin

Re: How to read data from nested list elements
 188271 by: Reddy, Ramachandra (IS Consultant)

Re: [s2] Whats the most strutsy way of doing....
 188275 by: Al Sutton

Re: Ajax Pagination using JQuery
 188280 by: Raghu
 188282 by: David Durham, Jr.

Re: Submitting a collection to Struts action
 188281 by: Milan Milanovic

Re: [S2] adding interceptor to all my actions
 188283 by: Vanja Petreski
 188284 by: Pawe³ Wielgus

Re: Error with action call from div
 188285 by: Scheidt

Administrivia:

---------------------------------------------------------------------
To post to the list, e-mail: user@(protected)
To unsubscribe, e-mail: user-digest-unsubscribe@(protected)
For additional commands, e-mail: user-digest-help@(protected)

----------------------------------------------------------------------

Attachment: user_188262.ezm (zipped)

Hi Lukasz,

I wrote this in my first post in this thread, I need to read
person.getJobs() when person object is loaded in my action class for this
Struts + AJAX+ Spring + Hibernate example provided in Struts docs, that's
it.

--
Thx, Milan


Lukasz Lenart wrote:
>
> 2008/6/27 Milan Milanovic <milanmilanovich@(protected)>:
>>
>> Hi,
>>
>> thank you. Do you know for any example of using this filter for
>> application
>> like I mentioned ?
>
> I'm not quite sure what you need, but this is the common why, how to
> solve such problem with web applications.
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188263.ezm (zipped)

Hi Lukasz,

thank you on this example. One question, is this going to work with this
Struts 2 + Spring 2 + JPA + AJAX application from Struts 2 docs, i.e., I
don't need to change code ?

--
Thx, Milan


Lukasz Lenart wrote:
>
>> I see that I can use OpenSessionInViewFilter, just I now need some
>> example
>> for this kind of application.
>
> Example:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <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">
>
>  <context-param>
>   <param-name>contextConfigLocation</param-name>
>   <param-value>/WEB-INF/classes/application-context*.xml</param-value>
>  </context-param>
>
>  <context-param>
>   <param-name>webAppRootKey</param-name>
>   <param-value>app.webroot</param-value>
>  </context-param>
>
>  <context-param>
>   <param-name>log4jConfigLocation</param-name>
>   <param-value>/WEB-INF/classes/log4j.properties</param-value>
>  </context-param>
>
>  <filter>
>   <filter-name>openSessionInView</filter-name>
>  
> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
>  </filter>
>
>  <filter>
>   <filter-name>encodingFilter</filter-name>
>  
> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
>   <init-param>
>     <param-name>encoding</param-name>
>     <param-value>UTF-8</param-value>
>   </init-param>
>   <init-param>
>     <param-name>forceEncoding</param-name>
>     <param-value>true</param-value>
>   </init-param>
>  </filter>
>
>  <filter-mapping>
>   <filter-name>openSessionInView</filter-name>
>   <url-pattern>/*</url-pattern>
>  </filter-mapping>
>
>  <filter-mapping>
>   <filter-name>encodingFilter</filter-name>
>   <url-pattern>/*</url-pattern>
>  </filter-mapping>
>
>  <listener>
>  
> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
>  </listener>
>
>  <listener>
>  
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>  </listener>
>
> </web-app>
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188264.ezm (zipped)
2008/6/27 Milan Milanovic <milanmilanovich@(protected)>:
>
> Hi Lukasz,
>
> I wrote this in my first post in this thread, I need to read
> person.getJobs() when person object is loaded in my action class for this
> Struts + AJAX+ Spring + Hibernate example provided in Struts docs, that's
> it.

Just add that filter and that's all, you don't have to change anything
else with your app.


Regards
--
Lukasz
http://www.lenart.org.pl/

Attachment: user_188265.ezm (zipped)

Hi Lukasz,

I tried to define web.xml as you give here, but when I deploy my application
I get this exception:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'sessionFactory' is defined
 at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:360)
 at
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:914)
 at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:241)
 at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
 at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:737)
 at
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:243)
 at
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:227)
 at
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:171)
 at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
 at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
 at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
 at
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413)
 at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
...

?

In this application
http://struts.apache.org/2.0.11.1/docs/struts-2-spring-2-jpa-ajax.html
Struts 2 + Spring + JPA + AJAX there is no defined bean with name
'sessionFactory'.
What can I do ?

--
Thx in advance, Milan


Lukasz Lenart wrote:
>
> 2008/6/27 Milan Milanovic <milanmilanovich@(protected)>:
>>
>> Hi Lukasz,
>>
>> I wrote this in my first post in this thread, I need to read
>> person.getJobs() when person object is loaded in my action class for this
>> Struts + AJAX+ Spring + Hibernate example provided in Struts docs, that's
>> it.
>
> Just add that filter and that's all, you don't have to change anything
> else with your app.
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188266.ezm (zipped)
Hi,

2008/6/27 Milan Milanovic <milanmilanovich@(protected)>:
>
> Hi Lukasz,
>
> I tried to define web.xml as you give here, but when I deploy my application
> I get this exception:

Just look to the doc, link I've sent you, there is such note:

Looks up the SessionFactory in Spring's root web application context.
Supports a "sessionFactoryBeanName" filter init-param in web.xml; the
default bean name is "sessionFactory". Looks up the SessionFactory on
each request, to avoid initialization order issues (when using
ContextLoaderServlet, the root application context will get
initialized after this filter).


Regards
--
Lukasz
http://www.lenart.org.pl/

Attachment: user_188267.ezm (zipped)

Hi Lukasz,

AFAIK I just need to define sessionFactory bean in my applicationContext.xml
to work with my JPA-enabled classes (just like in the Person example) ? How
can I do that ?

--
Thx, Milan


Milan Milanovic wrote:
>
> Hi Lukasz,
>
> I tried to define web.xml as you give here, but when I deploy my
> application I get this exception:
>
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
> named 'sessionFactory' is defined
>  at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:360)
>  at
> org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:914)
>  at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:241)
>  at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
>  at
> org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:737)
>  at
> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:243)
>  at
> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:227)
>  at
> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:171)
>  at
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
>  at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
>  at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>  at
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413)
>  at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
> ...
>
> ?
>
> In this application
> http://struts.apache.org/2.0.11.1/docs/struts-2-spring-2-jpa-ajax.html
> Struts 2 + Spring + JPA + AJAX there is no defined bean with name
> 'sessionFactory'.
> What can I do ?
>
> --
> Thx in advance, Milan
>
>
> Lukasz Lenart wrote:
>>
>> 2008/6/27 Milan Milanovic <milanmilanovich@(protected)>:
>>>
>>> Hi Lukasz,
>>>
>>> I wrote this in my first post in this thread, I need to read
>>> person.getJobs() when person object is loaded in my action class for
>>> this
>>> Struts + AJAX+ Spring + Hibernate example provided in Struts docs,
>>> that's
>>> it.
>>
>> Just add that filter and that's all, you don't have to change anything
>> else with your app.
>>
>>
>> Regards
>> --
>> Lukasz
>> http://www.lenart.org.pl/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188269.ezm (zipped)
2008/6/27 Milan Milanovic <milanmilanovich@(protected)>:
>
> Hi Lukasz,
>
> AFAIK I just need to define sessionFactory bean in my applicationContext.xml
> to work with my JPA-enabled classes (just like in the Person example) ? How
> can I do that ?

Sorry!! My big mistake ;-) Right now I discovered that you use JPA,
not Hibernate. In such example there is such configuration below, did
you setup it?

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

  <!-- Include this if you are using Hibernate -->
  <filter>
    <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
    <filter-class>
       org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
    </filter-class>
  </filter>

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

  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
       org.apache.struts2.dispatcher.FilterDispatcher
    </filter-class>
  </filter>

  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>


  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

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


Regards
--
Lukasz
http://www.lenart.org.pl/

Attachment: user_188270.ezm (zipped)

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
Session
 at
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
 at
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
 at
org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
 at com.myapp.model.Person$$EnhancerByCGLIB$$292cb8bb.getJobs(<generated>)
...

Why :-( ?

--
Thx very much, Milan


Lukasz Lenart wrote:
>
> 2008/6/27 Milan Milanovic <milanmilanovich@(protected)>:
>>
>> Hi Lukasz,
>>
>> AFAIK I just need to define sessionFactory bean in my
>> applicationContext.xml
>> to work with my JPA-enabled classes (just like in the Person example) ?
>> How
>> can I do that ?
>
> Sorry!! My big mistake ;-) Right now I discovered that you use JPA,
> not Hibernate. In such example there is such configuration below, did
> you setup it?
>
> <?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>
>
>   <!-- Include this if you are using Hibernate -->
>   <filter>
>      <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>      <filter-class>
>        
> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
>      </filter-class>
>   </filter>
>
>   <filter-mapping>
>      <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>      <url-pattern>/*</url-pattern>
>   </filter-mapping>
>
>   <filter>
>      <filter-name>struts2</filter-name>
>      <filter-class>
>         org.apache.struts2.dispatcher.FilterDispatcher
>      </filter-class>
>   </filter>
>
>   <filter-mapping>
>      <filter-name>struts2</filter-name>
>      <url-pattern>/*</url-pattern>
>   </filter-mapping>
>
>
>   <welcome-file-list>
>      <welcome-file>index.jsp</welcome-file>
>   </welcome-file-list>
>
>   <listener>
>      <listener-class>
>         org.springframework.web.context.ContextLoaderListener
>      </listener-class>
>   </listener>
> </web-app>
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188272.ezm (zipped)

Hi Lukasz,

I even tried to do this:

org.hibernate.Session session = ((org.hibernate.ejb.HibernateEntityManager)
service.getEntityManager()).getSession();

session.lock( persoon.getJobs(), LockMode.NONE);

But, it is the same :-(.

--
Thx, Milan



Milan Milanovic wrote:
>
> 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
> Session
>  at
> org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
>  at
> org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
>  at
> org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
>  at com.myapp.model.Person$$EnhancerByCGLIB$$292cb8bb.getJobs(<generated>)
> ...
>
> Why :-( ?
>
> --
> Thx very much, Milan
>
>
> Lukasz Lenart wrote:
>>
>> 2008/6/27 Milan Milanovic <milanmilanovich@(protected)>:
>>>
>>> Hi Lukasz,
>>>
>>> AFAIK I just need to define sessionFactory bean in my
>>> applicationContext.xml
>>> to work with my JPA-enabled classes (just like in the Person example) ?
>>> How
>>> can I do that ?
>>
>> Sorry!! My big mistake ;-) Right now I discovered that you use JPA,
>> not Hibernate. In such example there is such configuration below, did
>> you setup it?
>>
>> <?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>
>>
>>   <!-- Include this if you are using Hibernate -->
>>   <filter>
>>      <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>>      <filter-class>
>>        
>> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
>>      </filter-class>
>>   </filter>
>>
>>   <filter-mapping>
>>      <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>>      <url-pattern>/*</url-pattern>
>>   </filter-mapping>
>>
>>   <filter>
>>      <filter-name>struts2</filter-name>
>>      <filter-class>
>>         org.apache.struts2.dispatcher.FilterDispatcher
>>      </filter-class>
>>   </filter>
>>
>>   <filter-mapping>
>>      <filter-name>struts2</filter-name>
>>      <url-pattern>/*</url-pattern>
>>   </filter-mapping>
>>
>>
>>   <welcome-file-list>
>>      <welcome-file>index.jsp</welcome-file>
>>   </welcome-file-list>
>>
>>   <listener>
>>      <listener-class>
>>         org.springframework.web.context.ContextLoaderListener
>>      </listener-class>
>>   </listener>
>> </web-app>
>>
>>
>> Regards
>> --
>> Lukasz
>> http://www.lenart.org.pl/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188273.ezm (zipped)
2008/6/27 Milan Milanovic <milanmilanovich@(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/

Attachment: user_188274.ezm (zipped)

Hi Lukasz,

sorry about this amount of messages.

I actually do this (because of deleting):

Person person= service.getEntityManager().getReference(Person.class, id);

and then, when I do this:

session.lock( person, LockMode.NONE);

I get:

org.hibernate.SessionException: Session is closed!
 at
org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
 at org.hibernate.impl.SessionImpl.fireLock(SessionImpl.java:580)
 at org.hibernate.impl.SessionImpl.lock(SessionImpl.java:576)
...

If I call person.getJobs() then I get LazyInitializationException.

What can I do ?

--
Thx, Milan



Lukasz Lenart wrote:
>
> 2008/6/27 Milan Milanovic <milanmilanovich@(protected)>:
>>
>> Hi Lukasz,
>>
>> AFAIK I just need to define sessionFactory bean in my
>> applicationContext.xml
>> to work with my JPA-enabled classes (just like in the Person example) ?
>> How
>> can I do that ?
>
> Sorry!! My big mistake ;-) Right now I discovered that you use JPA,
> not Hibernate. In such example there is such configuration below, did
> you setup it?
>
> <?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>
>
>   <!-- Include this if you are using Hibernate -->
>   <filter>
>      <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>      <filter-class>
>        
> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
>      </filter-class>
>   </filter>
>
>   <filter-mapping>
>      <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>      <url-pattern>/*</url-pattern>
>   </filter-mapping>
>
>   <filter>
>      <filter-name>struts2</filter-name>
>      <filter-class>
>         org.apache.struts2.dispatcher.FilterDispatcher
>      </filter-class>
>   </filter>
>
>   <filter-mapping>
>      <filter-name>struts2</filter-name>
>      <url-pattern>/*</url-pattern>
>   </filter-mapping>
>
>
>   <welcome-file-list>
>      <welcome-file>index.jsp</welcome-file>
>   </welcome-file-list>
>
>   <listener>
>      <listener-class>
>         org.springframework.web.context.ContextLoaderListener
>      </listener-class>
>   </listener>
> </web-app>
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188276.ezm (zipped)

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 <milanmilanovich@(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: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188277.ezm (zipped)
Move OpenEntityManagerInViewFilter mapping before Struts2 mapping like below

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

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

If Acegi also use JPA. move OpenEntityManagerInViewFilter to the top.


Regards
--
Lukasz
http://www.lenart.org.pl/

Attachment: user_188278.ezm (zipped)

Hi Lukasz,

I moved it and now it works!! Great man, thank you very very much!
I hope that everything else will work good with this pattern ;-).

No, my Acegi is not using JPA, it uses just basic
(applicationContext-acegy-security.xml) configuration.

I think that this solution should be added somewhere in that Struts 2 +
Spring 2 + JPA + AJAX application example, because a lot of people will have
the same problem.

--
Thx one more time, Milan



Lukasz Lenart wrote:
>
> Move OpenEntityManagerInViewFilter mapping before Struts2 mapping like
> below
>
> <filter-mapping>
>  <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>  <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> <filter-mapping>
>  <filter-name>struts2</filter-name>
>  <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> If Acegi also use JPA. move OpenEntityManagerInViewFilter to the top.
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188279.ezm (zipped)
> I think that this solution should be added somewhere in that Struts 2 +
> Spring 2 + JPA + AJAX application example, because a lot of people will have
> the same problem.

The right order is already in the example, you made simple mistypo ;-)


Best regards
--
Lukasz
http://www.lenart.org.pl/

Attachment: user_188268.ezm (zipped)

GOT IT!!!!

thanks Dave!


newton.dave wrote:
>
> --- On Fri, 6/27/08, xianwinwin <xianwinwin@(protected):
>> removed - so the conversionError is not working. ok, how can
>> I provide my own errors now?
>
> Doesn't your existing validation handle the results of a failed
> conversion? i.e., the property would be null (or whatever)?
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188271.ezm (zipped)


Guys found the solution
Check the usage of nested tags that can handle any levels.

http://www.learntechnology.net/content/struts/struts_nested.jsp


Warm Regards
Ramachandra Reddy



-----Original Message-----
From: Reddy, Ramachandra (IS Consultant)
Sent: Thursday, June 26, 2008 12:44 PM
To: 'user@(protected)'
Subject: How to read data from nested list elements


Hi Folks,
I have particular requirement where I have nested elements and within that again some elements… So the nesting is up to 3 levels.

Top most element is   
ModulesList= it has N modules
 Module = it has N  Parts
Part= it has N Elements

Here is the class hieirarchy
Parent class that holds all modules.
public class FSModuleListForm extends ActionForm {

            private List mModuleList = new ArrayList();
      public List getModuleList() {return mModuleList;}
      public void setModuleList(List aModuleList) {mModuleList=aModuleList;}
     
public FSModuleForm getModule(int index)
      {
                  return (FSModuleForm) mModuleList.get(index);
      }

public void reset(ActionMapping aMapping, HttpServletRequest aRequest)
    {
        super.reset(aMapping, aRequest);
        moduleList = new ArrayList();
        for (int i=0; i < 25; i++)
        {
            mModuleList.add(i, new FSModuleForm());
        }
    }

}
==============================================
//Module Description
      public class FSModuleForm extends ActionForm
        {
            Public FSModuleForm()  
            {    
              moduleId = -1;
              moduleName=null;
              moduleType=null;
              moduleLabel=null;
              partsList = new ArrayList();

              //Lets initialize the list
              for (int i= 0 ; i < 10; i++ ){
                  partsList.add(i,new FSPartForm());
              }
            } 
            public FSPartForm getPart(int index) {
                  return (FSPartForm) partsList.get(index);
            }
            public void reset(ActionMapping aMapping, HttpServletRequest aRequest)
            {
                  partsList = new ArrayList();
                    //Lets initialize the list
                    for (int i= 0 ; i < 10; i++ ){
                        partsList.add(i,new FSPartForm());
                  }
            }
     
      }
==============================================

// PART Description
public class FSPartForm extends ActionForm {
     
     
      public FSPartForm()
       {
              partId=-1;
              sortOrder=0;
              partName=null;
              partLabel=null;
              partType=null;
              optionalFlag=null;
              partFootnote=null;
              elementList= new ArrayList();
            //Lets initialize the list
              for (int i= 0 ; i < 20; i++ ){
                  elementList.add(i,new FSElementForm());
              }
       }  

      public FSElementForm getElement(int index)
      {
           
                  return (FSElementForm) mElementList.get(index);
      }
      public void reset(ActionMapping aMapping, HttpServletRequest aRequest)
                  for (int i= 0 ; i < 50; i++ ){
                        elementList.add(i,new FSElementForm());
                    }
      }

}

==============================================
//Elemet Description.
public FSElementForm extends ActionForm {
 public FSElementForm()
      {
     
           elementId=-1;
           elementName=null;
           elementType=null;
           optionalFlag=null;
           defaultValue=null;
           sortOrder=0;
      }
     
}

Here is my JSP

      <logic:iterate id="module" name="FSModuleListForm" property="moduleList">
                        <tr>
                              <tr >  <!—Module info →
                                          <bean:write name="module" property="moduleName" /> <tr>
                                                Desc:<html:text name="module" property="moduleDesc"   indexed="true" />
                                                Label:<html:text name="module" property="moduleLabel"  indexed="true" />
                                    <html:hidden name="module" property="moduleId"        indexed="true" />
                              </tr>
                              <logic:present id="part" name="module" property="partsList">
                                    <logic:iterate id="part" name="module" property="partsList">
                                          <tr>
                                                <tr><bean:write name="part" property="partName" /></tr>
                                                <tr>Label:<html:text name="part" property="partLabel"    indexed="true" /></tr>
                                                <html:hidden name="part" property="partId" indexed="true" />
                                          </tr>
                                                <!—code to get each element will go here →
                                    </logic:iterate>
                              </logic:present>
                        </tr>
                        <hr>
                  </logic:iterate>


ISSUE:
1. Should I extend actionform for all classes or just the top most class is good (in my eg  FSModuleListForm) ?
2. I am able to display data on screen but when I submit only the module information gets populated
Not the parts associated to each module. Though indexing  value displayed looks good.
           
Html generated some what looks like
            InvestMent Objective1:
                        Desc:  <input type="text" name="module[0].moduleDesc" value="InvestMent Objective – first ">
                        Label:<input type="text" name="module[0].moduleLabel" value="InvestMent Objective First">
                        <input type="hidden" name="module[0].moduleId" value="1">
                                    This is Investment Objective1 Part NAME
                                                            Label:<input type="text" name="part[0].partLabel" value="This is Investment Objective1 Part Label">
                                                                        <input type="text" name="part[0].partId" value="1">

----------------------------------------------------------------------
            InvestMent Objective2:
                        Desc:  <input type="text" name="module[0].moduleDesc" value="InvestMent Objective – Second ">
                        Label:<input type="text" name="module[0].moduleLabel" value="InvestMent Objective second">
                        <input type="hidden" name="module[0].moduleId" value="2">
                                                This is Investment Objective2 Part NAME
                                                            Label:<input type="text" name="part[0].partLabel" value="This is Investment Objective2 Part Label">
                                                            <input type="text" name="part[0].partId" value="2">




Can some one please help me on this issue or is this not possible in Struts ?

Thanks in advance.







Warm Regards
Ramachandra Reddy



Attachment: user_188275.ezm (zipped)
Hi Jeromy,

Thanks for the comments.

I'm trying to steer away from javascript for the solution in order to
maximise browser compatibility (this app may be used on older mobile
phones).

I'm hoping that AES encryption isn't cracked ;), and by the inclusion of
some random noise in the properties list it should reduce the chances of
a simple brute force attack by increasing the length of the encrypted
data and not making the plain text obvious.

I can understand the problems with your plugin, My architecture stores
only the userId in the session and gets the user from the database as
needed (due to the back end being JPA/Hibernate and the user having
ManyToOne and OneToMany relationships I can't simply store the user in
the session). The system I'm going to implement will decrypt the data
from the cookie, verify it as valid, and then populate the session with
the neccessary information, all of which will be serializable objects
(Long, String, etc.)

Thanks again,

Al.


Jeromy Evans wrote:
> Al Sutton wrote:
>> Dave,
>>
>> I'm completely agree it's a great idea and useful thing to do, but
>> the problem is what to put into the cookie and how to map it to the
>> user.
>>
>> My current favourite is encrypt the properties you want to store
>> (using AES for speed and JCE support), then decrypt and inject when
>> needed. Cookies should be considered limited to 4K (due to the joys
>> of RFC2109 Section 6.3), so as long as the data fits joy shall be
>> mine :).
>>
>> Al.
>
> Hi Al,
> Just another variation I use where the useragent requires javascript:
> authenticate the user and generate a token; the token doesn't contain
> any sensitive data;
> the token is saved in a cookie and included in all requests (as
> cookie, header or param)
> an s2 interceptor checks the token is matched to an authenticated
> user. it injects relevant details to actions
>     (eg. a store maps tokens to users; server-side manages expiry,
> concurrent logins etc)
>
> It's not as fast as encoding login information in the cookie but it
> can't be broken. I use the same method to sign XHR requests.
> If the user has checked the "remember me" box the javascript gets the
> token from the cookie and resumes using it. The server it knows not
> to invalidate that token.
>
> Vulnerabilities:
> - The token should be unguessable to minimize forged requests;
> - as javascript is inscecure, tokens can be stolen from the cookie
> (eg. by an advertisement, XSS)
>
> I wrote the above as an S2 plugin. The only problem with releasing it
> as a plugin is that the "service that checks tokens" can't be
> Xwork'@(protected)
> via spring or guice) due to its potential external dependencies (eg.
> an EntityManager). The same plugin also allows me to apply roles to
> action methods (jsr-250).
>
> cheers,
> Jeromy Evans
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>


Attachment: user_188280.ezm (zipped)
Hi, I want to implement ajax pagination on my struts2 page but I am not sure
how to implement that. I am not very good in javascript and jquery but
learning them..

I have a table which will show 10 user comments at a time and there will be
pagination links for fetching next set of comments using Ajax using Jquery
$.getJSON( ) method.

I am using struts2 json plug in and it return json result. Now problem is
how to set this Json result to my struts2 tags on jsp page?

If anyone could help me on this problem then it will be great.

<table width= "500" border="0" cellspacing="0"
cellpadding="0">
        <s:if test="article.comments.size > 0">

               <s:iterator value="article.comments"
>
               <tr>
                <td width="50">
                    <a href="#" class="wname"> <s:property
value="userName"/> </a>
                </td>
                <td width="150">
                     posted on
                    <s:date name="commentDate"
format="dd-MMM-yyyy hh:mm aa" />
                </td>
                 <td width="200">

                </td>
               </tr>
                <tr >
                <td colspan="3">
                  <s:property value="comments"/>
                </td>
                </tr>
              </s:iterator>
                <span id="comments-Pagination"> Pagination links
goes here.. </span>
                </s:if>
                <s:else>
                  No Comment Found.
                </s:else>

            </table>

Thanks
Raghu

Attachment: user_188282.ezm (zipped)
On Fri, Jun 27, 2008 at 1:43 PM, Raghu <techhelp07@(protected):
> Hi, I want to implement ajax pagination on my struts2 page but I am not sure
> how to implement that. I am not very good in javascript and jquery but
> learning them..
>

You might be interested in something like this:

http://webplicity.net/flexigrid/

Regards,
Dave

Attachment: user_188281.ezm (zipped)

Hi,

you have multiple options. First, if you store your users in database, then
in your execute method you can retrieve them from database, or you can store
them in user session scope:

http://www.roseindia.net/struts/struts2/struts2ajax/struts2-session.shtml
Session scope

--
Regards, Milan



gokul balasubramanian wrote:
>
> Hello,I have a page with a collection of users. So I populate the form
> bean before displaying it&nbsp;and pass it to the view action.&nbsp;I use
> the &lt;logic:iterate&gt; tag to display them. These users can be
> modified.&nbsp;When I submit the form I am unable to iterate over the
> collection and&nbsp;found that it had a 'null' value. I am not sure how I
> am supposed to solve this. How do I retrieve the modified collection of
> users in the Struts Action?Any&nbsp;help is much appreciated.CheersGokul
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188283.ezm (zipped)
Anybody?

package-info.java does not work!

Struts 2.0.11.1

Vanja

2008/6/19 Paweł Wielgus <poulwiel@(protected)>:

> Hi all,
> i'm trying to add my own interceptor to all of my actions.
> I know that i can define new package ("default") and redefine default
> interceptor stack and then add @ParentPackage("default") to all my
> actions, but the question is how to do it in one place without having
> to add ParentPackage in all actions or writing configuration in xml?
>
> Best greetings,
> Paweł Wielgus.
>

Attachment: user_188284.ezm (zipped)
Hi Vanja,
i din't solve the problem, someone said that package-info is working
on trunk version (1.1.3 release?), but still it's not like the action
in subpackage of a package with package-info will receive
ParentPackage annotation - if i'm wrong i'll be very happy ;-)

So i'm waiting for next release to give it a try.

Best greetings,
Pawel Wielgus.

On 28/06/2008, Vanja Petreski <vpetreski@(protected):
> Anybody?
>
> package-info.java does not work!
>
> Struts 2.0.11.1
>
> Vanja
>
> 2008/6/19 Paweł Wielgus <poulwiel@(protected)>:
>
>> Hi all,
>> i'm trying to add my own interceptor to all of my actions.
>> I know that i can define new package ("default") and redefine default
>> interceptor stack and then add @ParentPackage("default") to all my
>> actions, but the question is how to do it in one place without having
>> to add ParentPackage in all actions or writing configuration in xml?
>>
>> Best greetings,
>> Paweł Wielgus.
>>
>

Attachment: user_188285.ezm (zipped)

I'm experience exactly the same issue. Have you find a solution?
Thanks



Paranoid_Fabio wrote:
>
> Hello. I've the following problem I'm stuck with:
> A tabbed panel with some divs:
>
>               <s:tabbedPanel id="upload_options">
>        <s:url id="mu" action="ManualContentUpload"/>
>         <s:div id="one" key="ContentUploadMain.Option.1" theme="ajax"
> href="%{mu}">
>        </s:div>
>        .....
>      </s:tabbedPanel>
>
> in the widget, i get the "loading...." message and then:
>
> Error loading '/...../.../ManualContentUpload.action? (200 OK)
>
> The mapping for the action is correct, because if I type it in the URL the
> resulting jsp is displayed correctly.
>
> <action name="ManualContentUpload"
> class="actions.contents.upload.ManualUpload">
>      <result name="success">/pages/ManualContentUpload.jsp</result>
> </action>
>
> All I want to do is to display the jsp in the div of the tabbel panel.
> What's my error?
>
> Thank you very much
>

--
Sent from the Struts - User mailing list archive at Nabble.com.

©2008 gg3721.com - Jax Systems, LLC, U.S.A.