on 07-24-2006 3:44 PM
I use jndi as temporary storage: first time when application runs it creates a thread and put it into jndi. next times application tries to find created thread in jndi - all is OK until i try to cast found object to my type.
class MyType implements Runnable{....}
in app:
Context ctx = null;
try {
Hashtable props = new Hashtable(1);
props.put("domain", "true");
ctx = new InitialContext(props);
Object found = ctx.lookup("jndiNameHere");
c = ((MyType ) found).getCounter(); // ClassCastException Here
} catch (NameNotFoundException e) {
MyType myType = new Scheduler();
try {
ctx.bind("jndiNameHere", myType );
} catch (NamingException e1) {
throw new ServletException(e);
}
myType .start();
} catch (Exception e) {
throw new ServletException(e);
}
the problem can be solved by making MyType Serializable:
class MyType implements Runnable, Serializable{....}
but in this case after jndi lookup i will have deSerialized object. This is not good for me - my thread (MyType) elters variable 'counter' and i want to get reference to the object with altered value.
Denis,
it´s not recommended to create your own threads in a container. Please tell more about your requirements, perhaps there is a smarter solution.
Regards
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Consider to use JMS (Java Message Service). You can put your jobs in a queue and a listener can process these jobs. This is the recommended solution to realize asynchronous communication.
I hope that helps a little bit. There are a lot of tutorials about JMS on the net (of course there are some pitfalls with SAP WAS, when you running in problems just ask here in the forum).
Regards
Sebastian
Message was edited by: Sebastian Voss
Denis,
Try this approach: <a href="/people/maksim.rashchynski/blog/2006/07/19/sdn-rss-feeds-spider-using-was-timeout-service">SDN RSS Feeds spider using WAS Timeout Service</a> by <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=pyouhggpqqi%3d">maksim Rashchynski</a>, btw our former collegue.
Valery Silaev
EPAM Systems
P.S. Join the <a href="http://sdn.idizaai.be/sdn_world/sdn_world.html">SDN World</a>!
The main problem i faced - is to init queue of task only one time - when server starts. Starts/stop/redeploy of my app must not influence on tasks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.