user2955469
user2955469

Reputation: 1

Remote EJB 3.0 lookup (STS 3.4.0, Weblogic 10.3.5)

I have a Spring MVC 3.1.1 application which need to look up a remote EJB 3.0 deployed into Weblogic 10.3.5.

The Spring application run inside the local server VMware vFabric tc S.D.E. 2.9, also Weblogic is local and started by STS 3.4.0

I've tried so many different ways for the lookup, but the error message is:

Name [ABC] is not bound in this Context. Unable to find [ABC]

where ABC is different for each try.

Weblogic is installed and configured, I can see the EJB deployed inside the console and that's what I can see inside his JNDI's tree:

AdminServer+LoginBean#it+company+project+ejb+login+LoginBeanRemote

which every + is a tree node, and the name is LoginBean#it.company.project.ejb.login.LoginBeanRemote

Under AdminServer I can see also the subtree ejb.mgmt.MEJB, I dunno if that's can be an useful notice.

As you can see I want to make that EJB for login scope inside Spring Security 3.1.4.

That's a remote interface's branch:

@Remote
public interface LoginBeanRemote {
    public User loadUserByUsername(final String username);
}

That's the class branch:

@Stateless(mappedName = "LoginBean")
public class LoginBean implements LoginBeanRemote {
   @Override
   public User loadUserByUsername(final String username) {
               final User user = new User();
               (...)
               return user;
   }
}

Now there isn't ejb-jar.xml nor weblogic-ejb-jar.xml, but when I've used one or every configuration XML I've obtained the same message. Now I don't use the name tag inside @Stateless, but when I've used it I've obtained the same message.

That's the client branch:

public class UserLogin {
    public User loadUserByUsername(final String username) {
        final User user = new User();
        Context context = null;
        final Hashtable <String, String> webLogic = new Hashtable <String, String>();
        webLogic.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
        webLogic.put(Context.PROVIDER_URL, "[http://localhost:7001]()"); //also used t3 and iiop
        //also used SECURITY_PRINCIPAL & SECURITY_CREDENTIALS
        try {
            context = new InitialContext();
            final LoginBeanRemote login = (LoginBeanRemote) context.lookup("LoginBean#it.postel.aos.ejb.login.LoginBeanRemote");
            (...)
        } catch (final NamingException ne) {
            (...)
        }
        (...)
        return user;
    }
}

Into production the spring application will be deployed into a different AS than the EJB module, even Weblogic 10.3.5, so I've used a remote EJB.

I've tested all inside STS.

I've referenced the EJB into the Spring application as an external JAR.

I've putted those files inside the lib folder into my domain's Weblogic server:
LoginEjb.jar, weblogic.jar and wlfullclient.jar,
but I've obtained the same error message also without those files (even I think I don't need to put weblogic.jar inside that).

I dunno if one XML configuration is required (ejb-jar.xml or weblogic-ejb-jar.xml), maybe when I've made those files I made some mistakes (now I haven't those files), but I've also read I can deploy an EJB without XMLs.

I've read some other questions on Stack Overflow but none of the suggestions provided a solution for me.

Upvotes: 0

Views: 3044

Answers (1)

eis
eis

Reputation: 53482

this is at least wrong:

    final Hashtable <String, String> webLogic = new Hashtable <String, String>();
    webLogic.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    webLogic.put(Context.PROVIDER_URL, "[http://localhost:7001]()"); //also used t3 and iiop
    try {
        context = new InitialContext();

if you only use new InitialContext() without parameters, you're doing local lookups, not remote. You need to init the context with the parameters you have, like this:

    final Hashtable <String, String> webLogic = new Hashtable <String, String>();
    webLogic.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    webLogic.put(Context.PROVIDER_URL, "http://localhost:7001"); //also used t3 and iiop
    try {
        context = new InitialContext(webLogic); // <--- note this

Upvotes: 1

Related Questions