• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

plz help me ,errors in InitialContext in wsad 5.1.1

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using WAS 5.0.2 and WSAD 5.1.1 Technologies in my Application.
The problem is I am connecting DB2 using javax.sql.DataSource &InitialContext

.....


DataSource ds = (DataSource)context.lookup("jdbc/jnName");

....
already i imported jar files like namingClient.jar and set the implfactory.properties file .
But iam getting error like

java.lang.ClassCastException:javax.naming.Reference exception .

plz help me reg this .i am struggling past 3 days
plz urgent
 
author
Posts: 3892
5
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where do these errors occur? Are you doing this inside WSAD or at the command line? Is this inside a Servlet or a standalone application? We need more information to go on.

Kyle
 
Ramesh Krishna
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kyle,
Thanks for ur reply
Actually i am running this application inside WSAD and trying to connect WAS 5.0.2 Server using Standard alone Program. iam not using any servlets.
plz suggest me...
 
Kyle Brown
author
Posts: 3892
5
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only way to create a Java application that uses WebSphere resources like Datasources appropriately is to create what's called an application client. An Application Client is a special project type (create it with new>project and select Application Client) that you add to an EAR file. When you create the Application Client project the classpath will be set appropriately with J2EE.jar and the others.

Finally, you run an application Client by creating an application client configuration using Run... and creating one in the application client runner configuration editor.

Trust me, this is the ONLY supported way to make this work. BTW, you should probably read in the infoCenter for WebSphere about "launchClient" as well, since you'll probably want to run this at the command line at some point.

A good idea for more information might be to read the EJB client chapter of my book, which covers all of this in detail.

Kyle
 
Ramesh Krishna
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi kyle
Thanks for ur kind reply.But Now its different error

com.ibm.ejs.jts.jts.CurrentSet$InitializationError: not initialized

but i already imported jar file txPrivate.jar.but it still showing this exception..
what to do?
 
Kyle Brown
author
Posts: 3892
5
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this happening within an application client project using the run... menu now?

Kyle
 
Ramesh Krishna
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah For ApplicationClient Module also its giving same error
 
Kyle Brown
author
Posts: 3892
5
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeez. I just realized what's happening. Believe it or not, I wrote about this in my own book! In Chapter 30, I wrote the following:

"The problem, as described in the InfoCenter, is that WebSphere J2EE application clients cannot access DataSources defined inside WebSphere �because the J2EE application client does not support Java 2 Connection Factories.� The upshot of this is that you have to define your own
WAS4 DataSources within the application client itself. There is a tool (the application client resource configuration tool or ACRT) that allows you to do this for WebSphere, but there is no way to do the same thing within WSAD.

This tool creates an XML file (called client-resource.xmi) that defines the data sources and other J2EE resources within the client container."

In my book I ended up giving an example of using the ACRT to create the client-resource.xmi file. That's probably your best bet.

Kyle
 
Ramesh Krishna
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kyle .i will try to implement ur suggestions.
one More thing where can i get ur book. i tried here but i didnt succeded
 
Kyle Brown
author
Posts: 3892
5
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ramesh,

My book does not have a specific indian edition. You should be able to get it from Amazon or one of the other bookstores that ship internationally.

Kyle
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic