Re: common error page in struts2 application

2009-07-31 Thread mailtolouis2020-struts
I think you can catch it, then do log.error(e.getMessage(),e); and then throw e;




From: Bhaarat Sharma bhaara...@gmail.com
To: Struts Users Mailing List user@struts.apache.org
Sent: Friday, July 31, 2009 5:03:34 AM
Subject: Re: common error page in struts2 application

Sorry I am a little confused.  Basically I need to be able to log the
message by doing log.error(e.getMessage(), e);  However, if i catch the
error and put it in the catch block then the global error page does not come
up (I am assuming because the exception is caught?)

If I do not catch the exception, then the error page shows up, however, I
have no way to do log.error(e.getMessage(), e);

After reading,
http://struts.apache.org/2.0.6/docs/exception-configuration.html I though I
can have a chainAction so something like.
package...
global-results
   result name=Exception type=chain
  param name=actionNameErrorPage/param
 param name=namespace/error/param
   /result
/global-results

global-exception-mappings
exception-mapping exception=java.lang.Exception
result=Exception/
/global-exception-mappings
action name=selectionPage class=reports.ReportSelection
result/reports/SelectionPage.jsp/result
/action

/package
package name=secure  namespace=/error
action name=ErrorPage class=com.myErrorClass
resulterrorpage.jsp/result
/action
/package
So finally, if i do not catch the error, the control will go to
com.myErrorClass.  Will I be able to do log.error(e.getMessage(), e); in
that class?? I dont think it will be available as originally the error was
thrown in reports.ReportSelection class.

I'd appreciate any help to guide me in right direction.

Thanks

On Thu, Jul 30, 2009 at 11:40 PM, Bhaarat Sharma bhaara...@gmail.comwrote:

 will the global exception not recognize the exception if I am catching it??
 I need to catch it because I want to put it in the logs.  However, in my
 example, if i am catching the exception then I am seeing that the error page
 defined with global-results is not coming up.
 do the global exception mappings only work for 'non caught' exceptions?


 On Thu, Jul 30, 2009 at 4:07 PM, Dave Newton newton.d...@yahoo.comwrote:

 Bhaarat Sharma wrote:

 Is there a way to just add [exception mapping] somewhere so that all
 20 package mappings see it?

 most of the packing are using struts-default


 You could create your own base package and extend from that. Package
 extension is also documented on the Struts 2 wiki (briefly):

 http://struts.apache.org/2.1.6/docs/package-configuration.html


 Dave

 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org





Re: common error page in struts2 application

2009-07-31 Thread Bhaarat Sharma
but if i am catching it, it is not showing my the common error page i
made..

On Fri, Jul 31, 2009 at 4:29 AM, mailtolouis2020-str...@yahoo.com wrote:

 I think you can catch it, then do log.error(e.getMessage(),e); and then
 throw e;



 
 From: Bhaarat Sharma bhaara...@gmail.com
 To: Struts Users Mailing List user@struts.apache.org
 Sent: Friday, July 31, 2009 5:03:34 AM
 Subject: Re: common error page in struts2 application

 Sorry I am a little confused.  Basically I need to be able to log the
 message by doing log.error(e.getMessage(), e);  However, if i catch the
 error and put it in the catch block then the global error page does not
 come
 up (I am assuming because the exception is caught?)

 If I do not catch the exception, then the error page shows up, however, I
 have no way to do log.error(e.getMessage(), e);

 After reading,
 http://struts.apache.org/2.0.6/docs/exception-configuration.html I though
 I
 can have a chainAction so something like.
 package...
global-results
   result name=Exception type=chain
  param name=actionNameErrorPage/param
 param name=namespace/error/param
   /result
/global-results

global-exception-mappings
exception-mapping exception=java.lang.Exception
 result=Exception/
/global-exception-mappings
action name=selectionPage class=reports.ReportSelection
result/reports/SelectionPage.jsp/result
/action

 /package
 package name=secure  namespace=/error
action name=ErrorPage class=com.myErrorClass
resulterrorpage.jsp/result
/action
 /package
 So finally, if i do not catch the error, the control will go to
 com.myErrorClass.  Will I be able to do log.error(e.getMessage(), e); in
 that class?? I dont think it will be available as originally the error was
 thrown in reports.ReportSelection class.

 I'd appreciate any help to guide me in right direction.

 Thanks

 On Thu, Jul 30, 2009 at 11:40 PM, Bhaarat Sharma bhaara...@gmail.com
 wrote:

  will the global exception not recognize the exception if I am catching
 it??
  I need to catch it because I want to put it in the logs.  However, in my
  example, if i am catching the exception then I am seeing that the error
 page
  defined with global-results is not coming up.
  do the global exception mappings only work for 'non caught' exceptions?
 
 
  On Thu, Jul 30, 2009 at 4:07 PM, Dave Newton newton.d...@yahoo.com
 wrote:
 
  Bhaarat Sharma wrote:
 
  Is there a way to just add [exception mapping] somewhere so that all
  20 package mappings see it?
 
  most of the packing are using struts-default
 
 
  You could create your own base package and extend from that. Package
  extension is also documented on the Struts 2 wiki (briefly):
 
  http://struts.apache.org/2.1.6/docs/package-configuration.html
 
 
  Dave
 
  -
  To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
  For additional commands, e-mail: user-h...@struts.apache.org
 
 
 



Re: common error page in struts2 application

2009-07-31 Thread Bhaarat Sharma
ahhh i was not 'thrwoing' e after catching it _

thansk

On Fri, Jul 31, 2009 at 6:55 AM, Bhaarat Sharma bhaara...@gmail.com wrote:

 but if i am catching it, it is not showing my the common error page i
 made..


 On Fri, Jul 31, 2009 at 4:29 AM, mailtolouis2020-str...@yahoo.com wrote:

 I think you can catch it, then do log.error(e.getMessage(),e); and then
 throw e;



 
 From: Bhaarat Sharma bhaara...@gmail.com
 To: Struts Users Mailing List user@struts.apache.org
 Sent: Friday, July 31, 2009 5:03:34 AM
 Subject: Re: common error page in struts2 application

 Sorry I am a little confused.  Basically I need to be able to log the
 message by doing log.error(e.getMessage(), e);  However, if i catch the
 error and put it in the catch block then the global error page does not
 come
 up (I am assuming because the exception is caught?)

 If I do not catch the exception, then the error page shows up, however, I
 have no way to do log.error(e.getMessage(), e);

 After reading,
 http://struts.apache.org/2.0.6/docs/exception-configuration.html I though
 I
 can have a chainAction so something like.
 package...
global-results
   result name=Exception type=chain
  param name=actionNameErrorPage/param
 param name=namespace/error/param
   /result
/global-results

global-exception-mappings
exception-mapping exception=java.lang.Exception
 result=Exception/
/global-exception-mappings
action name=selectionPage class=reports.ReportSelection
result/reports/SelectionPage.jsp/result
/action

 /package
 package name=secure  namespace=/error
action name=ErrorPage class=com.myErrorClass
resulterrorpage.jsp/result
/action
 /package
 So finally, if i do not catch the error, the control will go to
 com.myErrorClass.  Will I be able to do log.error(e.getMessage(), e); in
 that class?? I dont think it will be available as originally the error was
 thrown in reports.ReportSelection class.

 I'd appreciate any help to guide me in right direction.

 Thanks

 On Thu, Jul 30, 2009 at 11:40 PM, Bhaarat Sharma bhaara...@gmail.com
 wrote:

  will the global exception not recognize the exception if I am catching
 it??
  I need to catch it because I want to put it in the logs.  However, in my
  example, if i am catching the exception then I am seeing that the error
 page
  defined with global-results is not coming up.
  do the global exception mappings only work for 'non caught' exceptions?
 
 
  On Thu, Jul 30, 2009 at 4:07 PM, Dave Newton newton.d...@yahoo.com
 wrote:
 
  Bhaarat Sharma wrote:
 
  Is there a way to just add [exception mapping] somewhere so that all
  20 package mappings see it?
 
  most of the packing are using struts-default
 
 
  You could create your own base package and extend from that. Package
  extension is also documented on the Struts 2 wiki (briefly):
 
  http://struts.apache.org/2.1.6/docs/package-configuration.html
 
 
  Dave
 
  -
  To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
  For additional commands, e-mail: user-h...@struts.apache.org
 
 
 





[S2] OgnlValueStack Error setting expression warnings after upgrade from struts 2 to struts 2.1.7

