Thursday, August 07, 2008

"weblogic.rjvm.PeerGoneException: ; nested exception is: weblogic.utils.NestedException: java.lang.NoClassDefFoundError: com/bea/xml/XmlException"

I was trying to create a connection with datasource lying in weblogic 9.2 from Oracle Jdeveloper Studio Version 10.1.3.3.

To create a application connection and integration connection with Oracle Jdeveloper we have to copy the "weblogic.jar" file from the "c:\bea\weblogic92\server\lib" folder to
Oracle Jdeveloper "D:\JDevstudio10133\jdk\jre\lib\ext" folder.
This setup will work for creating application connection and integration connection with oracle Jdeveloper. But when i run a java client which calls the datasource it is failing and throwing following error message.


"weblogic.rjvm.PeerGoneException: ; nested exception is:
weblogic.utils.NestedException: java.lang.NoClassDefFoundError: com/bea/xml/XmlException
",

I dropped all the below jar files into the "D:\JDevstudio10133\jdk\jre\lib\ext" location and added these jar file into the project libraries.
Then i tried to run the java client and it worked. The java code is pasted below.

ojdbc14.jar
xbean.jar
xmlx.jar
xqrl.jar
wlxbean.jar
weblogic.jar

public class JavaClient {
public JavaClient()
{
}

public void getDataSourceConnection()
{
Context ctx = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
DataSource ds = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://hostname:9700");

try
{
ctx = new InitialContext(ht);
ds = (javax.sql.DataSource) ctx.lookup ("jdbc/BPELServerDataSource");
conn = ds.getConnection();

stmt = conn.createStatement();
stmt.execute("select * from domain");
rs = stmt.getResultSet();

while(rs.next())
{
System.out.println("The value of the domain id column is ==>"+rs.getString(1));
}
}
catch (Exception e)
{
System.out.println("Exception is: " + e.getMessage());
e.printStackTrace();
}
finally
{
try
{
ctx.close();
if (rs != null) rs.close();
if (stmt != null) stmt.close();
if (conn != null) conn.close();
} catch (Exception e)
{
System.out.println("Exception ==>"+e);
}
}
}

public static void main(String[] args) {
JavaClient jc = new JavaClient();
jc.getDataSourceConnection();
}
}

Please reply with your comment, if you are facing any issues.

3 comments:

  1. Anonymous8:17 PM

    This was very helpful. I had the same issue and was resolved with your resolution.

    Thanks!!

    ReplyDelete
  2. Anonymous1:34 PM

    Many thanks!

    ReplyDelete
  3. Anonymous2:12 PM

    Respect and I have a neat proposal: Who Repairs House Foundations exterior home renovation

    ReplyDelete