• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

NoClassDefFoundError WsnInitialContextFactory com/ibm/ejs/ras/Tr

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a very well known question.
I try to call datasource from a POJO.

My code is:

Hashtable properties = new Hashtable();

properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

Context context = new InitialContext(properties);
DataSource ds = (DataSource) context.lookup("jdbc/myDS");

Line: Context context = new InitialContext(properties); throws Exception as shown below:

Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/ejs/ras/Tr at com.ibm.websphere.naming.WsnInitialContextFactory.<clinit>(WsnInitialContextFactory.java:68).null(Unknown Source)

I have following jar files in build path of the project in following sequence:

idl.jar, iwsorb.jar,j2ee.jar,naming.jar, namingclient.jar,rt.jar, additinal jars in WebSphere v5.1JRE.

Do I need additional jar files?

There is no good documentation on the required jar files.
 
Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also have in code:
properties.put(Context.PROVIDER_URL, "iiop://localhost:myCorrectRMIPortNumber");
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sam Gehouse:

Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/ejs/ras/Tr at com.ibm.websphere.naming.WsnInitialContextFactory.<clinit>(WsnInitialContextFactory.java:68).null(Unknown Source)



You also need WAS_HOME/lib/ras.jar

Also following jar files might be required as well:

ecutils.jar
ffdc.jar
idl.jar
implFactory.jar
iwsorb.jar
j2ee.jar
naming.jar
namingclient.jar
namingserver.jar
ras.jar
tx.jar
txPrivate.jar
utils.jar
wsexception.jar

HTH
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!