Author Login
Post Reply
user Digest 15 Jul 2009 14:59:13 -0000 Issue 8752
Topics (messages 200726 through 200739):
Re: JSON Plugin and S:Action
200726 by: Chris Pratt
200730 by: Wes Wannemacher
Re: how to configure struts2 for /*.action?
200727 by: Dave Newton
200728 by: è°¢å¬é¸£
200729 by: ravi_eze
Struts2 Action Class and EJB Injection
200731 by: Robin Mannering
200732 by: Wes Wannemacher
200734 by: Robin Mannering
200735 by: Wes Wannemacher
200737 by: Robin Mannering
200738 by: Wes Wannemacher
200739 by: Robin Mannering
ParameterInterceptor problem
200733 by: Say Jon
200736 by: Robert Graf-Waczenski
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_200726.ezm (zipped)Ok, now I'm totally confused. The documentation at
http://cwiki.apache.org/S2PLUGINS/json-plugin.html says that the plug-in
required 2.0.6 or greater. It clearly did not support 2.1.2, but it seems
to support 2.1.6. Is the documentation wrong, should that say 2.1.6 instead
of 2.0.6?
(*Chris*)
On Tue, Jul 14, 2009 at 11:16 PM, Chris Pratt <thechrispratt@(protected):
> Ok, calling it from AJAX, instead of <s:action>, seems to work, but
> unfortunately it appears the JSON Plugin isn't compatible with Struts 2.1.
> I'm currently using 2.1.2, but the documentation says that it works with
> 2.0.6. Is there any plan to update it to work with 2.1? What I'm seeing
> is:
>
>
java.lang.NoSuchMethodError:
>
com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
> at
> com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:157)
> at
>
com.opensymphony.xwork2.DefaultActionInvocation.executeResult (
DefaultActionInvocation.java:355)
> at
>
com.opensymphony.xwork2.DefaultActionInvocation.invoke (
DefaultActionInvocation.java:259)
> ...
>
> Thanks.
> (*Chris*)
>
>
> On Tue, Jul 14, 2009 at 8:33 AM, Chris Pratt <thechrispratt@(protected):
>
>> Don't know, I was trying to initialize the variable using the same action
>> that would be used to update it. And, because of this problem, I haven't
>> been able to initialize it. Maybe I'll give it a try later.
>> (*Chris*)
>>
>>
>> On Tue, Jul 14, 2009 at 7:49 AM, Musachy Barroso <musachy@(protected):
>>
>>> Never thought of this use case before. Does it work if you use the
>>> action directly, instead of calling from a jsp?
>>>
>>> musachy
>>>
>>> On Mon, Jul 13, 2009 at 11:17 PM, Chris Pratt<thechrispratt@(protected)>
>>> wrote:
>>> > I'm having a problem using <s:action executeResult="true"> with an
>>> action
>>> > whose result type is json. It doesn't insert the results. My Action
>>> is
>>> > something like:
>>> >
>>> > public class InitCalendarAction {
>>> > private List<List<String>> json;
>>> >
>>> > /**
>>> > * Get the JSON Object to be Serialized
>>> > *
>>> > * @return JSON Object
>>> > */
>>> > public Object getJson () {
>>> > return json;
>>> > } //getJson
>>> >
>>> > /**
>>> > * Prepare the Object to be Serialized using JSON
>>> > *
>>> > * @return "success";
>>> > */
>>> > public String execute () {
>>> > Category cat;
>>> > Category[] daily = user.getPlan().getDailyCategories();
>>> > Calendar cal = Calendar.getInstance();
>>> > cal.set(Calendar.DATE,1);
>>> > int first = cal.get(Calendar.DAY_OF_WEEK) - 1;
>>> > List<String> row;
>>> > json = new ArrayList<List<String>>();
>>> > for(int day = 1;day <= cal.getMaximum(Calendar.DATE);day++) {
>>> > row = new ArrayList<String>();
>>> > row.add("true");
>>> > cat = daily[(day + first) % 7];
>>> > row.add(cat.name().toLowerCase());
>>> > row.add(cat.name());
>>> > json.add(row);
>>> > }
>>> > return "success";
>>> > } //execute
>>> >
>>> > } //*InitCalendarAction
>>> >
>>> > I have the action defined as:
>>> >
>>> > <action name="init-calendar" class="initCalendarAction">
>>> > <result type="json">
>>> > <param name="root">json</param>
>>> > </result>
>>> > </action>
>>> >
>>> > In my JSP, I have:
>>> >
>>> > var hilights = "<s:action name='init-calendar' namespace='/'
>>> > executeResult='/'/>";
>>> >
>>> > But instead of the expected:
>>> >
>>> > var hilights = "[ [ "true", "cardio", "Cardio"], [ "true",
>>> "upperbody",
>>> > "Upper Body"] ... ]";
>>> >
>>> > I get:
>>> > var hilights = "";
>>> >
>>> > There are no errors in the logs and when I write out each row in the
>>> array,
>>> > everything is there as expected, but there's just no output. Any
>>> idea's
>>> > why?
>>> > (*Chris*)
>>> >
>>>
>>>
>>>
>>> --
>>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>
>

