views:

652

answers:

2

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"&gt;

    <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.

A: 

seems like your mapped-name in ejb-jar.xml "Orquestrator" may be overriding the mappedName=OrquestratorBean setting of the Bean. Have you tried ic.lookup for "Orquestrator" ?

Shreeni
@Shreeni Thanks for your reply. I changed the descriptor to "OrquestratorBean" (to comply with the naming used in the annotation), but it didn't change anything: I got the same runtime exception as before. I updated original post with this change.
XpiritO
A: 

Your EJB gets bound under the following JNDI name (when deployed as EJB module):

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

Note that I deployed your code (without the weblogic-ejb-jar.xml) as an EJB module, not as a shared library.

Pascal Thivent