0

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user2955469
  • 1
  • 1
  • 1
  • Welcome to Stack Overflow. You might want to look into how to format code in your questions since there are a lot easier ways to do it (Less work for you). Please refer to the [help](http://stackoverflow.com/help) page for information. – Qben Nov 05 '13 at 09:58
  • @Qben: just a heads up: some people find that using code spans for names rather annoying (for example `Spring MVC 3.1.1` as opposed to Spring MVC 3.1.1) - some reviewers have been known to reject edits on that basis. :) – Qantas 94 Heavy Nov 05 '13 at 13:46
  • 1
    @Qantas94Heavy Oh, thanks for the hint! I will read up on what is the recommended way to highlight that kind of stuff. Thanks again. – Qben Nov 05 '13 at 13:49

1 Answers1

1

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
eis
  • 51,991
  • 13
  • 150
  • 199
  • Thank you eis, I forget to put the Hashtable object inside InitialContext. – user2955469 Nov 05 '13 at 14:12
  • But now, the problem is: webLogic.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); I think the problem is VMWare vFabric server configuration. – user2955469 Nov 05 '13 at 14:13
  • Sorry if I was a bit cryptic, but I'm at work... so the problem is the initial context factory. The Spring application run into STS using the VMWare vFabric server and has the wlfullclient.jar as external JAR. Do I need to put that JAR also into the server classpath? But the vFabric server stop if I try to do that. Do I need to put that JAR inside the Spring application, so not as external JAR? Thank you and best regards! – user2955469 Nov 05 '13 at 14:32
  • I've obtained a javax.naming.NoInitialContextException about weblogic.jndi.WLInitialContextFactory. I think that's because wlfullclient.jar is an external JAR for the Spring application (I haven't a lib folder inside it). There is also a pom.xml, so I dunno if I need to put that JAR as a new dependency or referencing it into the server as shared library (but I dunno how I can do that with vFabric). Thank's @eis !! – user2955469 Nov 05 '13 at 15:33
  • @user2955469 could you provide the full error message + stack trace? – eis Nov 05 '13 at 15:52