You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Oddward <su...@web.de> on 2009/01/21 20:23:26 UTC

inject EJB in Webapplication

Hello,

i have a Webservice that needs access an EJB inside an EAR. Im using
geronimo 2.1 with tomcat. I followed these instructions
http://cwiki.apache.org/GMOxDOC21/referring-to-an-ejb-from-outside-its-ear.html
with no result. I think its for EJBs not Servlets.

here some code snipits:


Webserviceclass:
	@EJB(name="dispatcher")
	protected MpeMessageDispatcherInterface mpe;
Web.xml:
   <dep:environment>
        <dep:moduleId>
            <dep:groupId>com.webservice.app</dep:groupId>
            <dep:artifactId>appwebservice</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>car</dep:type>
        </dep:moduleId>
         <sys:dependencies>
            <sys:dependency>
                <sys:groupId>myadear</sys:groupId>
                <sys:artifactId>myad-ear</sys:artifactId>
                <sys:version>1.0</sys:version>
            	<sys:type>car</sys:type>
            </sys:dependency>            
    </sys:dependencies>
    </dep:environment>
    <web:context-root>/IPhoneAppWS</web:context-root>
    <name:ejb-ref>
    	<name:ref-name>dispatcher</name:ref-name>
    	<name:pattern>
    		<name:groupId>my-ear</name:groupId>
	    	<name:artifactId>myear</name:artifactId>
	    	<name:version>1.0</name:version>
	    	<name:name>MpeMessageDispatcher</name:name>
    	</name:pattern>
    </name:ejb-ref>
</web:web-app>

