-
Getting NamingException (10 messages)
- Posted by: Narasimha Murthy
- Posted on: April 07 2005 03:01 EDT
Hi All,
I am not able to get the initialcontext from websphere. I have the following environment.
Server: WAS v6.01
OS: Win2K
Client: Java StandAlone Application.
Here's the code snippet, what I am using: I would really appreciate any help in this regard.
Thanks in Advance.
---------------------------------
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
properties.put(Context.PROVIDER_URL, "iiop://localhost:9100");
try
{
InitialContext jndiContext = new InitialContext(properties);
System.out.println("Got context");
Object ejbHome = jndiContext.lookup("StringProcessor");
System.out.println("Got ejbHome");
.....
}
catch(Exception e) {
System.out.println(e.toString() + "\n" + e.getStackTrace());
}
Here's the console output:
Got context
javax.naming.NamingException: Failed to initialize the ORB [Root exception is java.lang.ClassCastException]Threaded Messages (10)
- Getting NamingException by satya katta on April 08 2005 14:41 EDT
- Getting NamingException by Narasimha Murthy on April 11 2005 02:52 EDT
-
Getting NamingException by Narasimha Murthy on April 11 2005 06:47 EDT
-
Getting NamingException by Nageswara Rao Kolisetty on April 19 2005 06:37 EDT
-
Getting NamingException by Narasimha Murthy on April 21 2005 11:58 EDT
- Getting NamingException by Venkata Pardhasaradhi Naraparaju on May 08 2005 02:16 EDT
-
It is working for me by Nageswara Rao Kolisetty on May 17 2005 06:25 EDT
- How to call MBean deployed in Weblogic from java client by Nageswara Rao Kolisetty on June 10 2005 04:52 EDT
-
Getting NamingException by Narasimha Murthy on April 21 2005 11:58 EDT
-
Getting NamingException by Nageswara Rao Kolisetty on April 19 2005 06:37 EDT
-
Getting NamingException by Narasimha Murthy on April 11 2005 06:47 EDT
- Getting NamingException by Narasimha Murthy on April 11 2005 02:52 EDT
- Please help its urgent by technical 2008 on May 01 2008 11:52 EDT
- Please help its urgent by technical 2008 on May 01 2008 12:09 EDT
-
Getting NamingException[ Go to top ]
- Posted by: satya katta
- Posted on: April 08 2005 14:41 EDT
- in response to Narasimha Murthy
I guess you must be trying to get this context from an simple java client. I used to get a similar error. In WSAD if you are trying to do this from a simple java project you will get this error. If you are writing a client for an J2EE applicatin (ear) then try creating a client project for the J2EE application that should solve your problem. -
Getting NamingException[ Go to top ]
- Posted by: Narasimha Murthy
- Posted on: April 11 2005 02:52 EDT
- in response to satya katta
Hello Satya,
You are right, I used a simple java client for this; but I tried the same in jsp also. There too, I am getting an initialization exception. What should be done for the ORB initialization? Any idea..
ThanksI guess you must be trying to get this context from an simple java client. I used to get a similar error. In WSAD if you are trying to do this from a simple java project you will get this error. If you are writing a client for an J2EE applicatin (ear) then try creating a client project for the J2EE application that should solve your problem.
-
Getting NamingException[ Go to top ]
- Posted by: Narasimha Murthy
- Posted on: April 11 2005 06:47 EDT
- in response to Narasimha Murthy
Problem is resolved. JDK version mismatch will give this exception.
Thanks.Hello Satya,You are right, I used a simple java client for this; but I tried the same in jsp also. There too, I am getting an initialization exception. What should be done for the ORB initialization? Any idea..Thanks
I guess you must be trying to get this context from an simple java client. I used to get a similar error. In WSAD if you are trying to do this from a simple java project you will get this error. If you are writing a client for an J2EE applicatin (ear) then try creating a client project for the J2EE application that should solve your problem.
-
Getting NamingException[ Go to top ]
- Posted by: Nageswara Rao Kolisetty
- Posted on: April 19 2005 06:37 EDT
- in response to Narasimha Murthy
Hi, I am also getting the same problem. What is that meaning of JDK Version problem. Can you pls tell me how I can resolve this.
Thanks
Nagesh -
Getting NamingException[ Go to top ]
- Posted by: Narasimha Murthy
- Posted on: April 21 2005 23:58 EDT
- in response to Nageswara Rao Kolisetty
Client JDK version should be the same as of the Websphere Server. -
Getting NamingException[ Go to top ]
- Posted by: Venkata Pardhasaradhi Naraparaju
- Posted on: May 08 2005 02:16 EDT
- in response to Narasimha Murthy
Hi,
I was also facing the same problem when looking up an EJB deployed on WebSphere v6 from standalone client JVM. I used IBM JDK that comes bundled with WebSphere installation for both the server and client. Could you please let me know how to resolve this.
The exception stacktrace is follows:
javax.naming.NamingException: Failed to initialize the ORB [Root exception is java.lang.ClassCastException] -
It is working for me[ Go to top ]
- Posted by: Nageswara Rao Kolisetty
- Posted on: May 17 2005 06:25 EDT
- in response to Nageswara Rao Kolisetty
Hi
Thanks for your help. After changed the java_home it is working for me. Now it is working for me.
Thanks
Nagesh -
How to call MBean deployed in Weblogic from java client[ Go to top ]
- Posted by: Nageswara Rao Kolisetty
- Posted on: June 10 2005 04:52 EDT
- in response to Nageswara Rao Kolisetty
Hi All,
My application is deployed in weblogic and I want to write the Java Client which is need to acces that MBean which is deployed in weblogic. Can you please help me out in this regard.
Thanks
Nagesh -
Please help its urgent[ Go to top ]
- Posted by: technical 2008
- Posted on: May 01 2008 11:52 EDT
- in response to Narasimha Murthy
hi im using a stand alone java application to access a jndi data source configured on websphere 6.1 im getting the following error : failed to initialize the ORB... most of the solutions i got suggest to change from sun jdk to ibm jdk.BUT BUT how do we do that and what are the steps to be followed. Im an amateur...Please help its urgent -
Please help its urgent[ Go to top ]
- Posted by: technical 2008
- Posted on: May 01 2008 12:09 EDT
- in response to Narasimha Murthy
the code im using is given below: //WebsphereJNDI.java import java.sql.*; import java.util.*; import javax.sql.*; import javax.naming.*; import javax.rmi.*; public class WebSphereJNDI { private String websphere_server; private String jndi_datasource; private String sql_query; WebSphereJNDI(String serverpath, String jndiname, String query) { websphere_server = serverpath; jndi_datasource = jndiname; sql_query = query; } public ResultSet get_data() throws Exception { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); env.put(Context.PROVIDER_URL, websphere_server); InitialContext ctx = new InitialContext(env); DataSource ds = (DataSource) ctx.lookup(jndi_datasource); Connection conn = ds.getConnection(); Statement stm = conn.createStatement(); ResultSet res = stm.executeQuery(sql_query); // moving cursor to first row res.next(); return res; } } // ResultSetTester.java import java.sql.*; import java.util.*; import javax.sql.*; import javax.naming.*; import javax.rmi.*; public class ResultSetTester { public static void main(String[] args) throws Exception { WebSphereJNDI test = new WebSphereJNDI( "http://hostname:port no.", "jdbc/mydatasource", "SELECT * FROM pubs.dbo.authors"); System.out.println(dump_data(test.get_data())); } public static String dump_data(java.sql.ResultSet rs) throws Exception { int rowCount = 0; String result = ""; result += ""; ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); // table header result += ""; for (int i = 0; i < columnCount; i++) { result += "<TH>" + rsmd.getColumnLabel(i + 1) + "</TH>"; } result += ""; // the data while (rs.next()) { rowCount++; result += ""; for (int i = 0; i < columnCount; i++) { result += "<TD>" + rs.getString(i + 1) + "</TD>"; } result += ""; } result += "
"; return result; } }