HttpServlet implements Runnable thread issue

Hi,
I have a servlet that implements Runnable. In web.xml I have set this servlet to load-on-start=1. In the init method of the servlet I have a thread that starts and basically runs forever. Now I am facing some issues and am not able to figure out what exactly is going on. I see exceptions in the log file and then my servlet stops. I have catch block all over but somehow whenever some exception occurs my Thread just stops and the servlet stops too I have to manually invoke the servlet so the Thread to start over again. Here is a code snippet. Now if any error occurs in insert() method somehow Thread just stops even though I am catching an exception. This servlet is not called from anywhere it just loads as soon as the app is deployed and then the thread keeps running and in my insert method I am reading some files and inserting into the database. How can stop the thread from being stopping and where at the top level I can add catch block to exactly print the error even though I am catching all the exceptions in the code itself. How can I keep my thread alive even after any exceptions.
public class InsertData extends HttpServlet implements Runnable {
    Thread thread;
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        thread = new Thread(this);
        thread.setPriority(Thread.MIN_PRIORITY);
        thread.start();
    public void run() {      
        while (true) {                     
           insert();
           try {
            thread.sleep(10000);
          catch (InterruptedException ignored) { ; }
    private insert()
     try{
     catch(Exception exception)
    }Thanks

Hi,
After more debugging it turned out all the exceptions are handled correctly but some how after some time the thread just stops running in the servlet and even after invoking the servlet manually it doesn't start. Now asThread may take arround couple of minutes to finish but I am starting a new run every 1 minute which may lead to several Threads running a one particular time and as the time goes on thread increase also. So wondering if there's any limit on number of Threads to run at one particular time or is the Application Server removing any of these as in the code I don't see anything and no errors in the logs either.
Is there a way to find out if a servlet is loaded. As in the Application Server control I do see a servlet loaded but I don't see any of the Thread running that calls the insert method.
Also is it a good idea to have a Thread start in the init method that runs forever. Any other approach I can take. Writing a windows service or a cron job can be one but it's not in the scope. Other option I though of was using JMS and thru MDB I manually invoke the servlet and so I don't have to use Threads.
Is there any other approach I can have by using servlet itself. Basically I want to call my servlet every lets say 30 minutes automatically.
Thanks

Similar Messages

  • Threads: implement runnable or extend Thread.  Which is better?

    I want to know which way is better, as I want to do some work in threads.
    Thanks,
    Virum

    I want to know which way is better, as I want to do
    some work in threads.
    Thanks,
    VirumOne reason for implementing runnable can be that java doesnot allow multiple inheritance so by implementing runnable you can, at the same time, extend another class.
    Another reason though not recommended and not good programming practice is that although you cannot restart a dead thread, if you use runnables, you can submit the old runnable instance to a new thread, thus practically starting a thread more than once.

  • Implementing Runnable interface  Vs  extending Thread class

    hi,
    i've come to know by some people says that Implementing Runnbale interface while creating a thread is better option rather than extending a Thread class. HOw and Why? Can anybody explain.?

    Its the same amount of programming work...
    Sometimes it is not possible to extend Thread, becuase your threaded class might have to extend something else.
    The only difference between implementing Runnable and extending Thread is that by extending Thread, each of your threads has a unique object associated with it, whereas with Runnable, many threads share the same object instance.
    http://developerlife.com/lessons/threadsintro/default.htm#Implementing

  • Implements Runnable vs extends Thread

    Hello,
    Why do we call method run() in a Runnable class a thread? (at least my textbook implies such concept)
    If thread is an independent process, which runs on its own - then it's not about Runnable.run().
    public class RunnableThread implements Runnable
        public void run()
            for (int i=0; i<100000; i++)
                if (i%50000 == 0)
                System.out.print(i+" ");
        public static void main (String args[])
            System.out.println("Before thread");
            new RunnableThread().run();
            System.out.println("Thread started");// this line is executed only after
            // run() returns, not like with "true" threads, where execution course          
            //doesn't wait for start() to return
    }Or should I consider run() a regular (non-thread) method needed only to bypass extends restrictions?

    Why do we call method run() in a Runnable class a
    thread? We don't.
    (at least my textbook implies such concept)Perhaps you could post what your textbook says, and we can decipher it for you.
    If thread is an independent process, which runs
    on its own - then it's not about Runnable.run().Don't know what you mean by it being "about" Runnable.run()?
    Runnable.run is the method that gets executed when a thread is started.
    Or should I consider run() a regular (non-thread)
    method needed run() is a regular method. It happens to be one that is declared in the Runnable interface and is called by an executing thread. In your example code, you use just call run as you would any other method, so it acts just like any other method. To run it in a separate thread, you should call start() on the thread, not run(). The Thread object will then enter the waiting state and will call run() itself at the appropriate time.

  • Performance wise which is best extends Thread Class or implement Runnable

    Hi,
    Which one is best performance wise extends Thread Class or implement Runnable interface ?
    Which are the major difference between them and which one is best in which case.

    Which one is best performance wise extends Thread Class or implement Runnable interface ?Which kind of performance? Do you worry about thread creation time, or about execution time?
    If the latter, then don't : there is no effect on the code being executed.
    If the former (thread creation), then browse the API Javadoc about Executor and ExecutorService , and the other execution-related classes in the same package, to know about the usage of the various threading/execution models.
    If you worry about, more generally, throughput (which would be a better concern), then it is not impacted by whether you have implemented your code in a Runnable implementation class, or a Thread subclass.
    Which are the major difference between them and which one is best in which case.Runnable is almost always better design-wise :
    - it will eventually be executed in a thread, but it leaves you the flexibility to choose which thread (the current one, another thread, another from a pool,...). In particular you should read about Executor and ExecutorService as mentioned above. In particular, if you happen to actually have a performance problem, you can change the thread creation code with little impact on the code being executed in the threads.
    - it is an interface, and leaves you free to extend another class. Especially useful for the Command pattern.
    Edited by: jduprez on May 16, 2011 2:08 PM

  • Naming a thread that is created implementing Runnable

    How could I name a thread that I create using Runnable Interface?
    public class Test {
         * @param args the command line arguments
        public static void main(String[] args) {
            TestRunnable tr = new TestRunnable();
            /* running thread */
            new Thread(tr).start();//THREAD 3
    public class TestRunnable implements Runnable {
        public void run() {
            for(int y = 1; y < 1000; y++) {
                System.out.println("3333333333333333333333333333333333333333 " + Thread.currentThread() );
    }

    well, I'm just experimenting; learning about Threads. As you can see I
    was able to name the other two threads, I was just curious how you would do it,
    using the Runnable Interface, seeing as those two naming options I used don't
    seem to be an option for it. I may be misunderstanding your reply...
        public static void main(String[] args) {//thread 0
            FrameThread ft = new FrameThread();//extends Thread
            ft.setName("ft");
            Thread td = new Thread("td") {
                @Override
                public void run() {
                    for(int a = 1; a < 1000; a++) {
                        System.out.println("1111111111111111111111111111111111111111 " + Thread.currentThread() );
            TestRunnable tr = new TestRunnable();//class implements Runnable
            /* running threads */
            td.start();//THREAD 1
            ft.start();//THREAD 2
            new Thread(tr).start();//THREAD 3
    }I'm naming them so when I use : Thread.currentThread() the return slot has the name I provide.
    Edited by: rico16135 on May 3, 2008 3:14 PM
    Edited by: rico16135 on May 3, 2008 3:17 PM

  • Hi Guys! Will you share your thoughts on a Thread issue?

    Hi! I am working on figuring out how to get my application to use threads to enable the simultaneous movement of (n) balls across the JFrame area. The task is to enable the user to click on the application and with each click a new ball should be created as a Thread and then it should bounce back and forth across the screen.
    I have been working on this now for a couple of days. It would be really great if one of you guys could help me! :-)
    Here are my specific issues:
    I am using the mousePressed() method to generate the data needed to instantiate a Ball object. However, I cannot get it to work as a Thread.
    I tried calling the start() method on it but all that happens is the application stays blank.
    I cannot get this thing to work -and I really need to make it work today -- Please --- is there a sweetheart out there who will take a minute to help? ;-)
    Jennifer
    My code is below:
    Balls.java
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Balls extends JFrame implements MouseListener
          private int x, y, r, g, b;//Variables to hold x,y and color values
          private Vector basketOBalls;//Hold all of the Ball objects (and Threads created)
          private Ball ballFactory;//Ball objects created here
            Method Name: Balls()
            Return Value: none
            Input Parameters: None
            Method Description: Constructor
          public Balls()
            //call to super for Title of app
            super( " Bouncing Balls " );
            //Listen for mouse events
            addMouseListener( this ); 
            //instantiate the basketOBalls object
            basketOBalls = new Vector(20);
                //Set Initial JFrame Window Size
            setSize( 400, 400 );
         //Show it!
         show();
         }//EOConstructor
            Method Name: mousePressed(MouseEvent e)
            Return Value: none
            Input Parameters: MouseEvent
            Method Description: This takes the info from the users
            mouse click and creates a new Ball Object and then adds it
            to the basketOBalls Vector. Presently, it (incorrectly?) also
            calls the repaint() method in order to draw the ball to the
            screen.
           public void mousePressed( MouseEvent e )
               x = e.getX();//set x value
               y = e.getY();//set y value
               r = 1 + (int) ( 254 * Math.random() );//set red value
               g = 1 + (int) ( 254 * Math.random() );//set green value
               b = 1 + (int) ( 254 * Math.random() );//set blue value
               Color colorin = new Color( r, g, b );
               ballFactory = new Ball( x, y, colorin );
               //new Thread(ballFactory).start(); //This is the Problem area!!!!!!!!!!!!!!!!!!!!!
               basketOBalls.addElement( ballFactory );
               repaint();
            }//EOmP
            Method Name: paint( Graphics g )
            Return Value: none
            Input Parameters: Graphics Object g
            Method Description: Walk through the Vector to
            explicitly cast each object back as a Ball and
            then calls the Ball draw() and ball move() methods
            in order to make the balls move on the screen.
        public void paint( Graphics g )
            Ball b;
            for( int i = 0; i < basketOBalls.size(); i++)
               b = (Ball) (basketOBalls.elementAt(i));
               b.draw(g);
               b.move();
            }//EOFor
          }//EOpaint
            Method Name: main()
            Return Value: none
            Input Parameters: String args[]
            Method Description: This makes it all go.
          public static void main( String args[] )
            Balls app = new Balls();
            app.addWindowListener(
              new WindowAdapter()
                     public void windowClosing( WindowEvent e )
                                    System.exit(0);
                     }//EOwindowClosing Method
              }//EOWindowAdapter Method
              );//EOaddWindowListener Argument
          }//EOMain
        public void mouseClicked( MouseEvent e ) { }
        public void mouseReleased( MouseEvent e ) { }
        public void mouseEntered( MouseEvent e ) { }
        public void mouseExited( MouseEvent e ) { }
    }//EOFBall.java
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Ball extends JFrame //implements Runnable
            public static final int APP_SIZE = 400;//set bounds for screen area
         public static final int RADIUS = 15;//set size of balls
            private Color bgColor = java.awt.Color.lightGray;//may be used to clear background of JFrame
         private int x, y;//x & y coordinates
         private int speedX, speedY;//distances to use to redraw the balls
            private Color color = null;//the color of a ball
            Method Name: Ball(int initX, int initY, Color colorin) 
            Return Value: none
            Input Parameters: int, int , color
            Method Description: Constructor that creates a Ball object
         public Ball(int initX, int initY, Color colorin)
              x = initX;
              y = initY;
                    color = colorin;
                 speedX = (int)(1 + (Math.random() * 10));
              speedY = (int)(1 + (Math.random() * 10));
            Method Name: move()
            Return Value: none
            Input Parameters: none
            Method Description: This calculates the balls position and keeps it within
            the 400 pixel size of the application frame.
         public void move()
              x += speedX;
              y += speedY;
              if ((x - RADIUS < 0) || (x + RADIUS > APP_SIZE))
                   speedX = -speedX;
                   x += speedX;
              if ((y - RADIUS < 0) || (y + RADIUS > APP_SIZE))
                   speedY = -speedY;
                   y += speedY;
         } //EOMove
            Method Name: draw(Graphics bg) 
            Return Value: none
            Input Parameters: graphics
            Method Description: This method is how the ball draws itself
            public void draw(Graphics bg)
                bg.setColor( color );
                bg.fillOval(x - RADIUS, y - RADIUS, 2 * RADIUS, 2 * RADIUS);
    //PROBLEM AREA PROBLEM AREA PROBLEM AREA PROBLEM AREA PROBLEM AREA PROBLEM AREA
            Method Name: run() 
            Return Value: none
            Input Parameters: none
            Method Description: This method is called by start() in the Balls.java file
            found in the mousePressed() method. however, it does not work properly.
         public void run()
               while(true)
              try
                 Thread.sleep(100);
                       move();
                       draw(g);
                       repaint();
                    catch(Exception e)
                    e.printStackTrace( System.out );
        }//EOF

    There needs to be only one thread. On every mouse pressed just add a new Ball object to the vector located in Balls class. That thread need only invoke a repaint on your main class called Balls.
    public class Balls extends JFrame implements Runnable,MouseListener{
    Vector vector = new Vector();
    public static void main(String[] args){
    Balls balls = new Balls(); balls.setSize(400,400);
    balls.setVisible(true);
    Thread thread = new Thread(this);
    thread.start();
    public void run(){ 
    while(true){
    repaint();
    try{
    Thread.sleep(4000); //delay
    }catch(InterruptedException e){}
    public void paint(Graphics){
    for(i=0; i<vector.size(); i++){
    Ball b = (Ball)vector.elementAt(i);
    reposition(b);
    g.drawArc(b.getX(),b.getY(),0,360);
    public void reposition(Ball b){
    // reposition ball using balls get/set methods.
    public void MouseClicked(MouseEvent e){
    // add a new ball to vector.
    public class Ball{
    int x,y;
    public int getX(){ return x; }
    public int getY(){ return y; }
    public int setX(int x){ this.x = x; }
    public int setY(int y){ this.y = y; }
    Do check the syntax and compilation errors. The code above should give you some idea for approach.

  • Qestion for implementing Runnable

    HI,
    I have a function which executes multiple methods and store the result from those methods in List<Stirng> before the last methods executes I need to insert these List<String> values in a database with my dao object.
    I was wondering if I do the following:
    new Thread(new myInsertWorker()).start();
    executeMyFunction();
    Would I improve the performance on my program since it is very important for this last function to be fast.
    My question is if I insert the strings as a separate thread how do I need to write the thread to be as simple as possible and not cause any performance issues?

    Here is my code, I am new to concurrent programming, therefore I move slowly :) and check my code with someone else to prevent issues I am not aware of.
    Can I improve this simple piece of code to make sure if it does fail or hangs my application will not be affected?
    Thank you
    public class LogMessageWorker implements Runnable {
        List<LogMessage>_messages = new LinkedList();
        LogMessageDAO _logMessageDAO=null;
        public LogMessageWorker(LogMessageDAO logMessageDAO, List<LogMessage> messages){
            this._messages = messages;
            this._logMessageDAO = logMessageDAO;
        public LogMessageWorker(LogMessageDAO logMessageDAO, LogMessage message){
            this._messages.add(message);
            this._logMessageDAO = logMessageDAO;
        public void run() {
            try{
                _logMessageDAO.add(_messages);
            }catch(Exception e){
                e.printStackTrace();
    }This is how I call it:
    try {
                Thread logMsgThread = new Thread(new LogMessageWorker(logMessageDAO, logMessages));
                //logMsgThread.setPriority(Thread.MIN_PRIORITY);
                logMsgThread.start();
            } catch (Exception e) {
                e.printStackTrace();
            }Edited by: kminev on Dec 3, 2009 2:06 PM

  • Implementation of threads in servlets

    How to implement thread in the servlet which should be refreshed for for 30 minutes. Plz kindly help to code this.
    regards
    Suresh S

    Hi.
    Because servlet extends from HttpServlet you must implement this by implementing the Runnable interface, so yo must declare :
    public class myServlet extends HttpServlet implements Runable
    and you must implement the void run() function. At these fuction you must slepp the current trhead until 30 min :
    void run()
    Thread t=System.getCurrentThread();
    t.sleep(30000);
    // etc...
    Finnaly you must start this thread and the best place is at init funcion. How? well you need do some like
    Thread myT=new Thread(this);
    myT.start();
    but a interstenig question is how stop this thread. Well you can do this at destroy member of servlet. Destroy is called once by servlet container.
    The code sample is incomplete and you must catch some exceptions (for instance at sleep call)
    Hope this helps

  • A Simple Thread issue ....Please help

    I want to clean up something after completion of all threads. But my
    System.out.println("After completion of all the threads ...cleanup logic should goes here....");               
    is executing at first or in middle. please help me to fix this problem.
    class ThreadLogic implements Runnable
    public void run()
    for (int i = 1; i <= 10; i++)
    System.out.println(Thread.currentThread().getName()+" "+i);
    public class MyThread
    public static void main(String args[]) throws Exception
    Thread a=new Thread(new ThreadLogic(),"first");
    Thread b=new Thread(new ThreadLogic(),"second");
    a.start();
    b.start();
    System.out.println("After completion of all the threads ...cleanup logic should goes here....");               
    }

    [url http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#join()]Thread.join
    a.start();
    b.start();
    a.join();
    b.join();
    cleanup();

  • Problem Deploying Composites to Oracle SOA 11.1.1.5 (STUCK Thread Issue)

    Hi All,
    I got stuck thread issues when deploying composites to Oracle SOA 11.1.1.5 running on Windows Server 2008 R2. Even the SimpleApproval composite which ships with the standard installation is having trouble deploying.
    The composites are deploying fine in Oracle SOA 11.1.1.5 running on Windows XP.
    I'm not so good with thread dumps, so I post it below for rescue.
    Please advice,
    Rommel
    <Jul 18, 2011 10:15:25 AM AST> <Error> <WebLogicServer> <BEA-000337> <[STUCK] Ex
    ecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)' has been bus
    y for "605" seconds working on the request "weblogic.servlet.internal.ServletReq
    uestImpl@32d047d4[
    POST /soa-infra/deployer HTTP/1.1
    Connection: TE
    TE: trailers, deflate, gzip, compress
    User-Agent: Oracle HTTPClient Version 10h
    Accept-Encoding: gzip, x-gzip, compress, x-compress
    ECID-Context:
    Authorization: Basic bmFnaGl3ZWJsb2dpY3NvYTp3ZWJsb2dpY3NvYTEwIQ==
    Content-type: application/octet-stream
    Content-Length: 25876
    ]", which is more than the configured time (StuckThreadMaxTime) of "600" seconds
    . Stack trace:
    Thread-55 "[STUCK] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-
    tuning)'" <alive, in native, suspended, priority=1, DAEMON> {
    jrockit.net.SocketNativeIO.readBytesPinned(SocketNativeIO.java:???)
    jrockit.net.SocketNativeIO.socketRead(SocketNativeIO.java:24)
    java.net.SocketInputStream.socketRead0(SocketInputStream.java:???)
    java.net.SocketInputStream.read(SocketInputStream.java:107)
    oracle.net.nt.MetricsEnabledInputStream.read(TcpNTAdapter.java:707)
    oracle.net.ns.Packet.receive(Packet.java:243)
    oracle.net.ns.DataPacket.receive(DataPacket.java:106)
    oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:309)
    oracle.net.ns.NetInputStream.read(NetInputStream.java:254)
    oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrap
    per.java:93)
    oracle.jdbc.driver.T4CMAREngine.getNBytes(T4CMAREngine.java:1573)
    oracle.jdbc.driver.T4C8TTILobd.unmarshalLobData(T4C8TTILobd.java:360)
    oracle.jdbc.driver.T4C8TTILob.readLOBD(T4C8TTILob.java:787)
    oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:303)
    oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:181)
    oracle.jdbc.driver.T4C8TTILob.read(T4C8TTILob.java:139)
    oracle.jdbc.driver.T4CConnection.getBytes(T4CConnection.java:2690)
    ^-- Holding lock: oracle.jdbc.driver.T4CConnection@32386377[thin lock]
    oracle.sql.BLOB.getBytes(BLOB.java:557)
    oracle.jdbc.driver.OracleBlobInputStream.needBytes(OracleBlobInputStream.jav
    a:188)
    oracle.jdbc.driver.OracleBufferedStream.readInternal(OracleBufferedStream.ja
    va:171)
    oracle.jdbc.driver.OracleBufferedStream.read(OracleBufferedStream.java:151)
    ^-- Holding lock: oracle.jdbc.driver.OracleBlobInputStream@341d0b87[thin loc
    k]
    java.io.BufferedInputStream.fill(BufferedInputStream.java:189)
    java.io.BufferedInputStream.read(BufferedInputStream.java:236)
    ^-- Holding lock: oracle.mds.internal.persistence.db.DBInputStream@341d0bb2[
    thin lock]
    oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:363)
    oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:230)
    oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:217)
    oracle.fabric.common.wsdl.SchemaBuilder.parseXMLSrc(SchemaBuilder.java:1016)
    oracle.fabric.common.wsdl.SchemaBuilder.parseXSDSrc(SchemaBuilder.java:984)
    oracle.fabric.common.wsdl.SchemaBuilder.processSchemaImportsAndInclude(Schem
    aBuilder.java:755)
    oracle.fabric.common.wsdl.SchemaBuilder.loadEmbeddedSchemas(SchemaBuilder.ja
    va:474)
    oracle.fabric.common.wsdl.SchemaBuilder.loadSchemasFromWSDL(SchemaBuilder.ja
    va:423)
    oracle.fabric.common.wsdl.SchemaBuilder.loadAllSchemas(SchemaBuilder.java:21
    4)
    oracle.fabric.common.wsdl.SchemaManager.loadAllXSD(SchemaManager.java:209)
    ^-- Holding lock: oracle.fabric.common.wsdl.SchemaManager@36279195[thin lock
    oracle.fabric.common.wsdl.SchemaManager.getXSDEntityResolver(SchemaManager.j
    ava:424)
    oracle.fabric.composite.model.CompositeModel.loadImports(CompositeModel.java
    :361)
    oracle.fabric.composite.model.CompositeModel.getWSDLManager(CompositeModel.j
    ava:196)
    oracle.integration.platform.blocks.adapter.AbstractAdapterBindingComponent.g
    etWSDLDefinition(AbstractAdapterBindingComponent.java:168)
    oracle.integration.platform.blocks.adapter.AdapterReference.loadDefinition(A
    dapterReference.java:543)
    oracle.integration.platform.blocks.adapter.AdapterReference.load(AdapterRefe
    rence.java:377)
    oracle.integration.platform.blocks.adapter.AdapterReference.load(AdapterRefe
    rence.java:73)
    oracle.integration.platform.blocks.deploy.CompositeDeploymentConnection.depl
    oyReferences(CompositeDeploymentConnection.java:177)
    oracle.integration.platform.blocks.deploy.CompositeDeploymentConnection.depl
    oy(CompositeDeploymentConnection.java:81)
    oracle.integration.platform.blocks.deploy.CompositeDeploymentManagerImpl.ini
    tDeployment(CompositeDeploymentManagerImpl.java:143)
    oracle.integration.platform.blocks.deploy.CompositeDeploymentManagerImpl.loa
    d(CompositeDeploymentManagerImpl.java:61)
    sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:?
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:27
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
    .java:25)
    java.lang.reflect.Method.invoke(Method.java:575)
    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopU
    tils.java:306)
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint
    (ReflectiveMethodInvocation.java:182)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Reflect
    iveMethodInvocation.java:148)
    oracle.integration.platform.blocks.deploy.DeploymentEventPublisher.invoke(De
    ploymentEventPublisher.java:57)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Reflect
    iveMethodInvocation.java:148)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopPro
    xy.java:151)
    $Proxy309.load(Unknown Source)
    oracle.integration.platform.blocks.deploy.StandaloneCompositeDeploymentCoord
    inatorImpl.coordinateCompositeDeployment(StandaloneCompositeDeploymentCoordinato
    rImpl.java:54)
    oracle.integration.platform.blocks.deploy.servlet.BaseDeployProcessor.deploy
    NewComposite(BaseDeployProcessor.java:365)
    oracle.integration.platform.blocks.deploy.servlet.BaseDeployProcessor.deploy
    SARs(BaseDeployProcessor.java:123)
    ^-- Holding lock: java.lang.Object@3621c97c[thin lock]
    oracle.integration.platform.blocks.deploy.servlet.DeployProcessor.doDeployWo
    rk(DeployProcessor.java:122)
    oracle.integration.platform.blocks.deploy.servlet.DeployProcessor.doDeployWo
    rk(DeployProcessor.java:107)
    oracle.integration.platform.blocks.deploy.servlet.DeployProcessor.doDeploy(D
    eployProcessor.java:96)
    oracle.integration.platform.blocks.deploy.servlet.DeployProcessor.process(De
    ployProcessor.java:68)
    oracle.integration.platform.blocks.deploy.servlet.CompositeDeployerServlet.d
    oPostInsideLoggingSession(CompositeDeployerServlet.java:141)
    oracle.integration.platform.blocks.deploy.servlet.CompositeDeployerServlet.d
    oPost(CompositeDeployerServlet.java:119)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:700)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:815)
    weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSe
    curityHelper.java:224)
    weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelpe
    r.java:108)
    weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:206)
    weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:55)
    oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
    oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:299)
    oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java
    :405)
    oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
    oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:98)
    oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
    weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:55)
    oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
    oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:299)
    oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java
    :405)
    oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
    oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:98)
    oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
    weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:55)
    oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:86)
    weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:55)
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapR
    un(WebAppServletContext.java:3687)
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(W
    ebAppServletContext.java:3681)
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
    t.java:308)
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:116)
    weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletC
    ontext.java:2213)
    weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.
    java:2135)
    weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:142
    0)
    weblogic.work.ExecuteThread.execute(ExecuteThread.java:203)
    weblogic.work.ExecuteThread.run(ExecuteThread.java:170)
    >

    I just noted that this is a database connectivity issue because when I point my soa related data sources (mds, soa_infra, etc...)to a local xe database, the deployment is doing fine.

  • Error creating an instance of a runnable thread

    I'm trying to create two instances of a runnable thread but get this error message (in Eclipse):
    "No enclosing instance of type GE4000 is accessible. Must qualify the allocation with an enclosing instance of type GE4000 (e.g. x.new A() where x is an instance of GE4000)."
    I don't understand this error at all.
    GE4000 is GE4000.java
    The error occurs here and is within a protected static boolean method.
    for(int t = 0; t < (int) cameraCount; ++t) {
                   streamThreads[t] = new Thread(new CaptureStream(cameraHandle[t], frameBuffers[t], frameCount, basePath));
    CaptureStream Class is defined:
         public class CaptureStream implements Runnable {
    the constructor is:
         CaptureStream(Pv.tHandle handle, Pv.tFrame[] cameraFrames, int frameCount, String basePath) {
    Ironically, within CaptureScreen's run method I do an analogous creation of another thread without seeing an error.
    Edited: I un-nested it and it works! Thanks
    Edited by: Shellback3 on Dec 8, 2010 1:13 PM

    Kayaman wrote:
    I'd recommend avoiding using inner classes or at least learning how to use them before actually using them.I'm new at Java and that's why I posted to the forum.
    Or do you really need to have CaptureStream as an inner class?
    In any case you're trying to create one in a static method, where no enclosing instance of the outer class (GE4000) is available. So at the very least you'd need to make it a static nested class.OK, this is my structure:
    public class GE4000 {
    class CaptureStream implements Runnable {
    run() {}
    boolean startStreamCapture() {}
         public static void main(String[] args) {
    startStreamCapture();
    The method startStreamCapture was static and when I made it to non-static the error went away.
    However I can't use the method in main because it's not static.
    Do I understand correctly that the way to solve this is to put class CaptureStream into CaptureStream.java? That is, un-encapsulate it and then make startStream static?
    BTW My original version extended Thread and it compiled (but didn't do what I wanted) the error cropped up when I changed it to implement runnable.
    I appreciate your help.
    Nate

  • Question about methods in a class that implements Runnable

    I have a class that contains methods that are called by other classes. I wanted it to run in its own thread (to free up the SWT GUI thread because it appeared to be blocking the GUI thread). So, I had it implement Runnable, made a run method that just waits for the thread to be stopped:
    while (StopTheThread == false)
    try
    Thread.sleep(10);
    catch (InterruptedException e)
    //System.out.println("here");
    (the thread is started in the class constructor)
    I assumed that the other methods in this class would be running in the thread and would thus not block when called, but it appears the SWT GUI thread is still blocked. Is my assumption wrong?

    powerdroid wrote:
    Oh, excellent. Thank you for this explanation. So, if the run method calls any other method in the class, those are run in the new thread, but any time a method is called from another class, it runs on the calling class' thread. Correct?Yes.
    This will work fine, in that I can have the run method do all the necessary calling of the other methods, but how can I get return values back to the original (to know the results of the process run in the new thread)?Easy: use higher-level classes than thread. Specifically those found in java.util.concurrent:
    public class MyCallable implements Callable<Foo> {
      public Foo call() {
        return SomeClass.doExpensiveCalculation();
    ExecutorService executor = Executors.newFixedThreadPool();
    Future<Foo> future = executor.submit(new MyCallable());
    // do some other stuff
    Foo result = future.get(); // get will wait until MyCallable is finished or return the value immediately when it is already done.

  • Reflect the class that implements Runnable

    Hi,
    I am implementing the reflection of the class that implements Runnable. In order to start a new thread I am trying to invoke "start()" method ( which is obviously not defined my class ) and I therefore I am getting "java.lang.NoSuchMethodException".
    I am wondering is it possible at all to start a new thread on a reflected class?
    thanks in advance.
    {              Class refClass = Class.forName(className);
    String methodName = "start";
    Class[] types = new Class[1];
    types[0] = Class.forName("java.util.HashMap");
    Constructor cons = refClass.getConstructor(types);
    Object[] params = new Object[5];
    params[0] = new HashMap();
    Method libMethod = refClass.getMethod(methodName, null);
    libMethod.invoke(objType, null); }

    Well, if we knew what it meant to "start a thread on a class" we could probably figure out how to "start a thread on a reflected class". If we knew what a "reflected class" was, that is.
    In other words, it would help if you rephrased your question using standard terminology (and also explained why you want to do whatever it is you want to do).
    But let's guess for now: If you have an object which implements Runnable then you start a thread to run that object like this:
    Runnable r = // some object which implements Runnable
    new Thread(r).start();Not what you wanted? Go ahead and clarify then.

  • Thread issue...please clarify

    I am kind of new in Servlet/JSP world.
    I have a servlet and it gets the information from the database and put the information in a bean . In the servlet, the bean is placed in session object. The code is as follows:
    doPost(......)
    HttpSession session = req.getSession(true);
    //Here session is local variable to doPost()
    session.setAttribute("name", databean);
    //databean is the bean created by servlet inside doPost()
    //Then sendRedirect to a JSP page to show the information from the bean.
    The JSP retrives the values as bellow:
    <jsp:useBean id="name" class="common.Databean"
         scope="session" />
    <%
              //Get the information from the bean               
              Rowbean [] rows = name.getRows();
              for(int x = 0; x < rows.length ; x++)
              String description = rows[x].getDescription();
              String category_ident = rows[x].getCategory_ident();
    %>
    My question is :
    Is there any safe threading issue in this procedure..to be specific is that session object is accessable by any other client calling same time the servlet..
    Any explanation will be appreciated.
    Shakilc

    It is quite possible that the session can be accessed by two threads. This would be the case if the user accesses your servlet from two browser windows (or tabs). Browsers have different behaviors with regard to interacting with your application sessions. For example, two IE windows will be treated as two sessions, whereas, two Netscape tabs (not windows) will be treated as a single session. This behavior is browser specific. So, it is quite likely that you may be have two threads accessing your session at the same time. The session implementation is typically synchronized, so that two or more threads cannot modify a session value at the same time, but, one thread can immediately overwrite a value stored by another thread. This is normal behavior and typically acceptable behavior.
    Hope this answers your question.
    Sonny

Maybe you are looking for

  • I am having problems with Facebook.

    Two days ago we switched our internet company over from Hughes Net to Century Link. When we had Hughes Net, Facebook worked perfectly fine, other than it being slow simply because Hughes Net sucks. Now that we have Century Link, I decided to update t

  • Upgrading Weblogic 8.1, SP2 to Weblogic 8.1, SP6

    wanna to the code changes that are required in web application while upgrading Weblogic 8.1, SP2 to Weblogic 8.1, SP6.

  • Low sound/volume output

    After applying the updates (iTunes(6.02) & OS X (10.4.4)) the volume on my iMac seems to be a lot lower than it was before. I now have to turn the volume up more than half way to get the same output I used to get when the volume was only turned up a

  • For error message

    I have a problem some file has not open Error message Thisis not a valid PDF file

  • Routes and route groups expanded

    Is there any way to force the routes and route groups to show un-expanded when I click on the Routes/Groups tab in switch executive? I have many and it is difficult to navigate when they are all expanded. kph