• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

IBM WSAD...error  RSS feed

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys , i had posted a DataSource question before...but i was able to figure that out. My new problem is that i cant get the DataSource object in my java program and the following error is thrown.
---------------------------------------------------
java.lang.NoClassDefFoundError: com/ibm/ejs/ras/TraceElement
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:212)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:656)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:199)
at DataSourceCheck.main(DataSourceCheck.java:27)
Exception in thread "main"
--------------------------------------------------
Here is my Java program :
import java.sql.*;
import javax.naming.*;
import java.util.*;
class DataSourceCheck
{

public static void main(String[] args)
{
javax.sql.DataSource myDataSource= null;
try
{

String initialContextFactory = "com.ibm.websphere.naming.WsnInitialContextFactory";
String providerURL = "iiop://localhost:8081";
java.util.Properties props = new java.util.Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
props.put(Context.PROVIDER_URL, providerURL);
Context myContext = new InitialContext(props);
Connection myConnection = myDataSource.getConnection();
}
catch (Exception e)
{
e.printStackTrace();
System.out.println();
}
}
}

-------------------------------------------------
I start a Server instance from IBM WSAD and it runs on 8081.
Please suggest what to do .
 
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, the issue here is that when you just run a Java program in WSAD you're not starting it within WebSphere's J2EE client container. This is a common question we address in the WebSphere forum every day or so.
Inside WSAD, the way you address this is to make sure you do two things:
(1) Your client program must be within an Application Client Project associated with an EAR Project.
(2) To Run your client, first start the server. Then select your client program class (the one with the main() method) inside the J2EE perspective. Open the Run menu at the top of the screen and select "Run..." (Make sure you select Run... and not Run As).
(3) In the launch Configurations panel, select "WebSphere 5 Application Client" and press the "New" Button. Give your configuration a name (other than "new configuration" -- I usually use the same name as the client program class). If there are program arguments,enter them in the arguments tab. Hit "Apply" and the new configuration will be added.
(4) To run the client, press the "Run" button on ths page.
Note this will ONLY work if you are in WSAD 5.0. If you are in WSAD 4.0, you need to follow the instructions in this article.
Kyle
[ March 18, 2003: Message edited by: Kyle Brown ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!