• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1888
  • Last Modified:

Invoking EJB hosted in weblogic from silverstream


i have a code like this. I am trying to invoke an EJB that is hosted in a weblogic server. The method given below is on my client java program. if i run from my eclipse IDE it runs perfectly. But the same code when run from SilverStream application server (converted this code to a servlet) there it doesnt run. The execution stops at the line "return new InitialContext(properties);". The initialcontext is not getting created. has any one come across similar problem? how to solve this?

private Context getInitialContext() throws Exception {
    String url = "t3://ip-qdev01:26040";
    String user = null;
    String password = null;
    Properties properties = null;
    try {
      properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      properties.put(Context.PROVIDER_URL, url);
      if (user != null) {
        properties.put(Context.SECURITY_PRINCIPAL, user);
        properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
      //InitialContext sample = new InitialContext();
      //System.out.println("sample ------->  " + sample.getEnvironment());
     //above 3 lines for test purpose
      return new InitialContext(properties);
    catch(Exception e) {
      System.out.println("PaymentInterfaceTestClient1 : getInitialContext() : 6");
      log("Unable to connect to WebLogic server at " + url);
      log("Please make sure that the server is running.");
      throw e;
  • 5
  • 5
2 Solutions
Do you get any exception or does the execution simply "hangs"?
Can you run the lookup code from the machine running the Silverstream server as a simple java main program?

msk_satheeshAuthor Commented:
I tried running from my desktop with the right jars included (wlclient.jar). There it works. From SilverStream the execution simply 'hangs'. No exception thrown. I tried by including the wlclient.jar in the war file as well as setting the property to make use of the weblogic classes from the jar that included. See the below code where i have additionally set the Context.URL_PKG_PREFIXES property.

      properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      properties.put(Context.PROVIDER_URL, url);
Yes, you need the client Jar in the War used in the SilverStream. But, did you run the test code as a simple java main program on the silverstream machine?

Why am i asking this?, well, im trying to help you isolate the problem (code, environment setting, communication problems etc).
So, a good first step to close on the bugger is to take your code and run it on the machine running the Silverstream, as a java main.

Managing Security & Risk at the Speed of Business

Gartner Research VP, Neil McDonald & AlgoSec CTO, Prof. Avishai Wool, discuss the business-driven approach to automated security policy management, its benefits and how to align security policy management with business processes to address today's security challenges.

msk_satheeshAuthor Commented:
I just tried it. it looks more like a java version problem now.

I tried the following scenario:

1. Use Jdk 1.4 (java version "1.4.1_02") to compile and run with both success
2. Use Jdk1.3 (java version "1.3.0_02") to compile and run with compile success and run failure
3. Use the java version of silverstream (java version "1.3.1_07"). (both fail)

For cases 2 and 3. the run time error is:

-- Initializing bean access....
PaymentInterfaceTestClient1 : getInitialContext() : 1
PaymentInterfaceTestClient1 : getInitialContext() : 2
PaymentInterfaceTestClient1 : getInitialContext() : 3
PaymentInterfaceTestClient1 : getInitialContext() : 4
PaymentInterfaceTestClient1 : getInitialContext() : 5   {java.naming.provider.url=t3://ip-qdev01:26040, java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory}
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/corba/se/connection/ORBSocketFactory
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:488)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:106)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:243)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:51)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:190)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:183)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:281)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:115)
        at weblogic.corba.j2ee.naming.ORBHelper.<clinit>(ORBHelper.java:111)
        at weblogic.corba.client.ClientORBInitializer.initialize(ClientORBInitializer.java:84)
        at weblogic.jndi.WLInitialContextFactory.<init>(WLInitialContextFactory.java:29)
        at java.lang.Class.newInstance0(Native Method)
        at java.lang.Class.newInstance(Class.java:232)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:647)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:241)
        at javax.naming.InitialContext.init(InitialContext.java:217)
        at javax.naming.InitialContext.<init>(InitialContext.java:193)
        at be.belgacom.mobile.wlan.lmpg.PaymentInterfaceTestClient1.getInitialContext(PaymentInterfaceTestClient1.java:91)
        at be.belgacom.mobile.wlan.lmpg.PaymentInterfaceTestClient1.initialize(PaymentInterfaceTestClient1.java:36)
        at be.belgacom.mobile.wlan.lmpg.PaymentInterfaceTestClient1.<init>(PaymentInterfaceTestClient1.java:24)
        at be.belgacom.mobile.wlan.lmpg.PaymentInterfaceTestClient1.main(PaymentInterfaceTestClient1.java:451)
You got it then. I guess you have to use JDK 1.4 to use the wlclient. Or (perhaps) alternatively try an older version of the wlclient.