EJBinterface:
@Remote
public interface MpeMessageDispatcherInterface {

EJB:
@Stateless(name="MpeMessageDispatcher")
public class MpeMessageDispatcher implements MpeMessageDispatcherInterface {

javax.xml.ws.WebServiceException: Service resource injection failed
....
Caused by: java.lang.InstantiationException: Some objects to be injected
were not found in jndi: [javax.naming.NameNotFoundException: Name
"java:openejb/Deployment/myear/MpeMessageDispatcher/myear.mpe.MpeMessageDispatcherInterface"
not found.]
	at org.apache.geronimo.j2ee.annotation.Holder.newInstance(Holder.java:171)
	at
org.apache.geronimo.jaxws.annotations.AnnotationHolder.newInstance(AnnotationHolder.java:39)
	at org.apache.geronimo.cxf.pojo.POJOEndpoint.<init>(POJOEndpoint.java:76)
	... 65 more
inject

thx



-- 
View this message in context: http://www.nabble.com/inject-EJB-in-Webapplication-tp21590354s134p21590354.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: inject EJB in Webapplication

Posted by Shawn Jiang <ge...@gmail.com>.
No standalone EJB jar here.  I deployed the EJB along with a EAR.

On Wed, Apr 15, 2009 at 8:09 PM, viola lu <vi...@gmail.com> wrote:

> Pls try to add EJB jar dependency called to your geronimo-web.xml so that
> EJB is visible to your web application.for example:
>
>  <sys:dependencies>
>             <sys:dependency>
>
>                 <sys:groupId>default</sys:groupId>
>                     <sys:artifactId>CounterBean</sys:artifactId>
>       		    <sys:version>1.0</sys:version>
>
>       		    <sys:type>car</sys:type>
>             </sys:dependency>
>         </sys:dependencies>
>
>
> On Wed, Apr 15, 2009 at 5:52 PM, Shawn Jiang <ge...@gmail.com> wrote:
>
>> I encounter the same problem. Here is my case.
>> 1, deploy a ear package contain a session bean(deployed JNDI name
>> "CounterBeanRemote") implement a remote interface.
>>
>> 2, deploy a war package that contains a servlet using
>> @EJB(mappedName="CounterBeanRemote") to inject the EJB.
>>
>>
>>
>> When I access the servlet, I get:
>>
>> Exception: Some objects to be injected were not found in jndi: [javax.naming.NameNotFoundException: Name "java:openejb/Deployment/CounterBeanRemote/org.test.CounterRemote" not found.]
>> 	org.apache.geronimo.j2ee.annotation.Holder.newInstance(Holder.java:171)
>>
>>
>> Any advice per question can we inject EJB from a war outside the EJB ear
>>  ?
>>
>>
>> On Thu, Jan 29, 2009 at 1:06 AM, Oddward <su...@web.de>wrote:
>>
>>>
>>> 1. yes, the ear is running when i get the error
>>> 2. in ${geronimo.home}/var/log/geronimo.log i get the following:
>>>
>>> [OpenEJB] Auto-deploying ejb MpeMessageDispatcher:
>>> EjbDeployment(deployment-id=myAdEJB.jar/MpeMessageDispatcher)
>>> ...
>>> [startup] Jndi(name=MpeMessageDispatcherRemote) -->
>>> Ejb(deployment-id=myAdEJB.jar/MpeMessageDispatcher)
>>> ...
>>> [startup] Created Ejb(deployment-id=myAdEJB.jar/MpeMessageDispatcher,
>>> ejb-name=MpeMessageDispatcher, container=Default Stateless Container)
>>>
>>> i tried
>>> Webserviceclass:
>>>        @EJB(name="MpeMessageDispatcherRemote")
>>>        protected MpeMessageDispatcherInterface mpe;
>>>
>>> with no success
>>>
>>> thx
>>>
>>>
>>> djencks wrote:
>>> >
>>> > Is the ear that contains the ejb running when you get this error?
>>> >
>>> > When an ejb app starts, openejb prints the global jndi names it binds
>>> > the ejbs under in ${geronimo.home}/var/log/geronimo.log.  Can you look
>>> > and see what name your ejb is actually bound under?
>>> >
>>> > thanks
>>> > david jencks
>>> >
>>> > On Jan 21, 2009, at 11:23 AM, Oddward wrote:
>>> >
>>> >>
>>> >> Hello,
>>> >>
>>> >> i have a Webservice that needs access an EJB inside an EAR. Im using
>>> >> geronimo 2.1 with tomcat. I followed these instructions
>>> >>
>>> http://cwiki.apache.org/GMOxDOC21/referring-to-an-ejb-from-outside-its-ear.html
>>> >> with no result. I think its for EJBs not Servlets.
>>> >>
>>> >> here some code snipits:
>>> >>
>>> >>
>>> >> Webserviceclass:
>>> >>      @EJB(name="dispatcher")
>>> >>      protected MpeMessageDispatcherInterface mpe;
>>> >> Web.xml:
>>> >>   <dep:environment>
>>> >>        <dep:moduleId>
>>> >>            <dep:groupId>com.webservice.app</dep:groupId>
>>> >>            <dep:artifactId>appwebservice</dep:artifactId>
>>> >>            <dep:version>1.0</dep:version>
>>> >>            <dep:type>car</dep:type>
>>> >>        </dep:moduleId>
>>> >>         <sys:dependencies>
>>> >>            <sys:dependency>
>>> >>                <sys:groupId>myadear</sys:groupId>
>>> >>                <sys:artifactId>myad-ear</sys:artifactId>
>>> >>                <sys:version>1.0</sys:version>
>>> >>              <sys:type>car</sys:type>
>>> >>            </sys:dependency>
>>> >>    </sys:dependencies>
>>> >>    </dep:environment>
>>> >>    <web:context-root>/IPhoneAppWS</web:context-root>
>>> >>    <name:ejb-ref>
>>> >>      <name:ref-name>dispatcher</name:ref-name>
>>> >>      <name:pattern>
>>> >>              <name:groupId>my-ear</name:groupId>
>>> >>              <name:artifactId>myear</name:artifactId>
>>> >>              <name:version>1.0</name:version>
>>> >>              <name:name>MpeMessageDispatcher</name:name>
>>> >>      </name:pattern>
>>> >>    </name:ejb-ref>
>>> >> </web:web-app>
>>> >>
>>> >> EJBinterface:
>>> >> @Remote
>>> >> public interface MpeMessageDispatcherInterface {
>>> >>
>>> >> EJB:
>>> >> @Stateless(name="MpeMessageDispatcher")
>>> >> public class MpeMessageDispatcher implements
>>> >> MpeMessageDispatcherInterface {
>>> >>
>>> >> javax.xml.ws.WebServiceException: Service resource injection failed
>>> >> ....
>>> >> Caused by: java.lang.InstantiationException: Some objects to be
>>> >> injected
>>> >> were not found in jndi: [javax.naming.NameNotFoundException: Name
>>> >> "java:openejb/Deployment/myear/MpeMessageDispatcher/
>>> >> myear.mpe.MpeMessageDispatcherInterface"
>>> >> not found.]
>>> >>      at
>>> >> org.apache.geronimo.j2ee.annotation.Holder.newInstance(Holder.java:
>>> >> 171)
>>> >>      at
>>> >> org
>>> >> .apache
>>> >> .geronimo
>>> >> .jaxws
>>> >> .annotations.AnnotationHolder.newInstance(AnnotationHolder.java:39)
>>> >>      at
>>> >> org.apache.geronimo.cxf.pojo.POJOEndpoint.<init>(POJOEndpoint.java:76)
>>> >>      ... 65 more
>>> >> inject
>>> >>
>>> >> thx
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/inject-EJB-in-Webapplication-tp21590354s134p21590354.html
>>> >> Sent from the Apache Geronimo - Users mailing list archive at
>>> >> Nabble.com.
>>> >>
>>> >
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/inject-EJB-in-Webapplication-tp21590354s134p21710008.html
>>> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>> --
>> Shawn
>>
>
>
>
> --
> viola
>



-- 
Shawn

Re: inject EJB in Webapplication

Posted by viola lu <vi...@gmail.com>.
Pls try to add EJB jar dependency called to your geronimo-web.xml so that
EJB is visible to your web application.for example:

 <sys:dependencies>
            <sys:dependency>
                <sys:groupId>default</sys:groupId>
                    <sys:artifactId>CounterBean</sys:artifactId>
      		    <sys:version>1.0</sys:version>
      		    <sys:type>car</sys:type>
            </sys:dependency>
        </sys:dependencies>


On Wed, Apr 15, 2009 at 5:52 PM, Shawn Jiang <ge...@gmail.com> wrote:

> I encounter the same problem. Here is my case.
> 1, deploy a ear package contain a session bean(deployed JNDI name
> "CounterBeanRemote") implement a remote interface.
>
> 2, deploy a war package that contains a servlet using
> @EJB(mappedName="CounterBeanRemote") to inject the EJB.
>
>
>
> When I access the servlet, I get:
>
> Exception: Some objects to be injected were not found in jndi: [javax.naming.NameNotFoundException: Name "java:openejb/Deployment/CounterBeanRemote/org.test.CounterRemote" not found.]
> 	org.apache.geronimo.j2ee.annotation.Holder.newInstance(Holder.java:171)
>
>
> Any advice per question can we inject EJB from a war outside the EJB ear  ?
>
>
> On Thu, Jan 29, 2009 at 1:06 AM, Oddward <su...@web.de> wrote:
>
>>
>> 1. yes, the ear is running when i get the error
>> 2. in ${geronimo.home}/var/log/geronimo.log i get the following:
>>
>> [OpenEJB] Auto-deploying ejb MpeMessageDispatcher:
>> EjbDeployment(deployment-id=myAdEJB.jar/MpeMessageDispatcher)
>> ...
>> [startup] Jndi(name=MpeMessageDispatcherRemote) -->
>> Ejb(deployment-id=myAdEJB.jar/MpeMessageDispatcher)
>> ...
>> [startup] Created Ejb(deployment-id=myAdEJB.jar/MpeMessageDispatcher,
>> ejb-name=MpeMessageDispatcher, container=Default Stateless Container)
>>
>> i tried
>> Webserviceclass:
>>        @EJB(name="MpeMessageDispatcherRemote")
>>        protected MpeMessageDispatcherInterface mpe;
>>
>> with no success
>>
>> thx
>>
>>
>> djencks wrote:
>> >
>> > Is the ear that contains the ejb running when you get this error?
>> >
>> > When an ejb app starts, openejb prints the global jndi names it binds
>> > the ejbs under in ${geronimo.home}/var/log/geronimo.log.  Can you look
>> > and see what name your ejb is actually bound under?
>> >
>> > thanks
>> > david jencks
>> >
>> > On Jan 21, 2009, at 11:23 AM, Oddward wrote:
>> >
>> >>
>> >> Hello,
>> >>
>> >> i have a Webservice that needs access an EJB inside an EAR. Im using
>> >> geronimo 2.1 with tomcat. I followed these instructions
>> >>
>> http://cwiki.apache.org/GMOxDOC21/referring-to-an-ejb-from-outside-its-ear.html
>> >> with no result. I think its for EJBs not Servlets.
>> >>
>> >> here some code snipits:
>> >>
>> >>
>> >> Webserviceclass:
>> >>      @EJB(name="dispatcher")
>> >>      protected MpeMessageDispatcherInterface mpe;
>> >> Web.xml:
>> >>   <dep:environment>
>> >>        <dep:moduleId>
>> >>            <dep:groupId>com.webservice.app</dep:groupId>
>> >>            <dep:artifactId>appwebservice</dep:artifactId>
>> >>            <dep:version>1.0</dep:version>
>> >>            <dep:type>car</dep:type>
>> >>        </dep:moduleId>
>> >>         <sys:dependencies>
>> >>            <sys:dependency>
>> >>                <sys:groupId>myadear</sys:groupId>
>> >>                <sys:artifactId>myad-ear</sys:artifactId>
>> >>                <sys:version>1.0</sys:version>
>> >>              <sys:type>car</sys:type>
>> >>            </sys:dependency>
>> >>    </sys:dependencies>
>> >>    </dep:environment>
>> >>    <web:context-root>/IPhoneAppWS</web:context-root>
>> >>    <name:ejb-ref>
>> >>      <name:ref-name>dispatcher</name:ref-name>
>> >>      <name:pattern>
>> >>              <name:groupId>my-ear</name:groupId>
>> >>              <name:artifactId>myear</name:artifactId>
>> >>              <name:version>1.0</name:version>
>> >>              <name:name>MpeMessageDispatcher</name:name>
>> >>      </name:pattern>
>> >>    </name:ejb-ref>
>> >> </web:web-app>
>> >>
>> >> EJBinterface:
>> >> @Remote
>> >> public interface MpeMessageDispatcherInterface {
>> >>
>> >> EJB:
>> >> @Stateless(name="MpeMessageDispatcher")
>> >> public class MpeMessageDispatcher implements
>> >> MpeMessageDispatcherInterface {
>> >>
>> >> javax.xml.ws.WebServiceException: Service resource injection failed
>> >> ....
>> >> Caused by: java.lang.InstantiationException: Some objects to be
>> >> injected
>> >> were not found in jndi: [javax.naming.NameNotFoundException: Name
>> >> "java:openejb/Deployment/myear/MpeMessageDispatcher/
>> >> myear.mpe.MpeMessageDispatcherInterface"
>> >> not found.]
>> >>      at
>> >> org.apache.geronimo.j2ee.annotation.Holder.newInstance(Holder.java:
>> >> 171)
>> >>      at
>> >> org
>> >> .apache
>> >> .geronimo
>> >> .jaxws
>> >> .annotations.AnnotationHolder.newInstance(AnnotationHolder.java:39)
>> >>      at
>> >> org.apache.geronimo.cxf.pojo.POJOEndpoint.<init>(POJOEndpoint.java:76)
>> >>      ... 65 more
>> >> inject
>> >>
>> >> thx
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/inject-EJB-in-Webapplication-tp21590354s134p21590354.html
>> >> Sent from the Apache Geronimo - Users mailing list archive at
>> >> Nabble.com.
>> >>
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/inject-EJB-in-Webapplication-tp21590354s134p21710008.html
>> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Shawn
>



-- 
viola

Re: inject EJB in Webapplication

Posted by Shawn Jiang <ge...@gmail.com>.
Thanks for your tips,  I finally get it work by removing the mappedName
parameter from the @EJB annotation.   It's strange.  Let me make it clearer:

1, deploy a ear package contain a session bean(deployed JNDI name
"CounterBeanRemote") implement a remote interface.

The EJB:
@Stateless
public class CounterBean implements CounterRemote, CounterLocal {


2, deploy a war package that contains a servlet using
@EJB(mappedName="CounterBeanRemote") to inject the EJB.

The servlet:
public class CallEJBServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
 @EJB
private CounterRemote counter;

....
}


3,  I don't have any mapping in any deployment plan.  It just worked.


On Wed, Apr 15, 2009 at 10:09 PM, Fredrik Jonson <fr...@myrealbox.com>wrote:

> Shawn Jiang wrote:
>
> >  I encounter the same problem. Here is my case.
> >  1, deploy a ear package contain a session bean(deployed JNDI name
> >  "CounterBeanRemote") implement a remote interface.
> >
> >  2, deploy a war package that contains a servlet using
> >  @EJB(mappedName="CounterBeanRemote") to inject the EJB.
>
> I'm not sure how this is applicable to remote ejb references but to
> get injection to work in G I've always had to declare a ejb-local-ref
> in web.xml:
>
>  <ejb-local-ref>
>    <ejb-ref-name>SomeBean</ejb-ref-name>
>    <ejb-ref-type>Session</ejb-ref-type>
>    <local>com.example.app.SomeBeanRemote</local>
>  </ejb-local-ref>
>
> ...or something like that. Did you do that in your project?
>
> Without the ejb-local-ref the injection wont happen, even if the bean
> is declared within the same application ear.
>
> --
> Fredrik Jonson
>
>


-- 
Shawn

Re: inject EJB in Webapplication

Posted by Fredrik Jonson <fr...@myrealbox.com>.
Shawn Jiang wrote:
 
>  I encounter the same problem. Here is my case.
>  1, deploy a ear package contain a session bean(deployed JNDI name
>  "CounterBeanRemote") implement a remote interface.
> 
>  2, deploy a war package that contains a servlet using
>  @EJB(mappedName="CounterBeanRemote") to inject the EJB.

I'm not sure how this is applicable to remote ejb references but to
get injection to work in G I've always had to declare a ejb-local-ref
in web.xml:

  <ejb-local-ref>
    <ejb-ref-name>SomeBean</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local>com.example.app.SomeBeanRemote</local>
  </ejb-local-ref>

...or something like that. Did you do that in your project?

Without the ejb-local-ref the injection wont happen, even if the bean
is declared within the same application ear.

-- 
Fredrik Jonson 


Re: inject EJB in Webapplication

Posted by Shawn Jiang <ge...@gmail.com>.
I encounter the same problem. Here is my case.
1, deploy a ear package contain a session bean(deployed JNDI name
"CounterBeanRemote") implement a remote interface.

2, deploy a war package that contains a servlet using
@EJB(mappedName="CounterBeanRemote") to inject the EJB.



When I access the servlet, I get:

Exception: Some objects to be injected were not found in jndi:
[javax.naming.NameNotFoundException: Name
"java:openejb/Deployment/CounterBeanRemote/org.test.CounterRemote" not
found.]
	org.apache.geronimo.j2ee.annotation.Holder.newInstance(Holder.java:171)


Any advice per question can we inject EJB from a war outside the EJB ear  ?


On Thu, Jan 29, 2009 at 1:06 AM, Oddward <su...@web.de> wrote:

>
> 1. yes, the ear is running when i get the error
> 2. in ${geronimo.home}/var/log/geronimo.log i get the following:
>
> [OpenEJB] Auto-deploying ejb MpeMessageDispatcher:
> EjbDeployment(deployment-id=myAdEJB.jar/MpeMessageDispatcher)
> ...
> [startup] Jndi(name=MpeMessageDispatcherRemote) -->
> Ejb(deployment-id=myAdEJB.jar/MpeMessageDispatcher)
> ...
> [startup] Created Ejb(deployment-id=myAdEJB.jar/MpeMessageDispatcher,
> ejb-name=MpeMessageDispatcher, container=Default Stateless Container)
>
> i tried
> Webserviceclass:
>        @EJB(name="MpeMessageDispatcherRemote")
>        protected MpeMessageDispatcherInterface mpe;
>
> with no success
>
> thx
>
>
> djencks wrote:
> >
> > Is the ear that contains the ejb running when you get this error?
> >
> > When an ejb app starts, openejb prints the global jndi names it binds
> > the ejbs under in ${geronimo.home}/var/log/geronimo.log.  Can you look
> > and see what name your ejb is actually bound under?
> >
> > thanks
> > david jencks
> >
> > On Jan 21, 2009, at 11:23 AM, Oddward wrote:
> >
> >>
> >> Hello,
> >>
> >> i have a Webservice that needs access an EJB inside an EAR. Im using
> >> geronimo 2.1 with tomcat. I followed these instructions
> >>
> http://cwiki.apache.org/GMOxDOC21/referring-to-an-ejb-from-outside-its-ear.html
> >> with no result. I think its for EJBs not Servlets.
> >>
> >> here some code snipits:
> >>
> >>
> >> Webserviceclass:
> >>      @EJB(name="dispatcher")
> >>      protected MpeMessageDispatcherInterface mpe;
> >> Web.xml:
> >>   <dep:environment>
> >>        <dep:moduleId>
> >>            <dep:groupId>com.webservice.app</dep:groupId>
> >>            <dep:artifactId>appwebservice</dep:artifactId>
> >>            <dep:version>1.0</dep:version>
> >>            <dep:type>car</dep:type>
> >>        </dep:moduleId>
> >>         <sys:dependencies>
> >>            <sys:dependency>
> >>                <sys:groupId>myadear</sys:groupId>
> >>                <sys:artifactId>myad-ear</sys:artifactId>
> >>                <sys:version>1.0</sys:version>
> >>              <sys:type>car</sys:type>
> >>            </sys:dependency>
> >>    </sys:dependencies>
> >>    </dep:environment>
> >>    <web:context-root>/IPhoneAppWS</web:context-root>
> >>    <name:ejb-ref>
> >>      <name:ref-name>dispatcher</name:ref-name>
> >>      <name:pattern>
> >>              <name:groupId>my-ear</name:groupId>
> >>              <name:artifactId>myear</name:artifactId>
> >>              <name:version>1.0</name:version>
> >>              <name:name>MpeMessageDispatcher</name:name>
> >>      </name:pattern>
> >>    </name:ejb-ref>
> >> </web:web-app>
> >>
> >> EJBinterface:
> >> @Remote
> >> public interface MpeMessageDispatcherInterface {
> >>
> >> EJB:
> >> @Stateless(name="MpeMessageDispatcher")
> >> public class MpeMessageDispatcher implements
> >> MpeMessageDispatcherInterface {
> >>
> >> javax.xml.ws.WebServiceException: Service resource injection failed
> >> ....
> >> Caused by: java.lang.InstantiationException: Some objects to be
> >> injected
> >> were not found in jndi: [javax.naming.NameNotFoundException: Name
> >> "java:openejb/Deployment/myear/MpeMessageDispatcher/
> >> myear.mpe.MpeMessageDispatcherInterface"
> >> not found.]
> >>      at
> >> org.apache.geronimo.j2ee.annotation.Holder.newInstance(Holder.java:
> >> 171)
> >>      at
> >> org
> >> .apache
> >> .geronimo
> >> .jaxws
> >> .annotations.AnnotationHolder.newInstance(AnnotationHolder.java:39)
> >>      at
> >> org.apache.geronimo.cxf.pojo.POJOEndpoint.<init>(POJOEndpoint.java:76)
> >>      ... 65 more
> >> inject
> >>
> >> thx
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/inject-EJB-in-Webapplication-tp21590354s134p21590354.html
> >> Sent from the Apache Geronimo - Users mailing list archive at
> >> Nabble.com.
> >>
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/inject-EJB-in-Webapplication-tp21590354s134p21710008.html
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>
>


-- 
Shawn

Re: inject EJB in Webapplication

Posted by Oddward <su...@web.de>.
1. yes, the ear is running when i get the error
2. in ${geronimo.home}/var/log/geronimo.log i get the following:

[OpenEJB] Auto-deploying ejb MpeMessageDispatcher:
EjbDeployment(deployment-id=myAdEJB.jar/MpeMessageDispatcher)
...
[startup] Jndi(name=MpeMessageDispatcherRemote) -->
Ejb(deployment-id=myAdEJB.jar/MpeMessageDispatcher)
...
[startup] Created Ejb(deployment-id=myAdEJB.jar/MpeMessageDispatcher,
ejb-name=MpeMessageDispatcher, container=Default Stateless Container)

i tried
Webserviceclass:
	@EJB(name="MpeMessageDispatcherRemote")
	protected MpeMessageDispatcherInterface mpe;

with no success

thx


djencks wrote:
> 
> Is the ear that contains the ejb running when you get this error?
> 
> When an ejb app starts, openejb prints the global jndi names it binds  
> the ejbs under in ${geronimo.home}/var/log/geronimo.log.  Can you look  
> and see what name your ejb is actually bound under?
> 
> thanks
> david jencks
> 
> On Jan 21, 2009, at 11:23 AM, Oddward wrote:
> 
>>
>> Hello,
>>
>> i have a Webservice that needs access an EJB inside an EAR. Im using
>> geronimo 2.1 with tomcat. I followed these instructions
>> http://cwiki.apache.org/GMOxDOC21/referring-to-an-ejb-from-outside-its-ear.html
>> with no result. I think its for EJBs not Servlets.
>>
>> here some code snipits:
>>
>>
>> Webserviceclass:
>> 	@EJB(name="dispatcher")
>> 	protected MpeMessageDispatcherInterface mpe;
>> Web.xml:
>>   <dep:environment>
>>        <dep:moduleId>
>>            <dep:groupId>com.webservice.app</dep:groupId>
>>            <dep:artifactId>appwebservice</dep:artifactId>
>>            <dep:version>1.0</dep:version>
>>            <dep:type>car</dep:type>
>>        </dep:moduleId>
>>         <sys:dependencies>
>>            <sys:dependency>
>>                <sys:groupId>myadear</sys:groupId>
>>                <sys:artifactId>myad-ear</sys:artifactId>
>>                <sys:version>1.0</sys:version>
>>            	<sys:type>car</sys:type>
>>            </sys:dependency>
>>    </sys:dependencies>
>>    </dep:environment>
>>    <web:context-root>/IPhoneAppWS</web:context-root>
>>    <name:ejb-ref>
>>    	<name:ref-name>dispatcher</name:ref-name>
>>    	<name:pattern>
>>    		<name:groupId>my-ear</name:groupId>
>> 	    	<name:artifactId>myear</name:artifactId>
>> 	    	<name:version>1.0</name:version>
>> 	    	<name:name>MpeMessageDispatcher</name:name>
>>    	</name:pattern>
>>    </name:ejb-ref>
>> </web:web-app>
>>
>> EJBinterface:
>> @Remote
>> public interface MpeMessageDispatcherInterface {
>>
>> EJB:
>> @Stateless(name="MpeMessageDispatcher")
>> public class MpeMessageDispatcher implements  
>> MpeMessageDispatcherInterface {
>>
>> javax.xml.ws.WebServiceException: Service resource injection failed
>> ....
>> Caused by: java.lang.InstantiationException: Some objects to be  
>> injected
>> were not found in jndi: [javax.naming.NameNotFoundException: Name
>> "java:openejb/Deployment/myear/MpeMessageDispatcher/ 
>> myear.mpe.MpeMessageDispatcherInterface"
>> not found.]
>> 	at  
>> org.apache.geronimo.j2ee.annotation.Holder.newInstance(Holder.java: 
>> 171)
>> 	at
>> org 
>> .apache 
>> .geronimo 
>> .jaxws 
>> .annotations.AnnotationHolder.newInstance(AnnotationHolder.java:39)
>> 	at  
>> org.apache.geronimo.cxf.pojo.POJOEndpoint.<init>(POJOEndpoint.java:76)
>> 	... 65 more
>> inject
>>
>> thx
>>
>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/inject-EJB-in-Webapplication-tp21590354s134p21590354.html
>> Sent from the Apache Geronimo - Users mailing list archive at  
>> Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/inject-EJB-in-Webapplication-tp21590354s134p21710008.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: inject EJB in Webapplication

Posted by David Jencks <da...@yahoo.com>.
Is the ear that contains the ejb running when you get this error?

When an ejb app starts, openejb prints the global jndi names it binds  
the ejbs under in ${geronimo.home}/var/log/geronimo.log.  Can you look  
and see what name your ejb is actually bound under?

thanks
david jencks

On Jan 21, 2009, at 11:23 AM, Oddward wrote:

>
> Hello,
>
> i have a Webservice that needs access an EJB inside an EAR. Im using
> geronimo 2.1 with tomcat. I followed these instructions
> http://cwiki.apache.org/GMOxDOC21/referring-to-an-ejb-from-outside-its-ear.html
> with no result. I think its for EJBs not Servlets.
>
> here some code snipits:
>
>
> Webserviceclass:
> 	@EJB(name="dispatcher")
> 	protected MpeMessageDispatcherInterface mpe;
> Web.xml:
>   <dep:environment>
>        <dep:moduleId>
>            <dep:groupId>com.webservice.app</dep:groupId>
>            <dep:artifactId>appwebservice</dep:artifactId>
>            <dep:version>1.0</dep:version>
>            <dep:type>car</dep:type>
>        </dep:moduleId>
>         <sys:dependencies>
>            <sys:dependency>
>                <sys:groupId>myadear</sys:groupId>
>                <sys:artifactId>myad-ear</sys:artifactId>
>                <sys:version>1.0</sys:version>
>            	<sys:type>car</sys:type>
>            </sys:dependency>
>    </sys:dependencies>
>    </dep:environment>
>    <web:context-root>/IPhoneAppWS</web:context-root>
>    <name:ejb-ref>
>    	<name:ref-name>dispatcher</name:ref-name>
>    	<name:pattern>
>    		<name:groupId>my-ear</name:groupId>
> 	    	<name:artifactId>myear</name:artifactId>
> 	    	<name:version>1.0</name:version>
> 	    	<name:name>MpeMessageDispatcher</name:name>
>    	</name:pattern>
>    </name:ejb-ref>
> </web:web-app>
>
> EJBinterface:
> @Remote
> public interface MpeMessageDispatcherInterface {
>
> EJB:
> @Stateless(name="MpeMessageDispatcher")
> public class MpeMessageDispatcher implements  
> MpeMessageDispatcherInterface {
>
> javax.xml.ws.WebServiceException: Service resource injection failed
> ....
> Caused by: java.lang.InstantiationException: Some objects to be  
> injected
> were not found in jndi: [javax.naming.NameNotFoundException: Name
> "java:openejb/Deployment/myear/MpeMessageDispatcher/ 
> myear.mpe.MpeMessageDispatcherInterface"
> not found.]
> 	at  
> org.apache.geronimo.j2ee.annotation.Holder.newInstance(Holder.java: 
> 171)
> 	at
> org 
> .apache 
> .geronimo 
> .jaxws 
> .annotations.AnnotationHolder.newInstance(AnnotationHolder.java:39)
> 	at  
> org.apache.geronimo.cxf.pojo.POJOEndpoint.<init>(POJOEndpoint.java:76)
> 	... 65 more
> inject
>
> thx
>
>
>
> -- 
> View this message in context: http://www.nabble.com/inject-EJB-in-Webapplication-tp21590354s134p21590354.html
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>