2009-07-31 Thread Peter Phillips
I recently upgraded from struts 2.0 to 2.1.7 and noticed that we are
now getting lots of warnings in the logs:

12:31:53,283 WARN  [OgnlValueStack] Error setting expression
'button.save' with value '[Ljava.lang.String;@1683e9f'
ognl.OgnlException: target is null for setProperty(null, save,
[Ljava.lang.String;@1683e9f)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651)
at ognl.ASTProperty.setValueBody(ASTProperty.java:101)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
at ognl.SimpleNode.setValue(SimpleNode.java:246)
at ognl.ASTChain.setValueBody(ASTChain.java:172)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
at ognl.SimpleNode.setValue(SimpleNode.java:246)
at ognl.Ognl.setValue(Ognl.java:476)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192)
at 
com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161)

In our case the jsp has a submit button - s:submit key=button.save /.

Our action doesn't have a button.save property, I could add one to
suppress the warning but it doesn't feel right to add code to an
action to prevent a warning in the logs.  Alternatively I guess I
could change the log4j settings so that OgnlValueStack was set to
ERROR, but this would stop other warnings that I might actually be
interested in.

XW-613 changed the logging levels for the class from debug to warning
in a few places.  However reading the bug report by Brian Pontarelli
in XW-613 his issue seems to be the lack of warning logging when
exceptions are caught - which in my mind is more in the method
logLookupFailure (lines 353-359).  I agree that this is an exception
that the user should be warned about, whereas at present it is only a
debug (if devMode is false).

How are other people getting round the problem with submit buttons
causing warnings in the logs?

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: common error page in struts2 application

2009-07-31 Thread Greg Lindholm
What I do, instead of chaining the global error result to an error action,
is I use ognl in my error.jsp page to call a method and pass the exception
so it can be logged etc.  In my base action class I have a
notifyAdmin(Exception) method.

In error.jsp:
%-- Dummy expression to notify the admin --%
s:if test=notifyAdmin(exception)/s:if


On Fri, Jul 31, 2009 at 12:03 AM, Bhaarat Sharma bhaara...@gmail.comwrote:

 Sorry I am a little confused.  Basically I need to be able to log the
 message by doing log.error(e.getMessage(), e);  However, if i catch the
 error and put it in the catch block then the global error page does not
 come
 up (I am assuming because the exception is caught?)

 If I do not catch the exception, then the error page shows up, however, I
 have no way to do log.error(e.getMessage(), e);

 After reading,
 http://struts.apache.org/2.0.6/docs/exception-configuration.html I though
 I
 can have a chainAction so something like.
 package...
global-results
   result name=Exception type=chain
  param name=actionNameErrorPage/param
 param name=namespace/error/param
   /result
/global-results

global-exception-mappings
exception-mapping exception=java.lang.Exception
 result=Exception/
/global-exception-mappings
action name=selectionPage class=reports.ReportSelection
result/reports/SelectionPage.jsp/result
/action

 /package
 package name=secure  namespace=/error
action name=ErrorPage class=com.myErrorClass
resulterrorpage.jsp/result
/action
 /package
 So finally, if i do not catch the error, the control will go to
 com.myErrorClass.  Will I be able to do log.error(e.getMessage(), e); in
 that class?? I dont think it will be available as originally the error was
 thrown in reports.ReportSelection class.

 I'd appreciate any help to guide me in right direction.

 Thanks



Re: [S2] OgnlValueStack Error setting expression warnings after upgrade from struts 2 to struts 2.1.7

2009-07-31 Thread Greg Lindholm
I just change the logging level.

log4j.properties:
# Struts OgnlUtil issues unimportant warnings
log4j.logger.com.opensymphony.xwork2.util.OgnlUtil=error
log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack=error


On Fri, Jul 31, 2009 at 8:48 AM, Peter Phillips 
petergphill...@googlemail.com wrote:

 I recently upgraded from struts 2.0 to 2.1.7 and noticed that we are
 now getting lots of warnings in the logs:

 12:31:53,283 WARN  [OgnlValueStack] Error setting expression
 'button.save' with value '[Ljava.lang.String;@1683e9f'
 ognl.OgnlException: target is null for setProperty(null, save,
 [Ljava.lang.String;@1683e9f)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651)