I also have same problem as like you, only solution for this you need to run the EJB's from Weblogic Console using only JDK 1.3 Version, then it will be fine, because we also initially tries with 1.4 then it got failed, then we tried with JDK 1.3, debugs and runs fine. So in your case you try to use only JDK 1.3 rather than 1.4.

i hope it may help you
best of luck

msk_satheeshAuthor Commented:

Yes when it tried with the weblogic.jar from weblogic 7.0 (which runs on jdk1.3) it worked. Though i ran the program as a standalone. With silverstream i have not run it yet. some classpath problems are there.

Finally it is not going to solve my problem because i have to run two applications, one of them in silverstream 4.0 (runs on jre 1.3) and weblogic 8.1 that runs on jre1.4. The weblogic.jar from old version of weblogic will not be supported officially(for my project).

Now atleast i know what the problem is! Thanks to you guys!
Say, how bout some points :) ?
msk_satheeshAuthor Commented:
here you go yuvalg!
msk_satheeshAuthor Commented:
Am back with another problem!
Now it is accessing EJB from one Silverstream server to another! Ran into some problems. I have a piece of code which is:

Class NSUPProxy.java has method:

private NsupProxy(String providerURL) throws NsupLocatorException {
        this.providerURL = providerURL;
        this.nsupRemote = NsupLocator.getInstance(providerURL).getNsupService();

Class NsupLocator.java has method:

public UserProfilesReaderRemoteHome getHome() throws NsupLocatorException {
        try {
            Hashtable env = new Hashtable();
            env.put(Context.PROVIDER_URL, providerURL);

            InitialContext initial = new InitialContext(env);

            Object objRef = initial.lookup("ejb/UserProfilesReader");
            UserProfilesReaderRemoteHome userProfilesReaderRemoteHome =

            return userProfilesReaderRemoteHome;
        catch (ClassCastException e) {
            throw new NsupLocatorException(e.getMessage(), e);
        catch (NamingException e) {
            throw new NsupLocatorException(e.getMessage(), e);

Now i get an exception like this below. But again the wonderful thing is the code runs from my desktop (eclipse IDE) but not from silverstream. So my nsup server is up and running and the ejb name is alright. But from silverstream ??? :-((

javax.naming.NameNotFoundException.  Root exception is org.omg.CosNaming.NamingContextPackage.NotFound
        at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:29)
        at org.omg.CosNaming._NamingContextExtStub.resolve(_NamingContextExtStub.java:241)
        at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:363)
        at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:412)
        at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:390)
        at javax.naming.InitialContext.lookup(InitialContext.java:345)
        at be.belgacom.mobile.ns.userprofile.client.NsupLocator.getHome(NsupLocator.java:74)
        at be.belgacom.mobile.ns.userprofile.client.NsupLocator.getNsupService(NsupLocator.java:113)
        at be.belgacom.mobile.ns.userprofile.client.NsupLocator.getNsupService(NsupLocator.java:57)
        at be.belgacom.mobile.ns.userprofile.client.NsupProxy.<init>(NsupProxy.java:58)
        at be.belgacom.mobile.ns.userprofile.client.NsupProxy.getInstance(NsupProxy.java:45)
        at be.belgacom.mobile.wlan.nsup.ServletNSUPTester.checkMSISDN(ServletNSUPTester.java:115)
        at be.belgacom.mobile.wlan.nsup.ServletNSUPTester.doPost(ServletNSUPTester.java:63)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at com.sssw.srv.busobj.AgoFilterChain.doServlet(AgoFilterChain.java:396)
        at com.sssw.srv.busobj.AgoFilterChain.doFilter(AgoFilterChain.java:182)
        at com.sssw.srv.resources.AgWarResource.service(AgWarResource.java:629)
        at com.sssw.srv.resources.AgWarURLResource.perform(AgWarURLResource.java:115)
        at com.sssw.srv.http.httpd.perform(httpd.java:5631)
        at com.sssw.srv.http.Client.processRequest(Client.java:902)
        at com.sssw.srv.http.Client.loop(Client.java:1268)
        at com.sssw.srv.http.Client.runConnection(Client.java:1484)
        at com.sssw.srv.http.Client.run(Client.java:1432)
        at java.lang.Thread.run(Thread.java:479)
Are you sure that what you are trying to access is deployed correctly, can you call it fom its own server machine?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Managing Security Policy in a Changing Environment

The enterprise network environment is evolving rapidly as companies extend their physical data centers to embrace cloud computing and software-defined networking. This new reality means that the challenge of managing the security policy is much more dynamic and complex.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now