• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems with DataSources (NoClassDefFoundError: com/ibm/ejs/sm/beans/RepositoryOb...

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you need the jar file containing the com/ibm/ejs/sm/beans/RepositoryObjectImpl class in your client's classpath.
 
Horaci Macias
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It really looks like this, but I thought it had all jar necesary files in client's classpath, which are:
%WAS_HOME%\lib\ejs.jar
%WAS_HOME%\lib\ujc.jar
%JAVA_HOME%\lib\classes.zip;
do you know which jar do I need apart from the above �?
Thank you
Horaci Macias
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start with the basics. If you're running under any flavor of UNIX, make sure that the user/group your appserver is running as has read and execute permissions on all the .jar files in ./appserver/lib.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To me it looks like you are migrating to a newer version of WebSphere.
Try using the following context factory:
com.ibm.websphere.naming.WsnInitialContextFactory
The exception starts during lookup, so it might be that you are getting the wrong initial context in the first place.
reply
    Bookmark Topic Watch Topic
  • New Topic