I'm trying to
test if my DataSource is well configured, and I'm running this program:
**** CODE BEGIN *****
<pre>import javax.naming.*;
import java.util.*;
public class DSClient {
static
String url = "iiop://xxx.xxx.xxx.xxx:900";
public static Context getInitialContext() throws NamingException {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory");
p.put(Context.PROVIDER_URL, url);
return new InitialContext(p);
}
public static void main(String[] args) {
Context ctx = null;
javax.sql.DataSource ds = null;
java.sql.Connection conn = null;
try {
ctx = getInitialContext();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("end getInitialContext");
if (ctx != null) {
System.out.println(ctx.toString());
}
try {
ds = (javax.sql.DataSource) ctx.lookup("jdbc/OracleDS");
System.out.println("DataSource Created!");
System.out.println(ds.toString());
} catch (Exception e) {
e.printStackTrace();
}
try {
conn = ds.getConnection(user, password);
System.out.println("Connection created");
System.out.println("conn = " + conn);
} catch (Exception e) {
e.printStackTrace();
}
}
}</pre>
***** CODE END *****
I'm entering the following line to the command line, under solaris:
***** COMMAND LINE BEGIN *****
<pre>/opt/WebSphere/AppServer/java/jre/bin/java -cp /opt/WebSphere/AppServer/lib/ejs.jar:/opt/WebSphere/AppServer/lib/ujc.jar:./imports.jar:/opt/WebSphere/AppServer/java/jre/lib/classes.zip:./Deployedjetaced_0.5b.jar:. DSClient</pre>
***** COMMAND LINE END *****
where imports.jar are some classes my
EJB need to import and Deployedjetaced_0.5b.jar are my EJB deployed.
I get the following exception:
***** EXCEPTION BEGIN *****
<pre>Exception in
thread "P=22987:O=0:CT" java.lang.NoClassDefFoundError: com/ibm/ejs/sm/beans/RepositoryObjectImpl
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass0(Compiled Code)
at java.lang.ClassLoader.defineClass(Compiled Code)
at java.security.SecureClassLoader.defineClass(Compiled Code)
at java.net.URLClassLoader.defineClass(Compiled Code)
at java.net.URLClassLoader.access$1(Compiled Code)
at java.net.URLClassLoader$1.run(Compiled Code)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessController.doPrivileged(Compiled Code)
at java.net.URLClassLoader.findClass(Compiled Code)
at java.lang.ClassLoader.loadClass(Compiled Code)
at sun.misc.Launcher$AppClassLoader.loadClass(Compiled Code)
at java.lang.ClassLoader.loadClass(Compiled Code)
at java.lang.ClassLoader.loadClassInternal(Compiled Code)
at com.ibm.ejs.sm.beans.DataSourceBean$Factory.getObjectInstance(DataSourceBean.java:963)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:310)
at com.ibm.ejs.ns.jndi.CNContextImpl.isReference(CNContextImpl.java:1303)
at com.ibm.ejs.ns.jndi.CNContextImpl.doLookup(CNContextImpl.java:801)
at com.ibm.ejs.ns.jndi.CNContextImpl.lookup(CNContextImpl.java:585)
at javax.naming.InitialContext.lookup(InitialContext.java:349)
at DSClient.main(DSClient.java:41)</pre>
***** EXCEPTION END *****
I have one datasource called "OracleDS" and I think it's well configured. If someone finds a mistake in the code or has some code to test DataSources please tell me so.
Thank you
Horaci Macias
[This message has been edited by Horaci Macias (edited November 13, 2001).]