btw, I invoke the lookup method in a servlet, while considering that the invocation for wink classes is in the same thread, think it is also able to do that in rest class.
2012/11/7 Ivan <[email protected]> > Just have a try, the codes below work for me. I packaged the ejb and war > in the ear. > > TestEJB.jar > > package org.apache.geronimo.test; > > import javax.ejb.Local; > > @Local > public interface TestBeanInterface { > > public void test(); > } > > package org.apache.geronimo.test; > > import javax.ejb.Stateless; > > /** > * Session Bean implementation class TestBean > */ > @Stateless(name = "TestBean") > public class TestBean implements TestBeanInterface { > > /** > * Default constructor. > */ > public TestBean() { > // TODO Auto-generated constructor stub > } > > public void test() { > > } > > } > > TestWeb.war > > <?xml version="1.0" encoding="UTF-8"?> > <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/javaee > http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> > > <ejb-local-ref> > <ejb-ref-name>ejb/TestBean</ejb-ref-name> > <ejb-ref-type>Session</ejb-ref-type> > <local>org.apache.geronimo.test.TestBeanInterface</local> > <ejb-link>TestEJB.jar#TestBean</ejb-link> > </ejb-local-ref> > </web-app> > > Hope it helps. > > 2012/11/7 Michael Baylis <[email protected]> > >> Hi Ivan, >> I am afraid it didn't make a difference. >> >> I've tried:- >> >> Object x = ic.lookup("java:comp/env/ejb/TestEJB"); >> Object x = ic.lookup("ejb/TestEJB"); >> >> with the ejb-ref you provided. >> >> As I am using EJB 3.1 and annotations, I didn't put anything in >> ejb-jar.xml or openejb-jar.xml. Does anything need to go in there? >> >> Cheers, >> >> Michael >> >> >> On 06/11/2012 14:44, Ivan wrote: >> >> If the ejb jar is packaged in the same ear, could you try whether the >> configuration below works for you : >> >> <ejb-ref> >> <ref-name>ejb/TestEJB</ref-name> >> <ejb-link>bob.ejb#TestEJB</ejb-link> >> </ejb-ref> >> >> 2012/11/6 Michael Baylis <[email protected]> >> >>> Hi Folks, >>> Help!!! >>> >>> Whenever I start to use Wink with EJBs I always seem to get totally >>> confused wth JNDI lookups, please could you resolve this once and for all >>> for me. >>> >>> I have a restful service that would like to do a call to an EJB. I >>> have tried many combinations, but the following is what I have pieced >>> together from the docs:- >>> >>> I am using Geronimo 3.0.0, and as I understand it EJB injection does not >>> work in Wink (in Geronimo or IBM WAS 8.0) as the service class is loaded >>> but the rest servlet, so I have to use a jndi lookup:- >>> >>> bob.ear has bob.web, the restful service. >>> bob.ejb is seperate (but I would like it in the ear). >>> >>> bob.ejb has TestEJB with a @Remote and @Local which results in:- >>> >>> 2012-11-05 22:21:45,603 INFO [startup] Assembling app: >>> C:\Users\mikebyls\software\eclipse\default\bob.ejb\1.0\jar >>> 2012-11-05 22:21:45,619 INFO [startup] Jndi(name=TestEJBLocal) --> >>> Ejb(deployment-id=bob.ejb.jar/TestEJB) >>> 2012-11-05 22:21:45,619 INFO [startup] >>> Jndi(name=global/bob.ejb/TestEJB!bob.ejb.TestEJBLocal) --> >>> Ejb(deployment-id=bob.ejb.jar/TestEJB) >>> 2012-11-05 22:21:45,619 INFO [startup] Jndi(name=TestEJBRemote) --> >>> Ejb(deployment-id=bob.ejb.jar/TestEJB) >>> 2012-11-05 22:21:45,619 INFO [startup] >>> Jndi(name=global/bob.ejb/TestEJB!bob.ejb.TestEJBRemote) --> >>> Ejb(deployment-id=bob.ejb.jar/TestEJB) >>> 2012-11-05 22:21:45,619 INFO [startup] >>> Jndi(name=global/bob.ejb/TestEJB) --> Ejb(deployment-id=bob.ejb.jar/TestEJB) >>> >>> My bob.web deployment is:- >>> <web:web-app xmlns:app=" >>> http://geronimo.apache.org/xml/ns/j2ee/application-2.0" xmlns:bp=" >>> http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:client=" >>> http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0" >>> xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2" >>> xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:ejb=" >>> http://openejb.apache.org/xml/ns/openejb-jar-2.2" xmlns:jaspi=" >>> http://geronimo.apache.org/xml/ns/geronimo-jaspi" xmlns:log=" >>> http://geronimo.apache.org/xml/ns/loginconfig-2.0" xmlns:name=" >>> http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:pers=" >>> http://java.sun.com/xml/ns/persistence" xmlns:pkgen=" >>> http://openejb.apache.org/xml/ns/pkgen-2.1" xmlns:sec=" >>> http://geronimo.apache.org/xml/ns/security-2.0" xmlns:web=" >>> http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1"> >>> <dep:environment> >>> <dep:moduleId> >>> <dep:groupId>default</dep:groupId> >>> <dep:artifactId>bob.web</dep:artifactId> >>> <dep:version>1.0</dep:version> >>> <dep:type>car</dep:type> >>> </dep:moduleId> >>> <dep:dependencies> >>> <dep:dependency> >>> <dep:groupId>default</dep:groupId> >>> <dep:artifactId>bob.ejb</dep:artifactId> >>> <dep:version>1.0</dep:version> >>> <dep:type>jar</dep:type> >>> </dep:dependency> >>> </dep:dependencies> >>> </dep:environment> >>> <web:context-root>/bob</web:context-root> >>> <name:ejb-ref> >>> <name:ref-name>ejb/TestEJB</name:ref-name> >>> <name:ejb-link>TestEJBRemote</name:ejb-link> >>> </name:ejb-ref> >>> </web:web-app> >>> >>> >>> My Test Restful service is:- >>> >>> @Path("test") >>> public class Test1 { >>> >>> @GET >>> @Produces(MediaType.TEXT_PLAIN) >>> public String get() throws NamingException { >>> >>> InitialContext ic = new InitialContext(); >>> >>> Object x = ic.lookup("java:comp/env/ejb/TestEJB"); >>> >>> return "boo"; >>> } >>> >>> } >>> >>> >>> I have tried allsorts of combinations with the name, with the ejb in the >>> same ear, using local and remote interfaces, etc. Ive googled, but cant >>> seem to find a combination that willwork. >>> I have also tried different >>> "<name:ejb-link>TestEJBRemote</name:ejb-link>" names. >>> >>> Please put me out of my misery. >>> >>> Would it be possible to give me a solution that would work with the EJB >>> module in the same EAR as the WEB module please. >>> >>> Regards, >>> >>> Michael >>> >> >> >> >> -- >> Ivan >> >> >> > > > -- > Ivan > -- Ivan
