aspose file tools
The moose likes Web Services and the fly likes Accessing EJBs from an Axis WebService Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "Accessing EJBs from an Axis WebService" Watch "Accessing EJBs from an Axis WebService" New topic
Author

Accessing EJBs from an Axis WebService

Henrique Ordine
Ranch Hand

Joined: Sep 03, 2004
Posts: 127
Hi everyone,

I've created a webservice using Axis and I'd like to access an EJB which is in the same EAR as my webservice class.
I've deployed this EAR on JBoss 5.

My EJB:
@Stateless (name="AutorizaAcessoService", mappedName="ejb/AutorizaAcessoService")
public class AutorizaAcessoService implements IAutorizaAcessoService {
...
}

In my WebService class (which is in my war module) I try:
InitialContext context = new InitialContext();
NamingContext nc = (NamingContext) context.lookup("java:comp/env");
IAutorizaAcessoService aaService = (IAutorizaAcessoService)nc.lookup("ejb/AutorizaAcessoService");

There is a context for "java:comp/env" but at the last line I get a
javax.naming.NameNotFoundException: ejb not bound



My web.xml looks like:
<ejb-local-ref>
<ejb-ref-name>AutorizaAcessoService</ejb-ref-name>
<local>br.gov.cgu.ativa.service.autorizaracessosistema.IAutorizaAcessoService</local>
<mapped-name>ejb/AutorizaAcessoService</mapped-name>
</ejb-local-ref>

And my JBoss-web.xml:
<ejb-local-ref>
<ejb-ref-name>AutorizaAcessoService</ejb-ref-name>
<local-jndi-name>ejb/AutorizaAcessoService</local-jndi-name>
</ejb-local-ref>

Could anyone please help me find this EJB?


J2EE Architect/Developer
Henrique Ordine
Ranch Hand

Joined: Sep 03, 2004
Posts: 127
Never mind, got it.
I had to add my EAR's name to JNDI.
context.lookup("ativa-ear/AutorizaAcessoService/remote");

Just for the record.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Accessing EJBs from an Axis WebService
 
Similar Threads
How to lookup an EJB in Servlets?
linking webapp with ejb in ear
NameNotFoundException in EJB? could anyone tell me?
Lookup problem for local beans on oc4j
Referencing EJBs in a JAR file from a WAR