You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Guo <ho...@163.com> on 2016/03/08 16:44:16 UTC
how to use ejb 3.1/3.2 in struts2?
Hello, everyone.
I suppose this is very old question to struts user list.
how to use EJB 3.1/3.2 in struts2?
I did some research on google. but I totally no idea what’s the exactly solution for this.
some one said use cdi plugin. but if I use cdi plugin, I guess it can be @inject a ebb into action class. but if I want to inject a remote EJB interface, I think it is not work.
also, some one said use JNDI lookup , I suppose it can get it done. but I think it is very ugly way for it.
is there any better solution for this?
any comments?
Many many thanks
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how to use ejb 3.1/3.2 in struts2?
Posted by Mike Guo <ho...@163.com>.
after testing.
that CDI plugin can work on Glassfish4.1.1 and wildly 10
so, I think it will be better to it
thanks everyone
Mike
> 在 2016年3月9日,上午10:50,Mike Guo <ho...@163.com> 写道:
>
> Hi, Martin.
>
>
> thanks for your example.
>
> I guess it is not code in struts? is it spring code?
>
> anyway, I check the original code. but I feel I don’t have much knowledge for spring. so, I have to take much time learn the more code for this. but finally, I gave up that part, but I think it is a way. through I didn’t do test for it.
>
> and I found another interesting thing is:
>
> I used java EE (GlashFish4.1.1), I guess it support Java EE version is 7.
>
> so, I write a example for struts + struts-cdi-plugin.
>
> I found I can use @EJB in action directly.
>
> also, both @Inject and @EJB work well for this.
>
> really thanks Martin and Paul.
>
>
> Mike
>
>
>
>> 在 2016年3月9日,上午9:13,Martin Gainty <mg...@hotmail.com> 写道:
>>
>>
>>
>>
>>> From: hongweig@163.com
>>> Subject: Re: how to use ejb 3.1/3.2 in struts2?
>>> Date: Wed, 9 Mar 2016 06:38:39 +0800
>>> To: user@struts.apache.org
>>>
>>> Hi, Paul
>>>
>>> Thanks your response, yes. I used ee 7,
>>> would you share with me some examples?
>>>
>>> Thanks
>>>
>>> Mike
>>
>> MG>suggest downloading and configuring Glassfish AppServer then download @EJB injection examples at
>>
>> MG>https://glassfish.java.net/javaee5/ejb/examples/Sless.html
>>
>> MG>look at spring @EJB examples inside struts-2.3.18/spring-bom-plugin/spring-framework/spring-context specifically:
>> .\src\main\java\org\springframework\context\annotation\CommonAnnotationBeanPostProcessor.java
>> static { ClassLoader cl = CommonAnnotationBeanPostProcessor.class.getClassLoader(); try { @SuppressWarnings("unchecked") Class<? extends Annotation> clazz = (Class<? extends Annotation>) cl.loadClass("javax.xml.ws.WebServiceRef"); webServiceRefClass = clazz; } catch (ClassNotFoundException ex) { webServiceRefClass = null; } try { @SuppressWarnings("unchecked") Class<? extends Annotation> clazz = (Class<? extends Annotation>) cl.loadClass("javax.ejb.EJB"); ejbRefClass = clazz; } catch (ClassNotFoundException ex) { ejbRefClass = null; } }
>> and the @EJB test:
>>
>> .\src\test\java\org\springframework\context\annotation\CommonAnnotationBeanPostProcessorTests.java
>> public static class ExtendedEjbInjectionBean extends ResourceInjectionBean { @EJB(name="testBean4", beanInterface=TestBean.class) protected ITestBean testBean3;
>> MG>
>>>
>>>
>>> Sent from my iPhone
>>>
>>>> 在 2016年3月8日,23:50,Paul Benedict <pb...@apache.org> 写道:
>>>>
>>>> Are you using an EE 7 server? I believe 7 integrates CDI and EJB so you can
>>>> @Inject your remote bean interfaces. This may also be available in 6, but
>>>> you'd have to research that.
>>>>
>>>> PS: @EJB is a specialized injection annotation that only deals with EJB.
>>>> Obviously, but just wanted to point that out.
>>>>
>>>> Cheers,
>>>> Paul
>>>>
>>>>> On Tue, Mar 8, 2016 at 9:44 AM, Mike Guo <ho...@163.com> wrote:
>>>>>
>>>>> Hello, everyone.
>>>>>
>>>>> I suppose this is very old question to struts user list.
>>>>>
>>>>> how to use EJB 3.1/3.2 in struts2?
>>>>>
>>>>> I did some research on google. but I totally no idea what’s the exactly
>>>>> solution for this.
>>>>>
>>>>> some one said use cdi plugin. but if I use cdi plugin, I guess it can be
>>>>> @inject a ebb into action class. but if I want to inject a remote EJB
>>>>> interface, I think it is not work.
>>>>>
>>>>> also, some one said use JNDI lookup , I suppose it can get it done. but I
>>>>> think it is very ugly way for it.
>>>>>
>>>>>
>>>>> is there any better solution for this?
>>>>>
>>>>> any comments?
>>>>>
>>>>>
>>>>> Many many thanks
>>>>>
>>>>>
>>>>> Mike
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how to use ejb 3.1/3.2 in struts2?
Posted by Mike Guo <ho...@163.com>.
Hi, Martin.
thanks for your example.
I guess it is not code in struts? is it spring code?
anyway, I check the original code. but I feel I don’t have much knowledge for spring. so, I have to take much time learn the more code for this. but finally, I gave up that part, but I think it is a way. through I didn’t do test for it.
and I found another interesting thing is:
I used java EE (GlashFish4.1.1), I guess it support Java EE version is 7.
so, I write a example for struts + struts-cdi-plugin.
I found I can use @EJB in action directly.
also, both @Inject and @EJB work well for this.
really thanks Martin and Paul.
Mike
> 在 2016年3月9日,上午9:13,Martin Gainty <mg...@hotmail.com> 写道:
>
>
>
>
>> From: hongweig@163.com
>> Subject: Re: how to use ejb 3.1/3.2 in struts2?
>> Date: Wed, 9 Mar 2016 06:38:39 +0800
>> To: user@struts.apache.org
>>
>> Hi, Paul
>>
>> Thanks your response, yes. I used ee 7,
>> would you share with me some examples?
>>
>> Thanks
>>
>> Mike
>
> MG>suggest downloading and configuring Glassfish AppServer then download @EJB injection examples at
>
> MG>https://glassfish.java.net/javaee5/ejb/examples/Sless.html
>
> MG>look at spring @EJB examples inside struts-2.3.18/spring-bom-plugin/spring-framework/spring-context specifically:
> .\src\main\java\org\springframework\context\annotation\CommonAnnotationBeanPostProcessor.java
> static { ClassLoader cl = CommonAnnotationBeanPostProcessor.class.getClassLoader(); try { @SuppressWarnings("unchecked") Class<? extends Annotation> clazz = (Class<? extends Annotation>) cl.loadClass("javax.xml.ws.WebServiceRef"); webServiceRefClass = clazz; } catch (ClassNotFoundException ex) { webServiceRefClass = null; } try { @SuppressWarnings("unchecked") Class<? extends Annotation> clazz = (Class<? extends Annotation>) cl.loadClass("javax.ejb.EJB"); ejbRefClass = clazz; } catch (ClassNotFoundException ex) { ejbRefClass = null; } }
> and the @EJB test:
>
> .\src\test\java\org\springframework\context\annotation\CommonAnnotationBeanPostProcessorTests.java
> public static class ExtendedEjbInjectionBean extends ResourceInjectionBean { @EJB(name="testBean4", beanInterface=TestBean.class) protected ITestBean testBean3;
> MG>
>>
>>
>> Sent from my iPhone
>>
>>> 在 2016年3月8日,23:50,Paul Benedict <pb...@apache.org> 写道:
>>>
>>> Are you using an EE 7 server? I believe 7 integrates CDI and EJB so you can
>>> @Inject your remote bean interfaces. This may also be available in 6, but
>>> you'd have to research that.
>>>
>>> PS: @EJB is a specialized injection annotation that only deals with EJB.
>>> Obviously, but just wanted to point that out.
>>>
>>> Cheers,
>>> Paul
>>>
>>>> On Tue, Mar 8, 2016 at 9:44 AM, Mike Guo <ho...@163.com> wrote:
>>>>
>>>> Hello, everyone.
>>>>
>>>> I suppose this is very old question to struts user list.
>>>>
>>>> how to use EJB 3.1/3.2 in struts2?
>>>>
>>>> I did some research on google. but I totally no idea what’s the exactly
>>>> solution for this.
>>>>
>>>> some one said use cdi plugin. but if I use cdi plugin, I guess it can be
>>>> @inject a ebb into action class. but if I want to inject a remote EJB
>>>> interface, I think it is not work.
>>>>
>>>> also, some one said use JNDI lookup , I suppose it can get it done. but I
>>>> think it is very ugly way for it.
>>>>
>>>>
>>>> is there any better solution for this?
>>>>
>>>> any comments?
>>>>
>>>>
>>>> Many many thanks
>>>>
>>>>
>>>> Mike
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: how to use ejb 3.1/3.2 in struts2?
Posted by Martin Gainty <mg...@hotmail.com>.
> From: hongweig@163.com
> Subject: Re: how to use ejb 3.1/3.2 in struts2?
> Date: Wed, 9 Mar 2016 06:38:39 +0800
> To: user@struts.apache.org
>
> Hi, Paul
>
> Thanks your response, yes. I used ee 7,
> would you share with me some examples?
>
> Thanks
>
> Mike
MG>suggest downloading and configuring Glassfish AppServer then download @EJB injection examples at
MG>https://glassfish.java.net/javaee5/ejb/examples/Sless.html
MG>look at spring @EJB examples inside struts-2.3.18/spring-bom-plugin/spring-framework/spring-context specifically:
.\src\main\java\org\springframework\context\annotation\CommonAnnotationBeanPostProcessor.java
static { ClassLoader cl = CommonAnnotationBeanPostProcessor.class.getClassLoader(); try { @SuppressWarnings("unchecked") Class<? extends Annotation> clazz = (Class<? extends Annotation>) cl.loadClass("javax.xml.ws.WebServiceRef"); webServiceRefClass = clazz; } catch (ClassNotFoundException ex) { webServiceRefClass = null; } try { @SuppressWarnings("unchecked") Class<? extends Annotation> clazz = (Class<? extends Annotation>) cl.loadClass("javax.ejb.EJB"); ejbRefClass = clazz; } catch (ClassNotFoundException ex) { ejbRefClass = null; } }
and the @EJB test:
.\src\test\java\org\springframework\context\annotation\CommonAnnotationBeanPostProcessorTests.java
public static class ExtendedEjbInjectionBean extends ResourceInjectionBean { @EJB(name="testBean4", beanInterface=TestBean.class) protected ITestBean testBean3;
MG>
>
>
> Sent from my iPhone
>
> > 在 2016年3月8日,23:50,Paul Benedict <pb...@apache.org> 写道:
> >
> > Are you using an EE 7 server? I believe 7 integrates CDI and EJB so you can
> > @Inject your remote bean interfaces. This may also be available in 6, but
> > you'd have to research that.
> >
> > PS: @EJB is a specialized injection annotation that only deals with EJB.
> > Obviously, but just wanted to point that out.
> >
> > Cheers,
> > Paul
> >
> >> On Tue, Mar 8, 2016 at 9:44 AM, Mike Guo <ho...@163.com> wrote:
> >>
> >> Hello, everyone.
> >>
> >> I suppose this is very old question to struts user list.
> >>
> >> how to use EJB 3.1/3.2 in struts2?
> >>
> >> I did some research on google. but I totally no idea what’s the exactly
> >> solution for this.
> >>
> >> some one said use cdi plugin. but if I use cdi plugin, I guess it can be
> >> @inject a ebb into action class. but if I want to inject a remote EJB
> >> interface, I think it is not work.
> >>
> >> also, some one said use JNDI lookup , I suppose it can get it done. but I
> >> think it is very ugly way for it.
> >>
> >>
> >> is there any better solution for this?
> >>
> >> any comments?
> >>
> >>
> >> Many many thanks
> >>
> >>
> >> Mike
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
Re: how to use ejb 3.1/3.2 in struts2?
Posted by Mike Guo <ho...@163.com>.
Hi, Paul
Thanks your response, yes. I used ee 7,
would you share with me some examples?
Thanks
Mike
Sent from my iPhone
> 在 2016年3月8日,23:50,Paul Benedict <pb...@apache.org> 写道:
>
> Are you using an EE 7 server? I believe 7 integrates CDI and EJB so you can
> @Inject your remote bean interfaces. This may also be available in 6, but
> you'd have to research that.
>
> PS: @EJB is a specialized injection annotation that only deals with EJB.
> Obviously, but just wanted to point that out.
>
> Cheers,
> Paul
>
>> On Tue, Mar 8, 2016 at 9:44 AM, Mike Guo <ho...@163.com> wrote:
>>
>> Hello, everyone.
>>
>> I suppose this is very old question to struts user list.
>>
>> how to use EJB 3.1/3.2 in struts2?
>>
>> I did some research on google. but I totally no idea what’s the exactly
>> solution for this.
>>
>> some one said use cdi plugin. but if I use cdi plugin, I guess it can be
>> @inject a ebb into action class. but if I want to inject a remote EJB
>> interface, I think it is not work.
>>
>> also, some one said use JNDI lookup , I suppose it can get it done. but I
>> think it is very ugly way for it.
>>
>>
>> is there any better solution for this?
>>
>> any comments?
>>
>>
>> Many many thanks
>>
>>
>> Mike
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how to use ejb 3.1/3.2 in struts2?
Posted by Paul Benedict <pb...@apache.org>.
Are you using an EE 7 server? I believe 7 integrates CDI and EJB so you can
@Inject your remote bean interfaces. This may also be available in 6, but
you'd have to research that.
PS: @EJB is a specialized injection annotation that only deals with EJB.
Obviously, but just wanted to point that out.
Cheers,
Paul
On Tue, Mar 8, 2016 at 9:44 AM, Mike Guo <ho...@163.com> wrote:
> Hello, everyone.
>
> I suppose this is very old question to struts user list.
>
> how to use EJB 3.1/3.2 in struts2?
>
> I did some research on google. but I totally no idea what’s the exactly
> solution for this.
>
> some one said use cdi plugin. but if I use cdi plugin, I guess it can be
> @inject a ebb into action class. but if I want to inject a remote EJB
> interface, I think it is not work.
>
> also, some one said use JNDI lookup , I suppose it can get it done. but I
> think it is very ugly way for it.
>
>
> is there any better solution for this?
>
> any comments?
>
>
> Many many thanks
>
>
> Mike
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>