Attachment:
user_200730.ezm (zipped)On Wed, Jul 15, 2009 at 3:35 AM, Chris Pratt<thechrispratt@(protected):
> Ok, now I'm totally confused. The documentation at
> http://cwiki.apache.org/S2PLUGINS/json-plugin.html says that the plug-in
> required 2.0.6 or greater. It clearly did not support 2.1.2, but it seems
> to support 2.1.6. Is the documentation wrong, should that say 2.1.6 instead
> of 2.0.6?
> (*Chris*)
>
It is probably not clear in the json plugin docs, but in the move to
2.1, the build for the plugin broke. I didn't notice until
2.1.3-SNAPSHOT and we made some changes to get it working again.
Fortunately, the changes were only in unit tests, so you can build it
by disabling the tests and it should work. If you drop in the jar and
it doesn't work, let us know and we can figure it out from there.
-Wes
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

Attachment:
user_200727.ezm (zipped)ravi_eze wrote:
> did u mean that we cant map only *.action to struts filter? Or u were
> telling of some workaround? Why does struts put this restriction that all
> urls should pass through him?
As has been stated, S2 serves its own static content. If you're serving
the static content yourself (or don't need it) then mapping to *.action
*should* work ok.
> Please help, this is unexpected behavior of our application.
It can't be *that* unexpected-the documentation explicitly describes it.
Dave

Attachment:
user_200728.ezm (zipped)Hi ravi_eze,
One of our projects use Struts2, we have two url patterns /*.action and
/webservice/*, the first one is served by Struts2 and the second is served
by CXF framework directly.
is this what you want?
On Wed, Jul 15, 2009 at 11:06, ravi_eze <ravichandrac@(protected):
>
> i didnt get u,
>
> did u mean that we cant map only *.action to struts filter? Or u were
> telling of some workaround? Why does struts put this restriction that all
> urls should pass through him? And Why does he put restrictions at container
> level.
>
> see web.xml is the container level and i have my own applications/ filters
> in it. I should be given the choice to decide what urls should go to what
> and what not! Now why does struts come at this level at all??; Now that it
> comes what is the work around? The Filter dispatcher documentations says
> not
> to use other than '/*' for url pattern. He doesnt say what i need to do if
> at all i cant put /* there?
>
> Please help, this is unexpected behavior of our application. We were
> thinking all are fine, but suddenly this file upload didnt work (of prev
> jsp
> application).
>
> any help/ ponters are of great help.
>
> regards,
> ravi
>
>
> Wes Wannemacher wrote:
> >
> > 2009/7/14 谢冬鸣 <msys.xdm@(protected)>:
> >> Hi david,
> >> I have another question, I want to forward my Struts2 result to one jsp
> >> page
> >> which included in one jar file, how can I locate the jsp file? You said
> >> "...there are several Struts2 jars that house css and js files...", do
> >> you
> >> have any idea how to get these files?
> >>
> >> Thanks
> >>
> >> On Tue, Jul 14, 2009 at 23:29, Kawczynski, David
> >> <david_kawczynski@(protected)
> >>> wrote:
> >>
> >>> I was in the same boat...
> >>> One of my clients use apache httpd for all static content
> >>> and tomcat for all dynamic content... there are several
> >>> Struts2 jars that house css and js files. If you don't
> >>> map everything to the Struts2 filter your Struts2 app
> >>> won't be as full-featured as it could be. (Javascript
> >>> validation won't work, any themed presentation will appear
> >>> quite plain, etc...)
> >>>
> >
> > As far as I know, the content that is served by struts directly (css,
> > js and image files) are always mapped to URLs that start with /struts.
> > It might be possible to create two mappings, one to /struts/* and
> > another to *.action. As for the question above, I don't think there is
> > any good way to serve a JSP out of a jar file. Rather than packaging
> > your JSPs into your jar, can you configure your build to copy the JSP
> > somewhere into your app so that it can be served traditionally? If you
> > have to put the content into a jar, maybe try looking at freemarker.
> > We use freemarker internally for generating tag output because we can
> > package it in the jar files and it is more general-purpose than JSP.
> >
> > -Wes
> >
> > --
> > Wes Wannemacher
> > Author - Struts 2 In Practice
> > Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> > http://www.manning.com/wannemacher
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > For additional commands, e-mail: user-help@(protected)
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/how-to-configure-struts2-for--*.action--tp24481000p24491177.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
--
*********************************************
Xie Dongming
MAIL(Gtalk):msys.xdm@(protected)
Mobie:+86-15071342225
*********************************************
---------------------------------------------------------------------
俺终身奋斗的最低革命纲领:农妇--山泉--有点儿田

Attachment:
user_200729.ezm (zipped)
hi,
Thanks for the response.
We are not serving static content.
We have a JSP which is used to upload images/ files etc.(submits the form to
/upload.jsp)
When we give the struts mapping, this Jsp doesnt work.
As said in:
https://svn.apache.org/repos/asf/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java;
i think we should map only /* in web.xml. Please correct me if i am wrong.
What will happen if i do *.action?
Why did the doc say /* *should* be in web.xml?
Thanks in advance,
ravi
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_200731.ezm (zipped)Hello,
Platform : Struts 2, EJB 3.0, Glassfish 2.1
I wish to obtain a reference to an EJB using injection.
This works fine within a servlet, but from within a Struts2 action
class, all references to injected EJB variables hold a 'null' reference.
I've included a portion of my action class below.
I'm confused as to why a Servlet has no trouble using injection as
compared to the Struts 2 action class. Both the servlet and action
class reside in the same Web application.
Does anybody have any ideas?
/public class UserAction extends ActionSupport implements
ServletRequestAware, SessionAware {
private static Logger logger = Logger.getLogger(SetupServlet.class);
@EJB
SetupServiceBeanLocal setupService;
@EJB
UserServiceBeanLocal userService;
...
}/

Attachment:
user_200732.ezm (zipped)The difference is that the container did not instantiate your struts
action, struts did. There are EJB plugins available, check the plugin
registry.
http://cwiki.apache.org/S2PLUGINS/home.html
The ones I have seen are based on injection via interceptor. I've
toyed with the notion of creating an ObjectFactory based plugin so
that struts can delegate creation of action classes to the ejb
container. This would allow for injection for more than just @EJB
(@(protected)).
The only issue is that it doesn't seem like we see much traffic on
here from ejb users. Would anyone else be interested in an
ObjectFactory based plugin? If so, would any of you also want it to
work with Spring? The interceptor-based solution works good because it
doesn't interfere with object-creation-based plugins like
spring/guice/etc.
-Wes
On Wed, Jul 15, 2009 at 9:21 AM, Robin Mannering<robin@(protected):
> Hello,
>
> Platform : Struts 2, EJB 3.0, Glassfish 2.1
>
> I wish to obtain a reference to an EJB using injection.
>
> This works fine within a servlet, but from within a Struts2 action class,
> all references to injected EJB variables hold a 'null' reference.
>
> I've included a portion of my action class below.
>
> I'm confused as to why a Servlet has no trouble using injection as compared
> to the Struts 2 action class. Both the servlet and action class reside in
> the same Web application.
>
> Does anybody have any ideas?
>
> /public class UserAction extends ActionSupport implements
> ServletRequestAware, SessionAware {
>
> private static Logger logger = Logger.getLogger(SetupServlet.class);
> @EJB
> SetupServiceBeanLocal setupService;
> @EJB
> UserServiceBeanLocal userService;
> ...
> }/
>
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

Attachment:
user_200734.ezm (zipped)Many thanks for the prompt and detailed reply.
I understand why the use of injection does not work now within a Struts2
action class.
However, there only seems one EJB plugin available, which doesn't
actually have a download available and hasn't had for some time it appears.
http://code.google.com/p/struts2ejb3/downloads/list
I'm wary to trust in a plugin that doesn't appear to be currently
maintained (available to download).
Is there anybody that is using Struts2 as the 'frontend' to an EJB 3
'backend' and what solution do you currently employ.
Thanks
Robin
Wes Wannemacher wrote:
> The difference is that the container did not instantiate your struts
> action, struts did. There are EJB plugins available, check the plugin
> registry.
>
> http://cwiki.apache.org/S2PLUGINS/home.html
>
> The ones I have seen are based on injection via interceptor. I've
> toyed with the notion of creating an ObjectFactory based plugin so
> that struts can delegate creation of action classes to the ejb
> container. This would allow for injection for more than just @EJB
> (@(protected)).
>
> The only issue is that it doesn't seem like we see much traffic on
> here from ejb users. Would anyone else be interested in an
> ObjectFactory based plugin? If so, would any of you also want it to
> work with Spring? The interceptor-based solution works good because it
> doesn't interfere with object-creation-based plugins like
> spring/guice/etc.
>
> -Wes
>
> On Wed, Jul 15, 2009 at 9:21 AM, Robin Mannering<robin@(protected):
>
>> Hello,
>>
>> Platform : Struts 2, EJB 3.0, Glassfish 2.1
>>
>> I wish to obtain a reference to an EJB using injection.
>>
>> This works fine within a servlet, but from within a Struts2 action class,
>> all references to injected EJB variables hold a 'null' reference.
>>
>> I've included a portion of my action class below.
>>
>> I'm confused as to why a Servlet has no trouble using injection as compared
>> to the Struts 2 action class. Both the servlet and action class reside in
>> the same Web application.
>>
>> Does anybody have any ideas?
>>
>> /public class UserAction extends ActionSupport implements
>> ServletRequestAware, SessionAware {
>>
>> private static Logger logger = Logger.getLogger(SetupServlet.class);
>> @EJB
>> SetupServiceBeanLocal setupService;
>> @EJB
>> UserServiceBeanLocal userService;
>> ...
>> }/
>>
>>
>
>
>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00
>
>

Attachment:
user_200735.ezm (zipped)You are right, there is only one, the other one in that list is a
jboss-ejb plugin. Take a look at the source for the plugin, it is not
particularly complex and I know the author is lurking around here
somewhere. I would suggest that you do one of two things -
1. Create an interceptor, probably identical to the one in the plugin.
If you have troubles, bring them to the list, we'll help.
2. Create an object factory implementation that creates actions using
your container's semantics. Again, if you have troubles, bring 'em
back here, we'll help you.
-Wes
On Wed, Jul 15, 2009 at 9:48 AM, Robin Mannering<robin@(protected):
> Many thanks for the prompt and detailed reply.
>
> I understand why the use of injection does not work now within a Struts2
> action class.
>
> However, there only seems one EJB plugin available, which doesn't actually
> have a download available and hasn't had for some time it appears.
>
> http://code.google.com/p/struts2ejb3/downloads/list
>
> I'm wary to trust in a plugin that doesn't appear to be currently maintained
> (available to download).
>
> Is there anybody that is using Struts2 as the 'frontend' to an EJB 3
> 'backend' and what solution do you currently employ.
>
> Thanks
> Robin
>
> Wes Wannemacher wrote:
>>
>> The difference is that the container did not instantiate your struts
>> action, struts did. There are EJB plugins available, check the plugin
>> registry.
>>
>> http://cwiki.apache.org/S2PLUGINS/home.html
>>
>> The ones I have seen are based on injection via interceptor. I've
>> toyed with the notion of creating an ObjectFactory based plugin so
>> that struts can delegate creation of action classes to the ejb
>> container. This would allow for injection for more than just @EJB
>> (@(protected)).
>>
>> The only issue is that it doesn't seem like we see much traffic on
>> here from ejb users. Would anyone else be interested in an
>> ObjectFactory based plugin? If so, would any of you also want it to
>> work with Spring? The interceptor-based solution works good because it
>> doesn't interfere with object-creation-based plugins like
>> spring/guice/etc.
>>
>> -Wes
>>
>> On Wed, Jul 15, 2009 at 9:21 AM, Robin Mannering<robin@(protected)>
>> wrote:
>>
>>>
>>> Hello,
>>>
>>> Platform : Struts 2, EJB 3.0, Glassfish 2.1
>>>
>>> I wish to obtain a reference to an EJB using injection.
>>>
>>> This works fine within a servlet, but from within a Struts2 action class,
>>> all references to injected EJB variables hold a 'null' reference.
>>>
>>> I've included a portion of my action class below.
>>>
>>> I'm confused as to why a Servlet has no trouble using injection as
>>> compared
>>> to the Struts 2 action class. Both the servlet and action class reside
>>> in
>>> the same Web application.
>>>
>>> Does anybody have any ideas?
>>>
>>> /public class UserAction extends ActionSupport implements
>>> ServletRequestAware, SessionAware {
>>>
>>> private static Logger logger = Logger.getLogger(SetupServlet.class);
>>> @(protected)
>>> SetupServiceBeanLocal setupService;
>>> @(protected)
>>> UserServiceBeanLocal userService;
>>> ...
>>> }/
>>>
>>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database:
>> 270.13.14/2238 - Release Date: 07/14/09 18:03:00
>>
>>
>
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

Attachment:
user_200737.ezm (zipped)Hi Wes,
I found a resource on the web that seems to be a simpler solution:
InitialContext ic = new InitialContext();
UserServiceBeanLocal userService = (UserServiceBeanLocal)
ic.lookup(UserServiceBeanLocal.class.getName());
As in the web resource I found, it was necessary to change @Local to
@Remote in the session bean for it to be found correctly.
It worked perfectly using the above.
Here is a link to the resource. What do you think of this solution?
http://www.coderanch.com/t/58279/Struts/Connecting-ejb-session-bean-from
Thanks
Robin
Wes Wannemacher wrote:
> You are right, there is only one, the other one in that list is a
> jboss-ejb plugin. Take a look at the source for the plugin, it is not
> particularly complex and I know the author is lurking around here
> somewhere. I would suggest that you do one of two things -
> 1. Create an interceptor, probably identical to the one in the plugin.
> If you have troubles, bring them to the list, we'll help.
> 2. Create an object factory implementation that creates actions using
> your container's semantics. Again, if you have troubles, bring 'em
> back here, we'll help you.
>
> -Wes
>
> On Wed, Jul 15, 2009 at 9:48 AM, Robin Mannering<robin@(protected):
>
>> Many thanks for the prompt and detailed reply.
>>
>> I understand why the use of injection does not work now within a Struts2
>> action class.
>>
>> However, there only seems one EJB plugin available, which doesn't actually
>> have a download available and hasn't had for some time it appears.
>>
>> http://code.google.com/p/struts2ejb3/downloads/list
>>
>> I'm wary to trust in a plugin that doesn't appear to be currently maintained
>> (available to download).
>>
>> Is there anybody that is using Struts2 as the 'frontend' to an EJB 3
>> 'backend' and what solution do you currently employ.
>>
>> Thanks
>> Robin
>>
>> Wes Wannemacher wrote:
>>
>>> The difference is that the container did not instantiate your struts
>>> action, struts did. There are EJB plugins available, check the plugin
>>> registry.
>>>
>>> http://cwiki.apache.org/S2PLUGINS/home.html
>>>
>>> The ones I have seen are based on injection via interceptor. I've
>>> toyed with the notion of creating an ObjectFactory based plugin so
>>> that struts can delegate creation of action classes to the ejb
>>> container. This would allow for injection for more than just @EJB
>>> (@(protected)).
>>>
>>> The only issue is that it doesn't seem like we see much traffic on
>>> here from ejb users. Would anyone else be interested in an
>>> ObjectFactory based plugin? If so, would any of you also want it to
>>> work with Spring? The interceptor-based solution works good because it
>>> doesn't interfere with object-creation-based plugins like
>>> spring/guice/etc.
>>>
>>> -Wes
>>>
>>> On Wed, Jul 15, 2009 at 9:21 AM, Robin Mannering<robin@(protected)>
>>> wrote:
>>>
>>>
>>>> Hello,
>>>>
>>>> Platform : Struts 2, EJB 3.0, Glassfish 2.1
>>>>
>>>> I wish to obtain a reference to an EJB using injection.
>>>>
>>>> This works fine within a servlet, but from within a Struts2 action class,
>>>> all references to injected EJB variables hold a 'null' reference.
>>>>
>>>> I've included a portion of my action class below.
>>>>
>>>> I'm confused as to why a Servlet has no trouble using injection as
>>>> compared
>>>> to the Struts 2 action class. Both the servlet and action class reside
>>>> in
>>>> the same Web application.
>>>>
>>>> Does anybody have any ideas?
>>>>
>>>> /public class UserAction extends ActionSupport implements
>>>> ServletRequestAware, SessionAware {
>>>>
>>>> private static Logger logger = Logger.getLogger(SetupServlet.class);
>>>> @EJB
>>>> SetupServiceBeanLocal setupService;
>>>> @EJB
>>>> UserServiceBeanLocal userService;
>>>> ...
>>>> }/
>>>>
>>>>
>>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database:
>>> 270.13.14/2238 - Release Date: 07/14/09 18:03:00
>>>
>>>
>>>
>
>
>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00
>
>

Attachment:
user_200738.ezm (zipped)I don't see anything wrong with that. I'd still like to eventually
create a plugin that removes the need to do that in your execute
method. The EJB spec added those annotations, so I'd like to figure
out a way to honor them (cleanly).
-Wes
On Wed, Jul 15, 2009 at 10:37 AM, Robin Mannering<robin@(protected):
> Hi Wes,
>
> I found a resource on the web that seems to be a simpler solution:
>
> InitialContext ic = new InitialContext();
> UserServiceBeanLocal userService = (UserServiceBeanLocal)
> ic.lookup(UserServiceBeanLocal.class.getName());
>
> As in the web resource I found, it was necessary to change @Local to @Remote
> in the session bean for it to be found correctly.
>
> It worked perfectly using the above.
>
> Here is a link to the resource. What do you think of this solution?
>
> http://www.coderanch.com/t/58279/Struts/Connecting-ejb-session-bean-from
>
> Thanks
> Robin
>
> Wes Wannemacher wrote:
>>
>> You are right, there is only one, the other one in that list is a
>> jboss-ejb plugin. Take a look at the source for the plugin, it is not
>> particularly complex and I know the author is lurking around here
>> somewhere. I would suggest that you do one of two things -
>> 1. Create an interceptor, probably identical to the one in the plugin.
>> If you have troubles, bring them to the list, we'll help.
>> 2. Create an object factory implementation that creates actions using
>> your container's semantics. Again, if you have troubles, bring 'em
>> back here, we'll help you.
>>
>> -Wes
>>
>> On Wed, Jul 15, 2009 at 9:48 AM, Robin Mannering<robin@(protected)>
>> wrote:
>>
>>>
>>> Many thanks for the prompt and detailed reply.
>>>
>>> I understand why the use of injection does not work now within a Struts2
>>> action class.
>>>
>>> However, there only seems one EJB plugin available, which doesn't
>>> actually
>>> have a download available and hasn't had for some time it appears.
>>>
>>> http://code.google.com/p/struts2ejb3/downloads/list
>>>
>>> I'm wary to trust in a plugin that doesn't appear to be currently
>>> maintained
>>> (available to download).
>>>
>>> Is there anybody that is using Struts2 as the 'frontend' to an EJB 3
>>> 'backend' and what solution do you currently employ.
>>>
>>> Thanks
>>> Robin
>>>
>>> Wes Wannemacher wrote:
>>>
>>>>
>>>> The difference is that the container did not instantiate your struts
>>>> action, struts did. There are EJB plugins available, check the plugin
>>>> registry.
>>>>
>>>> http://cwiki.apache.org/S2PLUGINS/home.html
>>>>
>>>> The ones I have seen are based on injection via interceptor. I've
>>>> toyed with the notion of creating an ObjectFactory based plugin so
>>>> that struts can delegate creation of action classes to the ejb
>>>> container. This would allow for injection for more than just @EJB
>>>> (@(protected)).
>>>>
>>>> The only issue is that it doesn't seem like we see much traffic on
>>>> here from ejb users. Would anyone else be interested in an
>>>> ObjectFactory based plugin? If so, would any of you also want it to
>>>> work with Spring? The interceptor-based solution works good because it
>>>> doesn't interfere with object-creation-based plugins like
>>>> spring/guice/etc.
>>>>
>>>> -Wes
>>>>
>>>> On Wed, Jul 15, 2009 at 9:21 AM, Robin Mannering<robin@(protected)>
>>>> wrote:
>>>>
>>>>
>>>>>
>>>>> Hello,
>>>>>
>>>>> Platform : Struts 2, EJB 3.0, Glassfish 2.1
>>>>>
>>>>> I wish to obtain a reference to an EJB using injection.
>>>>>
>>>>> This works fine within a servlet, but from within a Struts2 action
>>>>> class,
>>>>> all references to injected EJB variables hold a 'null' reference.
>>>>>
>>>>> I've included a portion of my action class below.
>>>>>
>>>>> I'm confused as to why a Servlet has no trouble using injection as
>>>>> compared
>>>>> to the Struts 2 action class. Both the servlet and action class reside
>>>>> in
>>>>> the same Web application.
>>>>>
>>>>> Does anybody have any ideas?
>>>>>
>>>>> /public class UserAction extends ActionSupport implements
>>>>> ServletRequestAware, SessionAware {
>>>>>
>>>>> private static Logger logger = Logger.getLogger(SetupServlet.class);
>>>>> @EJB
>>>>> SetupServiceBeanLocal setupService;
>>>>> @EJB
>>>>> UserServiceBeanLocal userService;
>>>>> ...
>>>>> }/
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>>
>>>> No virus found in this incoming message.
>>>> Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database:
>>>> 270.13.14/2238 - Release Date: 07/14/09 18:03:00
>>>>
>>>>
>>>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database:
>> 270.13.14/2238 - Release Date: 07/14/09 18:03:00
>>
>>
>
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

Attachment:
user_200739.ezm (zipped)Yes, using annotations would be the ideal method.
I think I remember reading that declaring beans as 'remote' when this is
not that case, may cause unnecessary serialization/deserialization as
calls are supposedly being made remotely. Depending on the EJB app
server configuration.
Obviously, this could cause significant overhead when returning large
result sets from a session bean.
I've yet to find where I read that but will update this thread if/when I do.
Robin
Wes Wannemacher wrote:
> I don't see anything wrong with that. I'd still like to eventually
> create a plugin that removes the need to do that in your execute
> method. The EJB spec added those annotations, so I'd like to figure
> out a way to honor them (cleanly).
>
> -Wes
>
> On Wed, Jul 15, 2009 at 10:37 AM, Robin Mannering<robin@(protected):
>
>> Hi Wes,
>>
>> I found a resource on the web that seems to be a simpler solution:
>>
>> InitialContext ic = new InitialContext();
>> UserServiceBeanLocal userService = (UserServiceBeanLocal)
>> ic.lookup(UserServiceBeanLocal.class.getName());
>>
>> As in the web resource I found, it was necessary to change @Local to @Remote
>> in the session bean for it to be found correctly.
>>
>> It worked perfectly using the above.
>>
>> Here is a link to the resource. What do you think of this solution?
>>
>> http://www.coderanch.com/t/58279/Struts/Connecting-ejb-session-bean-from
>>
>> Thanks
>> Robin
>>
>> Wes Wannemacher wrote:
>>
>>> You are right, there is only one, the other one in that list is a
>>> jboss-ejb plugin. Take a look at the source for the plugin, it is not
>>> particularly complex and I know the author is lurking around here
>>> somewhere. I would suggest that you do one of two things -
>>> 1. Create an interceptor, probably identical to the one in the plugin.
>>> If you have troubles, bring them to the list, we'll help.
>>> 2. Create an object factory implementation that creates actions using
>>> your container's semantics. Again, if you have troubles, bring 'em
>>> back here, we'll help you.
>>>
>>> -Wes
>>>
>>> On Wed, Jul 15, 2009 at 9:48 AM, Robin Mannering<robin@(protected)>
>>> wrote:
>>>
>>>
>>>> Many thanks for the prompt and detailed reply.
>>>>
>>>> I understand why the use of injection does not work now within a Struts2
>>>> action class.
>>>>
>>>> However, there only seems one EJB plugin available, which doesn't
>>>> actually
>>>> have a download available and hasn't had for some time it appears.
>>>>
>>>> http://code.google.com/p/struts2ejb3/downloads/list
>>>>
>>>> I'm wary to trust in a plugin that doesn't appear to be currently
>>>> maintained
>>>> (available to download).
>>>>
>>>> Is there anybody that is using Struts2 as the 'frontend' to an EJB 3
>>>> 'backend' and what solution do you currently employ.
>>>>
>>>> Thanks
>>>> Robin
>>>>
>>>> Wes Wannemacher wrote:
>>>>
>>>>
>>>>> The difference is that the container did not instantiate your struts
>>>>> action, struts did. There are EJB plugins available, check the plugin
>>>>> registry.
>>>>>
>>>>> http://cwiki.apache.org/S2PLUGINS/home.html
>>>>>
>>>>> The ones I have seen are based on injection via interceptor. I've
>>>>> toyed with the notion of creating an ObjectFactory based plugin so
>>>>> that struts can delegate creation of action classes to the ejb
>>>>> container. This would allow for injection for more than just @EJB
>>>>> (@(protected)).
>>>>>
>>>>> The only issue is that it doesn't seem like we see much traffic on
>>>>> here from ejb users. Would anyone else be interested in an
>>>>> ObjectFactory based plugin? If so, would any of you also want it to
>>>>> work with Spring? The interceptor-based solution works good because it
>>>>> doesn't interfere with object-creation-based plugins like
>>>>> spring/guice/etc.
>>>>>
>>>>> -Wes
>>>>>
>>>>> On Wed, Jul 15, 2009 at 9:21 AM, Robin Mannering<robin@(protected)>
>>>>> wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> Platform : Struts 2, EJB 3.0, Glassfish 2.1
>>>>>>
>>>>>> I wish to obtain a reference to an EJB using injection.
>>>>>>
>>>>>> This works fine within a servlet, but from within a Struts2 action
>>>>>> class,
>>>>>> all references to injected EJB variables hold a 'null' reference.
>>>>>>
>>>>>> I've included a portion of my action class below.
>>>>>>
>>>>>> I'm confused as to why a Servlet has no trouble using injection as
>>>>>> compared
>>>>>> to the Struts 2 action class. Both the servlet and action class reside
>>>>>> in
>>>>>> the same Web application.
>>>>>>
>>>>>> Does anybody have any ideas?
>>>>>>
>>>>>> /public class UserAction extends ActionSupport implements
>>>>>> ServletRequestAware, SessionAware {
>>>>>>
>>>>>> private static Logger logger = Logger.getLogger(SetupServlet.class);
>>>>>> @EJB
>>>>>> SetupServiceBeanLocal setupService;
>>>>>> @EJB
>>>>>> UserServiceBeanLocal userService;
>>>>>> ...
>>>>>> }/
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ------------------------------------------------------------------------
>>>>>
>>>>>
>>>>> No virus found in this incoming message.
>>>>> Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database:
>>>>> 270.13.14/2238 - Release Date: 07/14/09 18:03:00
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database:
>>> 270.13.14/2238 - Release Date: 07/14/09 18:03:00
>>>
>>>
>>>
>
>
>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00
>
>

Attachment:
user_200733.ezm (zipped)Hi all,
I have been using Struts 2 for a while now and I am pulling my hair over the
following issue. At times, when my parameter name contains a period, the
Parameterinterceptor doesn't seem to be applied properly. For example I have
a parameter "userAddress.country.id" which points to
getModel().getUserAddress().getCountry().setId() right? This works most of
the time but occasionally, the value doesn't get set. I know this because my
validation keeps denying the user saying that "Country is required" when the
user have indeed chosen a country (problem because the parameter is not
applied properly). The problem goes away when I restart Tomcat.
Anyone facing the same problem? I'm using Struts 2.1.6 by the way.
Regards.
W.SayJon
Email Disclaimer:
The information contained in or attached to this email is confidential and
solely for the use of the individual or entity to whom it is addressed.
If you are not the intended recipient, please notify the sender immediately
and delete any copies of this email.
Any unauthorised disclosure, copying, distribution or any action taken in
reliance on the contents of this information is strictly prohibited and may
be unlawful.

Attachment:
user_200736.ezm (zipped)Even though you are pretty vague in what you write below, i have a few
pointers for you:
1) Check (and tell us) if you designed your action implements the
ModelDriven interface (guessed from you talking about getModel() below)
2) Maybe your getModel() returns an improperly initialized instance when
it is called several times. If the call chain you quote below somewhere
yields a null value, Struts2 is incapable of applying your parameter
value because it does not have an instance to set the value at.
3) The fact that the problem goes away when you restart Tomcat indicates
that the getModel() return value depends on the user's session and maybe
the value is ok when the session is fresh and the value is not ok when
you call your action repeatedly. (Again, guesswork here...)
Quoting your action source code and your model class source code would
help us helping you.
Robert
Say Jon schrieb:
> Hi all,
> I have been using Struts 2 for a while now and I am pulling my hair over the
> following issue. At times, when my parameter name contains a period, the
> Parameterinterceptor doesn't seem to be applied properly. For example I have
> a parameter "userAddress.country.id" which points to
> getModel().getUserAddress().getCountry().setId() right? This works most of
> the time but occasionally, the value doesn't get set. I know this because my
> validation keeps denying the user saying that "Country is required" when the
> user have indeed chosen a country (problem because the parameter is not
> applied properly). The problem goes away when I restart Tomcat.
>
> Anyone facing the same problem? I'm using Struts 2.1.6 by the way.
>
> Regards.
> W.SayJon
>
> Email Disclaimer:
> The information contained in or attached to this email is confidential and
> solely for the use of the individual or entity to whom it is addressed.
> If you are not the intended recipient, please notify the sender immediately
> and delete any copies of this email.
> Any unauthorised disclosure, copying, distribution or any action taken in
> reliance on the contents of this information is strictly prohibited and may
> be unlawful.
>
>