• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing Web context in a thread in WAS 5.1  RSS feed

 
Anup Bansal
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am facing an issue with accessing a Web context in a Java thread.
I have a generic class which does an insert in the Oracle table. The resource for Oracle connection is mentioned in the Web resources.

Accessing this class from a servlet drectly does not cause any issue and a record can be directly inserted into the database.

However when I spawn a thread from the servlet which is using the generic class, the generic class is unable to detect the resource and hence the inertion of data to Oracle table fails.

How can I access such a resource in the thread i spawned?

Please advice.

Thanks & regards,
Anup
 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With regards to the resource, the next question would be exactly what are you doing, which container etc etc and your probably better posting in a J2ee forum

J2EE servers weren't intended to have threads created in them in general by applications though there are lots of examples of it being done successfully but if your using something modern, big and new container wise look for a WorkManager or Timer API against whatever your using (weblogic \ glassfish \ BEA). These let you run in threads but the container can see what your up to and do thread pooling etc etc etc ie manage you. If you make use of J2EE resources in your own thread by reference it'd be up to the container as to how helpful it was or not, though you could use things you copied at creation and passed into your thread object depending on exactly what it was.
 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Missed the WAS (read it as was) in the title you'll find the some workmanager notes for WAS 6 here (not sure about 5)...

http://www.javaworld.com/javaworld/jw-01-2007/jw-01-workmgr.html
 
Anup Bansal
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is there a better way of implementing this threading to use the generic class?

Regards,
Anup
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!