NameNotFoundException when calling a EJB in Weblogic 10.3

Posted by XpiritO on Stack Overflow See other posts from Stack Overflow or by XpiritO
Published on 2010-04-13T11:16:16Z Indexed on 2010/04/13 19:53 UTC
Read the original article Hit count: 531

Filed under:
|
|
|

First of all, I'd like to underline that I've already read other posts in StackOverflow (example) with similar questions, but unfortunately I didn't manage to solve this problem with the answers I saw on those posts. I have no intention to repost a question that has already been answered, so if that's the case, I apologize and I'd be thankful to whom points out where the solution is posted.

Here is my question:

I'm trying to deploy an EJB in WebLogic 10.3.2. The purpose is to use a specific WorkManager to execute work produced in the scope of this component.

With this in mind, I've set up a WorkManager (named ResponseTimeReqClass-0) on my WebLogic configuration, using the web-based interface (Environment > Work Managers > New). Here is a screenshot:

http://img11.imageshack.us/img11/8607/screenshot0p.jpg

Here is my session bean definition and descriptors:

OrquestratorRemote.java

package orquestrator;

import javax.ejb.Remote;

@Remote
public interface OrquestratorRemote {

    public void initOrquestrator();

}

OrquestratorBean.java

package orquestrator;

import javax.ejb.Stateless;

import com.siemens.ecustoms.orchestration.eCustomsOrchestrator;

@Stateless(name = "OrquestratorBean", mappedName = "OrquestratorBean") 
public class OrquestratorBean implements OrquestratorRemote {

    public void initOrquestrator(){
        eCustomsOrchestrator orquestrator = new eCustomsOrchestrator();
        orquestrator.run();
    }

}

META-INF\ejb-jar.xml

<?xml version='1.0' encoding='UTF-8'?>
<ejb-jar xmlns='http://java.sun.com/xml/ns/javaee'
         xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
         metadata-complete='true'>

<enterprise-beans>
    <session>
        <ejb-name>OrquestradorEJB</ejb-name>
        <mapped-name>OrquestratorBean</mapped-name>
        <business-remote>orquestrator.OrquestratorRemote</business-remote>
        <ejb-class>orquestrator.OrquestratorBean</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
    </session>
</enterprise-beans>

<assembly-descriptor></assembly-descriptor>

</ejb-jar>

META-INF\weblogic-ejb-jar.xml

(I've placed work manager configuration in this file, as I've seen on a tutorial on the internet)

<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/90"
   xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.bea.com/ns/weblogic/90
   http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd">

    <weblogic-enterprise-bean>
        <ejb-name>OrquestratorBean</ejb-name> 
        <jndi-name>OrquestratorBean</jndi-name> 
        <dispatch-policy>ResponseTimeReqClass-0</dispatch-policy> 
    </weblogic-enterprise-bean>

</weblogic-ejb-jar>

I've compiled this into a JAR and deployed it on WebLogic, as a library shared by administrative server and all cluster nodes on my solution (it's in "Active" state).


As I've seen in several tutorials and examples, I'm using this code on my application, in order to call the bean:

InitialContext ic = null;
try {
    Hashtable<String,String> env = new Hashtable<String,String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL, "t3://localhost:7001");
    ic = new InitialContext(env);
}
catch(Exception e) {
    System.out.println("\n\t Didn't get InitialContext: "+e);
}
//
try {
    Object obj = ic.lookup("OrquestratorBean");
    OrquestratorRemote remote =(OrquestratorRemote)obj;
    System.out.println("\n\n\t++ Remote => "+ remote.getClass());
    System.out.println("\n\n\t++ initOrquestrator()");
    remote.initOrquestrator();
}
catch(Exception e) {
    System.out.println("\n\n\t WorkManager Exception => "+ e);
    e.printStackTrace();
}

Unfortunately, this don't work. It throws an exception on runtime, as follows:

WorkManager Exception => javax.naming.NameNotFoundException: Unable to resolve 'OrquestratorBean'. Resolved '' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'OrquestratorBean'. Resolved '']; remaining name 'OrquestratorBean'

After seeing this, I've even tried changing this line

Object obj = ic.lookup("OrquestratorBean");

to this:

Object obj = ic.lookup("OrquestratorBean#orquestrator.OrquestratorBean");

but the result was the same runtime exception.

Can anyone please help me detecting what am I doing wrong here? I'm having a bad time debugging this, as I don't know how to check out what may be causing this issue...

Thanks in advance for your patience and help.

© Stack Overflow or respective owner

Related posts about weblogic

Related posts about ejb