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 <mgai...@hotmail.com> 写道:
> 
> 
> 
> 
>> From: hongw...@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 <pbened...@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 <hongw...@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-unsubscr...@struts.apache.org
>>>> For additional commands, e-mail: user-h...@struts.apache.org
>>>> 
>>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>> 
>                                         



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

Reply via email to