at ognl.ASTProperty.setValueBody(ASTProperty.java:101)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
at ognl.SimpleNode.setValue(SimpleNode.java:246)
at ognl.ASTChain.setValueBody(ASTChain.java:172)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
at ognl.SimpleNode.setValue(SimpleNode.java:246)
at ognl.Ognl.setValue(Ognl.java:476)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192)
at
 com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161)

 In our case the jsp has a submit button - s:submit key=button.save /.

 Our action doesn't have a button.save property, I could add one to
 suppress the warning but it doesn't feel right to add code to an
 action to prevent a warning in the logs.  Alternatively I guess I
 could change the log4j settings so that OgnlValueStack was set to
 ERROR, but this would stop other warnings that I might actually be
 interested in.

 XW-613 changed the logging levels for the class from debug to warning
 in a few places.  However reading the bug report by Brian Pontarelli
 in XW-613 his issue seems to be the lack of warning logging when
 exceptions are caught - which in my mind is more in the method
 logLookupFailure (lines 353-359).  I agree that this is an exception
 that the user should be warned about, whereas at present it is only a
 debug (if devMode is false).

 How are other people getting round the problem with submit buttons
 causing warnings in the logs?

 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org




Re: [S2] OgnlValueStack Error setting expression warnings after upgrade from struts 2 to struts 2.1.7

2009-07-31 Thread Wes Wannemacher
On Fri, Jul 31, 2009 at 8:48 AM, Peter
Phillipspetergphill...@googlemail.com wrote:
 I recently upgraded from struts 2.0 to 2.1.7 and noticed that we are
 now getting lots of warnings in the logs:

 12:31:53,283 WARN  [OgnlValueStack] Error setting expression
 'button.save' with value '[Ljava.lang.String;@1683e9f'
 ognl.OgnlException: target is null for setProperty(null, save,
 [Ljava.lang.String;@1683e9f)
        at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651)
        at ognl.ASTProperty.setValueBody(ASTProperty.java:101)
        at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
        at ognl.SimpleNode.setValue(SimpleNode.java:246)
        at ognl.ASTChain.setValueBody(ASTChain.java:172)
        at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
        at ognl.SimpleNode.setValue(SimpleNode.java:246)
        at ognl.Ognl.setValue(Ognl.java:476)
        at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192)
        at 
 com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161)

 In our case the jsp has a submit button - s:submit key=button.save /.

 Our action doesn't have a button.save property, I could add one to
 suppress the warning but it doesn't feel right to add code to an
 action to prevent a warning in the logs.  Alternatively I guess I
 could change the log4j settings so that OgnlValueStack was set to
 ERROR, but this would stop other warnings that I might actually be
 interested in.

 XW-613 changed the logging levels for the class from debug to warning
 in a few places.  However reading the bug report by Brian Pontarelli
 in XW-613 his issue seems to be the lack of warning logging when
 exceptions are caught - which in my mind is more in the method
 logLookupFailure (lines 353-359).  I agree that this is an exception
 that the user should be warned about, whereas at present it is only a
 debug (if devMode is false).

 How are other people getting round the problem with submit buttons
 causing warnings in the logs?



/sigh... This is one of the great debates of struts2 development. On
one side you have a camp that wants to know any time a parameter is
submitted that doesn't have a matching getter/setter on the action, on
the other side, you have a group that doesn't want a bunch of errors
in the log. IMO, I get around it by setting the logging level
differently from dev to production. The problem is a bit basic in it's
nature, the current mechanisms for parameter parsing using OGNL to set
values against the action class. OGNL will throw an exception if a
passed parameter does not match a property on the target action.
Obviously, not all situations warrant a property on the target action,
but at the same time, when you are developing your application and you
forget a getter/setter on an action, you want to know. We've tried a
few different solutions, including using the value of devMode to
decide whether or not to show the errors, but it seems that there is
no perfect solution. Honestly, I think that if someone wants to help
tackle this issue, go ahead and file a JIRA, but I can say with
confidence that bugs and patches that indiscriminately turn the
exceptions and logging off or on will not be considered.

-Wes


-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Struts2 + JPA + JSON - Help with error

