Re: Re: Re: Re: Re: Re: How to change remote JNDI-name in Jonas
"Guillaume Sauthier (OW2)" <[email protected]> Tue, 9 Aug 2011 13:51:25 +0200
| Newsgroups | gmane.comp.java.objectweb.jonas |
|---|---|
| Message-ID | <CAG1yf3Mwb9e65TgBtw7VgT4OcfCq3B2UUZAN-JHS9jkrj3W_Hw@mail.gmail.com> |
--0016367fafdfebca8e04aa112e72 Content-Type: text/plain; charset=ISO-8859-1 EasyBeans (the EJB3 container in JOnAS) gives priority to beans found in the same application if there is multiple match. The EJB3 spec mandates that behavior so you're safe :) Just make a try. --G 2011/8/9 Stefaan Somers <[email protected]> > But, > > our applications are generated, so we can have for example 2 > account-beans in 2 different applications. Therefore we must be able > to uniquely identify the 2 remote JNDI interfaces to the 2 different > applications. That's why we are using "mappedName" > > Greetings, > > Stefaan Somers > > On 9 August 2011 11:55, Guillaume Sauthier (OW2) > <[email protected]> wrote: > > You should also remove your mapped names (don't needed anymore because > you > > rely on the container to find the right interface for you). > > > > --G > > > > 2011/8/9 Stefaan Somers <[email protected]> > >> > >> Hello, > >> > >> I'v tried that too, but it also injects the remote-bean then instead > >> of the local-bean. > >> > >> Greetings, > >> > >> Stefaan Somers > >> > >> On 9 August 2011 11:04, Guillaume Sauthier (OW2) > >> <[email protected]> wrote: > >> > Can't you change your Calculator.java to something like this: > >> > > >> > It's much more easier to read :) > >> > > >> > /** > >> > * Session Bean implementation class Calculator > >> > */ > >> > @Stateless > >> > public class Calculator implements CalculatorRemote, CalculatorLocal { > >> > > >> > @EJB > >> > private ParametersLocal params; > >> > > >> > > >> > /** > >> > * Default constructor. > >> > */ > >> > public Calculator() { > >> > > >> > } > >> > > >> > @Override > >> > public String returnMessage() { > >> > result = parameters.getParameter(); > >> > return "It's all being calculated :" + result; > >> > } > >> > > >> > } > >> > > >> > 2011/8/9 Stefaan Somers <[email protected]> > >> >> > >> >> Hi Guillaume, > >> >> Thnks for responding. I'm already banging my head for a few days with > >> >> this problem. So any help would be most welcome. > >> >> > >> >> I've included a sample project. For the Parameters-bean I use the > >> >> mappedName parameter, since I need to give it a unique-name. > >> >> > >> >> If I try to get the Local Parameters-bean with the Calculator-bean, > it > >> >> gives me the following exception : > >> >> > >> >> java.lang.ClassCastException: $Proxy63 cannot be cast to > >> >> be.sso.test.ParametersLocal > >> >> at > >> >> > >> >> > be.sso.test.Calculator.original$EasyBeans$returnMessage(Calculator.java:34) > >> >> at > >> >> > >> >> > org.ow2.easybeans.gen.invocationcontext.be.sso.test.Calculator.EasyBeansInvocationContextImplreturnMessageAROUNDINVOKE1942950347.proceed(Unknown > >> >> Source) > >> >> at > >> >> > >> >> > org.ow2.easybeans.transaction.interceptors.CMTRequiredTransactionInterceptor.intercept(CMTRequiredTransactionInterceptor.java:110) > >> >> at > >> >> > >> >> > org.ow2.easybeans.gen.invocationcontext.be.sso.test.Calculator.EasyBeansInvocationContextImplreturnMessageAROUNDINVOKE1942950347.proceed(Unknown > >> >> Source) > >> >> at > >> >> > >> >> > org.ow2.jonas.jndi.interceptors.impl.easybeans.ResourceCheckerInterceptor.intercept(ResourceCheckerInterceptor.java:103) > >> >> at > >> >> > >> >> > org.ow2.easybeans.gen.invocationcontext.be.sso.test.Calculator.EasyBeansInvocationContextImplreturnMessageAROUNDINVOKE1942950347.proceed(Unknown > >> >> Source) > >> >> at > >> >> > >> >> > org.ow2.jonas.ejb.easybeans.JOnASENCInterceptor.intercept(JOnASENCInterceptor.java:67) > >> >> at > >> >> > >> >> > org.ow2.easybeans.gen.invocationcontext.be.sso.test.Calculator.EasyBeansInvocationContextImplreturnMessageAROUNDINVOKE1942950347.proceed(Unknown > >> >> Source) > >> >> at be.sso.test.Calculator.returnMessage(Calculator.java) > >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > >> >> at > >> >> > >> >> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > >> >> at > >> >> > >> >> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > >> >> at java.lang.reflect.Method.invoke(Method.java:597) > >> >> at > >> >> > >> >> > org.ow2.easybeans.container.session.stateless.StatelessSessionFactory.localCall(StatelessSessionFactory.java:161) > >> >> at > >> >> > >> >> > org.ow2.easybeans.container.session.SessionFactory.rpcInvoke(SessionFactory.java:237) > >> >> at > >> >> > >> >> > org.ow2.easybeans.rpc.rmi.server.RMIServerRPCImpl.getEJBResponse(RMIServerRPCImpl.java:106) > >> >> at > >> >> > >> >> > org.ow2.easybeans.rpc.rmi.client.RMIClientRPC.sendEJBRequest(RMIClientRPC.java:105) > >> >> at > >> >> > >> >> > org.ow2.easybeans.proxy.client.ClientRPCInvocationHandler.invoke(ClientRPCInvocationHandler.java:195) > >> >> at > >> >> > >> >> > org.ow2.easybeans.proxy.client.ClientRPCInvocationHandler.invoke(ClientRPCInvocationHandler.java:111) > >> >> at $Proxy62.returnMessage(Unknown Source) > >> >> at > >> >> be.sso.servlet.CalculateServlet.doGet(CalculateServlet.java:40) > >> >> at > javax.servlet.http.HttpServlet.service(HttpServlet.java:617) > >> >> at > javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > >> >> at > >> >> > >> >> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > >> >> at > >> >> > >> >> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >> >> at > >> >> > >> >> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > >> >> at > >> >> > >> >> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > >> >> at > >> >> > >> >> > org.ow2.jonas.web.tomcat6.CheckOpenResourcesValve.invoke(CheckOpenResourcesValve.java:73) > >> >> at > >> >> > >> >> > org.ow2.jonas.web.tomcat6.tx.TransactionValve.invoke(TransactionValve.java:90) > >> >> at > >> >> > >> >> > org.ow2.jonas.web.tomcat6.ResetAuthenticationValve.invoke(ResetAuthenticationValve.java:95) > >> >> at > >> >> > >> >> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > >> >> at > >> >> > >> >> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > >> >> at > >> >> > >> >> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > >> >> at > >> >> > >> >> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340) > >> >> at > >> >> > >> >> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) > >> >> at > >> >> > >> >> > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > >> >> at > >> >> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > >> >> at java.lang.Thread.run(Thread.java:619) > >> >> > >> >> > >> >> > >> >> On 9 August 2011 10:45, Guillaume Sauthier (OW2) > >> >> <[email protected]> wrote: > >> >> > Can't you rely on container's injection (@EJB) ? > >> >> > --G > >> >> > > >> >> > 2011/8/9 Stefaan Somers <[email protected]> > >> >> >> > >> >> >> Hi all, > >> >> >> > >> >> >> I need to change the remote jndi-name of a Stateless Session Bean > . > >> >> >> Default the naming for jonas is : > >> >> >> > >> >> >> SessionBean.class.getName() > >> >> >> + "_" + SessionBeanInterface.class.getName() + "@Remote" > >> >> >> > >> >> >> How can I change this. If I add the attribute mappedName in the > >> >> >> @Stateless-annotation, I cannot get to the Local Interface > anymore. > >> >> >> And I need to be able to get to both. > >> >> >> > >> >> >> Greetings, > >> >> >> > >> >> >> Stefaan Somers > >> >> > > >> >> > > >> > > >> > > > > > > --0016367fafdfebca8e04aa112e72 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable EasyBeans (the EJB3 container in JOnAS) gives priority to beans found in th= e same application if there is multiple match.<br>The EJB3 spec mandates th= at behavior so you're safe :)<br>Just make a try.<br>--G<br><br><div cl= ass=3D"gmail_quote"> 2011/8/9 Stefaan Somers <span dir=3D"ltr"><<a href=3D"mailto:stefaan.som= [email protected]">[email protected]</a>></span><br><blockquote class= =3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd= ing-left:1ex;"> But,<br> <br> our applications are generated, so we can have for example 2<br> account-beans in 2 different applications. Therefore we must be able<br> to uniquely identify the 2 remote JNDI interfaces to the 2 different<br> applications. That's why we are using "mappedName"<br> <br> Greetings,<br> <br> Stefaan Somers<br> <br> On 9 August 2011 11:55, Guillaume Sauthier (OW2)<br> <div><div></div><div class=3D"h5"><<a href=3D"mailto:guillaume.sauthier@= ow2.org">[email protected]</a>> wrote:<br> > You should also remove your mapped names (don't needed anymore bec= ause you<br> > rely on the container to find the right interface for you).<br> ><br> > --G<br> ><br> > 2011/8/9 Stefaan Somers <<a href=3D"mailto:[email protected]= ">[email protected]</a>><br> >><br> >> Hello,<br> >><br> >> I'v tried that too, but it also injects the remote-bean then i= nstead<br> >> of the local-bean.<br> >><br> >> Greetings,<br> >><br> >> Stefaan Somers<br> >><br> >> On 9 August 2011 11:04, Guillaume Sauthier (OW2)<br> >> <<a href=3D"mailto:[email protected]">guillaume.sauthi= [email protected]</a>> wrote:<br> >> > Can't you change your Calculator.java to something like t= his:<br> >> ><br> >> > It's much more easier to read :)<br> >> ><br> >> > /**<br> >> > =A0* Session Bean implementation class Calculator<br> >> > =A0*/<br> >> > @Stateless<br> >> > public class Calculator implements CalculatorRemote, Calculat= orLocal {<br> >> ><br> >> > =A0 @EJB<br> >> > =A0 private ParametersLocal params;<br> >> ><br> >> ><br> >> > =A0=A0=A0 /**<br> >> > =A0=A0=A0=A0 * Default constructor.<br> >> > =A0=A0=A0=A0 */<br> >> > =A0=A0=A0 public Calculator() {<br> >> ><br> >> > =A0=A0=A0 }<br> >> ><br> >> > =A0=A0=A0 @Override<br> >> > =A0=A0=A0 public String returnMessage() {<br> >> > =A0=A0=A0 =A0=A0=A0 result =3D parameters.getParameter();<br> >> > =A0=A0=A0 =A0=A0=A0 return "It's all being calculate= d :" + result;<br> >> > =A0=A0=A0 }<br> >> ><br> >> > }<br> >> ><br> >> > 2011/8/9 Stefaan Somers <<a href=3D"mailto:stefaan.somers@= gmail.com">[email protected]</a>><br> >> >><br> >> >> Hi Guillaume,<br> >> >> Thnks for responding. I'm already banging my head for= a few days with<br> >> >> this problem. So any help would be most welcome.<br> >> >><br> >> >> I've included a sample project. For the Parameters-be= an I use the<br> >> >> mappedName parameter, since I need to give it a unique-na= me.<br> >> >><br> >> >> If I try to get the Local Parameters-bean with the Calcul= ator-bean, it<br> >> >> gives me the following exception :<br> >> >><br> >> >> java.lang.ClassCastException: $Proxy63 cannot be cast to<= br> >> >> be.sso.test.ParametersLocal<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> be.sso.test.Calculator.original$EasyBeans$returnMessage(C= alculator.java:34)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.gen.invocationcontext.be.sso.test.Calcu= lator.EasyBeansInvocationContextImplreturnMessageAROUNDINVOKE1942950347.pro= ceed(Unknown<br> >> >> Source)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.transaction.interceptors.CMTRequiredTra= nsactionInterceptor.intercept(CMTRequiredTransactionInterceptor.java:110)<b= r> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.gen.invocationcontext.be.sso.test.Calcu= lator.EasyBeansInvocationContextImplreturnMessageAROUNDINVOKE1942950347.pro= ceed(Unknown<br> >> >> Source)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.jonas.jndi.interceptors.impl.easybeans.ResourceCh= eckerInterceptor.intercept(ResourceCheckerInterceptor.java:103)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.gen.invocationcontext.be.sso.test.Calcu= lator.EasyBeansInvocationContextImplreturnMessageAROUNDINVOKE1942950347.pro= ceed(Unknown<br> >> >> Source)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.jonas.ejb.easybeans.JOnASENCInterceptor.intercept= (JOnASENCInterceptor.java:67)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.gen.invocationcontext.be.sso.test.Calcu= lator.EasyBeansInvocationContextImplreturnMessageAROUNDINVOKE1942950347.pro= ceed(Unknown<br> >> >> Source)<br> >> >> =A0 =A0 =A0 =A0at be.sso.test.Calculator.returnMessage(Ca= lculator.java)<br> >> >> =A0 =A0 =A0 =A0at sun.reflect.NativeMethodAccessorImpl.in= voke0(Native Method)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodA= ccessorImpl.java:39)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegatin= gMethodAccessorImpl.java:25)<br> >> >> =A0 =A0 =A0 =A0at java.lang.reflect.Method.invoke(Method.= java:597)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.container.session.stateless.StatelessSe= ssionFactory.localCall(StatelessSessionFactory.java:161)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.container.session.SessionFactory.rpcInv= oke(SessionFactory.java:237)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.rpc.rmi.server.RMIServerRPCImpl.getEJBR= esponse(RMIServerRPCImpl.java:106)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.rpc.rmi.client.RMIClientRPC.sendEJBRequ= est(RMIClientRPC.java:105)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.proxy.client.ClientRPCInvocationHandler= .invoke(ClientRPCInvocationHandler.java:195)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.easybeans.proxy.client.ClientRPCInvocationHandler= .invoke(ClientRPCInvocationHandler.java:111)<br> >> >> =A0 =A0 =A0 =A0at $Proxy62.returnMessage(Unknown Source)<= br> >> >> =A0 =A0 =A0 =A0at<br> >> >> be.sso.servlet.CalculateServlet.doGet(CalculateServlet.ja= va:40)<br> >> >> =A0 =A0 =A0 =A0at javax.servlet.http.HttpServlet.service(= HttpServlet.java:617)<br> >> >> =A0 =A0 =A0 =A0at javax.servlet.http.HttpServlet.service(= HttpServlet.java:717)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.apache.catalina.core.ApplicationFilterChain.internalD= oFilter(ApplicationFilterChain.java:290)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(= ApplicationFilterChain.java:206)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.apache.catalina.core.StandardWrapperValve.invoke(Stan= dardWrapperValve.java:233)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.apache.catalina.core.StandardContextValve.invoke(Stan= dardContextValve.java:191)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.jonas.web.tomcat6.CheckOpenResourcesValve.invoke(= CheckOpenResourcesValve.java:73)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.jonas.web.tomcat6.tx.TransactionValve.invoke(Tran= sactionValve.java:90)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.ow2.jonas.web.tomcat6.ResetAuthenticationValve.invoke= (ResetAuthenticationValve.java:95)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.apache.catalina.core.StandardHostValve.invoke(Standar= dHostValve.java:127)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorR= eportValve.java:102)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.apache.catalina.core.StandardEngineValve.invoke(Stand= ardEngineValve.java:109)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.apache.catalina.connector.CoyoteAdapter.service(Coyot= eAdapter.java:340)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.apache.coyote.http11.Http11Processor.process(Http11Pr= ocessor.java:857)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >><br> >> >> org.apache.coyote.http11.Http11Protocol$Http11ConnectionH= andler.process(Http11Protocol.java:588)<br> >> >> =A0 =A0 =A0 =A0at<br> >> >> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndp= oint.java:489)<br> >> >> =A0 =A0 =A0 =A0at java.lang.Thread.run(Thread.java:619)<b= r> >> >><br> >> >><br> >> >><br> >> >> On 9 August 2011 10:45, Guillaume Sauthier (OW2)<br> >> >> <<a href=3D"mailto:[email protected]">guillau= [email protected]</a>> wrote:<br> >> >> > Can't you rely on container's injection (@EJ= B) ?<br> >> >> > --G<br> >> >> ><br> >> >> > 2011/8/9 Stefaan Somers <<a href=3D"mailto:stefaa= [email protected]">[email protected]</a>><br> >> >> >><br> >> >> >> Hi all,<br> >> >> >><br> >> >> >> I need to change the remote jndi-name of a State= less Session Bean .<br> >> >> >> Default the naming for jonas is :<br> >> >> >><br> >> >> >> SessionBean.class.getName()<br> >> >> >> + "_" + SessionBeanInterface.class.get= Name() + "@Remote"<br> >> >> >><br> >> >> >> How can I change this. If I add the attribute ma= ppedName in the<br> >> >> >> @Stateless-annotation, I cannot get to the Local= Interface anymore.<br> >> >> >> And I need to be able to get to both.<br> >> >> >><br> >> >> >> Greetings,<br> >> >> >><br> >> >> >> Stefaan Somers<br> >> >> ><br> >> >> ><br> >> ><br> >> ><br> ><br> ><br> </div></div></blockquote></div><br> --0016367fafdfebca8e04aa112e72--