Solved

Invoking EJB hosted in weblogic from silverstream

Posted on 2004-08-20
11
1,868 Views
Last Modified: 2008-01-09
Hi,

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());
      //System.out.println(System.getProperties());
     //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;
    }
  }
0
Comment
Question by:msk_satheesh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 3

Expert Comment

by:yuvalg
ID: 11862847
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?

Yuval.
0
 

Author Comment

by:msk_satheesh
ID: 11868263
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.URL_PKG_PREFIXES,"weblogic.jndi.factories:weblogic.corba.j2ee.naming.url:weblogic.corba.j2ee.naming.url:weblogic.corba.client.naming");
      properties.put(Context.PROVIDER_URL, url);
0
 
LVL 3

Expert Comment

by:yuvalg
ID: 11878198
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.

Yuval.
0
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

 

Author Comment

by:msk_satheesh
ID: 11879398
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
java.naming.factory.object
java.naming.factory.state
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)
$
0
 
LVL 3

Accepted Solution

by:
yuvalg earned 400 total points
ID: 11879812
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.
0
 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 100 total points
ID: 11889566
Hi,

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

R.K
0
 

Author Comment

by:msk_satheesh
ID: 11889963
Hi,

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!
0
 
LVL 3

Expert Comment

by:yuvalg
ID: 11890687
Say, how bout some points :) ?
0
 

Author Comment

by:msk_satheesh
ID: 11894270
here you go yuvalg!
0
 

Author Comment

by:msk_satheesh
ID: 11894372
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.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
            env.put(Context.PROVIDER_URL, providerURL);

            InitialContext initial = new InitialContext(env);

            Object objRef = initial.lookup("ejb/UserProfilesReader");
            UserProfilesReaderRemoteHome userProfilesReaderRemoteHome =
                (UserProfilesReaderRemoteHome)PortableRemoteObject.narrow(objRef,
                    UserProfilesReaderRemoteHome.class);

            return userProfilesReaderRemoteHome;
        }
        catch (ClassCastException e) {
            throw new NsupLocatorException(e.getMessage(), e);
        }
        catch (NamingException e) {
              e.printStackTrace();
            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)
0
 
LVL 3

Expert Comment

by:yuvalg
ID: 11900008
Are you sure that what you are trying to access is deployed correctly, can you call it fom its own server machine?
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question