2009-07-31 Thread Nathan Schulte
Nathan Schulte nathan.schulte at ngc.com writes:

 
 Nathan Schulte nathan.schulte at ngc.com writes:
  here, http://article.gmane.org/gmane.comp.jakarta.struts.user/170543,
 http://article.gmane.org/gmane.comp.jakarta.struts.user/170543
 
  Here is a link to the error, http://pastebin.com/m5d0d22c8.
 http://pastebin.com/m5d0d22c8
 
 Also, here is the exception report (of a similar action) given as the HTTP
 response:
 http://pastebin.com/m21348ec5
 

I have found a fix for this issue.  As it turns out, because the JSON Plugin is
using reflection, and the entities the JSON Plugin is reflecting on are using
Hibernate/JPA lazy initialization magic, the JSON Plugin was serializing the
magic as well.  This magic contains references to underlying JPA
implementation, which also contains references, which also contain references,
all the way down past the JDBC layer.  I didn't go as far as to find out what
was causing this particular error/exception, but simply knew that I don't want
the Plugin to serialize the hibernateLazyInitializer instances in my entities. 
The Plugin supports property exclusion via regex, thus the simple fix.

Hey, perhaps this property exclusion property will come in handy to keep from
loading the whole database into memory for those self joins I have on my
entities... :P.

On another note, although this fixes my particular issue, perhaps there is some
more elegant solution to help with anything implementing this (or other
problematic) OOP patterns.

-Nate




-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: [S2] OgnlValueStack Error setting expression warnings after upgrade from struts 2 to struts 2.1.7

2009-07-31 Thread Greg Lindholm


 /sigh... This is one of the great debates of struts2 development. On
 one side you have a camp that wants to know any time a parameter is
 submitted that doesn't have a matching getter/setter on the action, on
 the other side, you have a group that doesn't want a bunch of errors
 in the log. IMO, I get around it by setting the logging level
 differently from dev to production. The problem is a bit basic in it's
 nature, the current mechanisms for parameter parsing using OGNL to set
 values against the action class. OGNL will throw an exception if a
 passed parameter does not match a property on the target action.
 Obviously, not all situations warrant a property on the target action,
 but at the same time, when you are developing your application and you
 forget a getter/setter on an action, you want to know. We've tried a
 few different solutions, including using the value of devMode to
 decide whether or not to show the errors, but it seems that there is
 no perfect solution. Honestly, I think that if someone wants to help
 tackle this issue, go ahead and file a JIRA, but I can say with
 confidence that bugs and patches that indiscriminately turn the
 exceptions and logging off or on will not be considered.

 -Wes


I do use a different log4j.properties file for devel vs. production which
helps.

I think the best you (committers) can do is be aware of the differing needs
and make the logging fine grained enough so users can turn individual
messages on or off as needed.  You may need several loggers in a class in
order to permit fine grained tuning.

