Solved

Invoking EJB hosted in weblogic from silverstream

Posted on 2004-08-20
11
1,857 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
  • 5
  • 5
11 Comments
 
LVL 3

Expert Comment

by:yuvalg
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:msk_satheesh
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Say, how bout some points :) ?
0
 

Author Comment

by:msk_satheesh
Comment Utility
here you go yuvalg!
0
 

Author Comment

by:msk_satheesh
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now