The only other thing I would suggest is to reserve 'error' level reporting
to only times when things go horribly wrong and recovery is not possible.
Nobody wants to ever see ERROR show up in the logs when it isn't really an
error.  (E.g. in 2.1.6 https://issues.apache.org/struts/browse/WW-1714)


Re: [S2] OgnlValueStack Error setting expression warnings after upgrade from struts 2 to struts 2.1.7

2009-07-31 Thread Peter Phillips
Thanks for your help.  I guess everyone has their own opinions on when
warnings etc. should appear in the logs and trying to keep everyone
happy is an impossible task.

After a bit more digging I think I can just implement my own version
of OgnlValueStackFactory (by setting the struts.valueStackFactory
property) and then my own version of OgnlValueStack with the warnings
changed to debug and vica versa!

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: Struts2 + JPA + JSON - Help with error

2009-07-31 Thread Martin Gainty

disable lazy-initialisation in /WEB-INF/applicationContext.xml

bean id=testDataProvider 
class=org.apache.struts2.showcase.application.TestDataProvider 
singleton=true lazy-init=false/

Martin Gainty 
__ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




 To: user@struts.apache.org
 From: nathan.schu...@ngc.com
 Subject: Re: Struts2 + JPA + JSON - Help with error
 Date: Fri, 31 Jul 2009 13:50:14 +
 
 Nathan Schulte nathan.schulte at ngc.com writes:
 
  
  Nathan Schulte nathan.schulte at ngc.com writes:
   here, http://article.gmane.org/gmane.comp.jakarta.struts.user/170543,
  http://article.gmane.org/gmane.comp.jakarta.struts.user/170543
  
   Here is a link to the error, http://pastebin.com/m5d0d22c8.
  http://pastebin.com/m5d0d22c8
  
  Also, here is the exception report (of a similar action) given as the HTTP
  response:
  http://pastebin.com/m21348ec5
  
 
 I have found a fix for this issue.  As it turns out, because the JSON Plugin 
 is
 using reflection, and the entities the JSON Plugin is reflecting on are using
 Hibernate/JPA lazy initialization magic, the JSON Plugin was serializing the
 magic as well.  This magic contains references to underlying JPA
 implementation, which also contains references, which also contain references,
 all the way down past the JDBC layer.  I didn't go as far as to find out what
 was causing this particular error/exception, but simply knew that I don't want
 the Plugin to serialize the hibernateLazyInitializer instances in my 
 entities. 
 The Plugin supports property exclusion via regex, thus the simple fix.
 
 Hey, perhaps this property exclusion property will come in handy to keep from
 loading the whole database into memory for those self joins I have on my
 entities... :P.
 
 On another note, although this fixes my particular issue, perhaps there is 
 some
 more elegant solution to help with anything implementing this (or other
 problematic) OOP patterns.
 
 -Nate
 
 
 
 
 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org
 

_
Bing™ brings you maps, menus, and reviews organized in one place. Try it now.
http://www.bing.com/search?q=restaurantsform=MLOGENpubl=WLHMTAGcrea=TXT_MLOGEN_Local_Local_Restaurants_1x1

Re: EJB Injection in Interceptor

2009-07-31 Thread Robin Mannering

Wow!  Thanks for all this great feedback and ideas regards this problem.

I'm sorry I cannot add any useful prompts to help you develop a plugin 
Wes as Spring and it's methods for injection are something I know 
nothing about.  I have to admit, injection is not something I fully 
understand and anything I offered as a solution would likely be incorrect.


However, my only real requirement (currently) is to obtain local 
references to both stateless and stateful session beans in Glassfish 2.1 
from within Struts 2 action classes.


Looking at Haroons' examples, this would seem to be exactly the solution 
I'm looking for and I will try and implement this.


Can I just ask two further small questions to Haroon?

Is the EJBInvokerServlet set to initialise at app startup via the 
web.xml definition?


Does the EJBInvokerServlet approach work for stateful session bean 
references as well as stateless?


Again, thank you for the time and effort everyone has gone through in 
providing ideas and solutions to this problem.  It is good to know that 
this kind of expert help is available via the forum.


Many thanks, Robin



Wes Wannemacher wrote:

On Thu, Jul 30, 2009 at 10:34 AM, Haroon
Rafiqueharoon.rafi...@utoronto.ca wrote:
  

Hi Wes,

I don't know much of the details about the JEE spec, however, I can share
my implementation with you. The code is not in production yet, so caveat
emptor (it works for us, for now in development).

I use glassfish as my app server. To expose local EJB interfaces within
our entire application, I use an EJBInvokerServlet (uses the @EJB and
@EJBs annotations). The listing is as follows (took out package and import
statements and anonymized):

   @EJBs(
   value = {
   @EJB(beanInterface = Local1.class, name = ejb/local1),
   @EJB(beanInterface = Local2.class, name = ejb/local2),
   }
   )
   /**
* Used to make local interfaces of listed EJBs available within the whole
* web application.
*/
   public class EJBInvokerServlet extends HttpServlet {
   }

The other way to inject beans is by specifying ejb-local-ref inside web.xml.
   ejb-local-ref
   ejb-ref-nameLocal1Bean/ejb-ref-name
   ejb-ref-typeSession/ejb-ref-type
   localLocal1/local
   /ejb-local-ref
I prefer the Servlet approach as its simpler.

Wherever we need the EJBs to be automagically injected (the container does
its part because of EJBInvokerServlet), we then use the @Resource
annotation, e.g., to inject the Local1 interface, I would use:

   @Resource(mappedName = ejb/local1)
   private Local1 local1;

Hope that helps.



Haroon, it does and it doesn't. @EJB/@EJBs and @Resource aren't the
only DI annotations that are part of the EE specs. This is the problem
Robin has with the existing integration plugins. My understanding of
what he wants is that he wants to be able to use other annotations
(like @PersistenceContext) on fields in a struts action and have those
fields injected.

To turn it around and consider it compared to another similar
plugin... In the spring plugin, we delegate the class instantiation to
spring, then spring can decide what needs injected, etc. based on
spring configuration. What I'd like to do is apply the same concept to
EE. To do this in spring, there is an implementation of the
ObjectFactory that first tries to instantiate objects using spring,
and when that fails, it falls back on traditional xwork instantiation
(reflection-based). Once the object is created, the spring object
factory then checks to see if it can autowire the instance (based on
plugin configuration).

I'd like to try a similar approach with EE. The hard part is that I
don't know what API, or where to look for an API that instantiates EE
objects. Spring has 'applicationContext.getBean', is there something
similar for EE? Even if it's not as easy as Spring, I'm still willing
to wade through it for a bit since it seems like it would be useful to
at least a few users. The advantage to an object factory based EE
plugin is that I don't need to be aware of the annotations at all, I'd
be delegating that sort of thing to the EE app server's own
mechanisms.

-Wes


  




No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.392 / Virus Database: 270.13.37/2273 - Release Date: 07/30/09 18:09:00


  


Re: EJB Injection in Interceptor

2009-07-31 Thread Haroon Rafique
Hi Robin, see comments inline:

On Today at 7:25pm, RM=Robin Mannering ro...@mtndesigns.co.uk wrote:

RM [..snip..]
RM 
RM Can I just ask two further small questions to Haroon?
RM 
RM Is the EJBInvokerServlet set to initialise at app startup via the 
RM web.xml definition?
RM 

Nope. Its not mentioned anywhere else in the app. Its just packaged in 
the .war file (which is inside the .ear). Glassfish does the right thing 
when it sees a servlet marked with the @EJB annotations. You can use the 
Glassfish Admin Console (usually http://localhost:4848/):
  Application Server - General tab - JNDI Browsing
and you should find your EJBs under the ejb tree (the path to JNDI 
browsing is from memory).

RM 
RM Does the EJBInvokerServlet approach work for stateful session bean 
RM references as well as stateless?
RM 

Dunno. We have only done @Stateless.

RM 
RM Again, thank you for the time and effort everyone has gone through in 
RM providing ideas and solutions to this problem.  It is good to know 
RM that this kind of expert help is available via the forum.
RM 
RM Many thanks, Robin
RM 

Cheers,
--
Haroon Rafique
haroon.rafi...@utoronto.ca


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: EJB Injection in Interceptor

2009-07-31 Thread Haroon Rafique
On Today at 2:02pm, HR=Haroon Rafique haroon.rafi...@utoronto.ca wrote:

HR [..snip..]
HR 
HR Nope. Its not mentioned anywhere else in the app. Its just packaged in 
HR the .war file (which is inside the .ear). Glassfish does the right thing 
HR when it sees a servlet marked with the @EJB annotations. You can use the 
HR Glassfish Admin Console (usually http://localhost:4848/):
HR   Application Server - General tab - JNDI Browsing
HR and you should find your EJBs under the ejb tree (the path to JNDI 
HR browsing is from memory).
HR 

Scratch that. The above only applies if you want to see @Remote ejbs.

Cheers,
--
Haroon Rafique
haroon.rafi...@utoronto.ca


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: [s2] Multiple file upload using arrays

2009-07-31 Thread Dave Newton

Nate Drake wrote:

I have a question about multiple file uploads using arrays[1].  Say I have 4
text fields with a file input field related to each one on a JSP like
this:

input type=text name=attrVal/   s:file label=File (1) name=attrImg
/
input type=text name=attrVal/   s:file label=File (2) name=attrImg
/
input type=text name=attrVal/   s:file label=FIle (3) name=attrImg
/
input type=text name=attrVal/   s:file label=FIle (4) name=attrImg
/

The user must enter a value in the text field, but uploading a file isn't
required.  If the user picks a file for File(1) and File(4), in my
Action class the attrImg File[] only has two values in it.  This makes
sense, but I'm wondering, is there a way I can get Struts to include null
values in the File[] for the file upload fields (in this case 2 and 3) the
user didn't choose a file for?  I need to keep the files associated with the
textfield data in my action, as it works now, I can't do that, because I
won't know which textfield the files are related to.  I can't give each
upload field a unique name, as the user is able to add a new textfield/file
input pair dynamically.  


Provide your own indexes in the field name--otherwise S2 has no way of 
knowing anything was skipped.


Dave

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org