User threads in OC4J 10.1.2

I have a servlet running in an OC4J container that kicks off a daemon thread. It looks like the thread ends when the OC4J instance is restarted...
Can anyone confirm this?
Also, does adding the -userThreads switch to the OC4J startup offer any advantage other than allowing user Threads to access the OC4J context?

... just in case you don't get an answer on this forum. There is a J2EE forum and Oracle Application Server forum which might be the better source to ask this question.
Frank

Similar Messages

  • User Thread from OC4J

    Hi,
    I am trying to start a new thread from within my web application.
    but every time it gives me an error -
    javax.naming.NamingException - Not in application scope - start OC4J with the -userThreads switch if using user created threads.
    Can anyone suggest what changes in the server setting do i need to make to the Oracle application server ? I am using 10g version.

    Hi,
    use Enterprise Manager to get to the application server, select your OC4J container, select administration, go to server attributes and put the switch -userThreads to the OC4J options. Restart the container.
    That should do it.
    Timo

  • Creating AppModule in a background user thread (NPE)

    Hello!
    The application uses a user thread (OC4J is running with -userThreads option) which used for perform some background tasks.
    We want the thread creates an application module, fires some methods, releases the module and exit.
    So, we have a code fragment like this in run() method:
    service =
    (AppModule)Configuration.createRootApplicationModule(SERVICE, SERVICE_CONFIG, null);
    service.doSomething();
    Ihe following error is occurring:
    06/12/12 20:44:06 java.lang.NullPointerException
    06/12/12 20:44:06      at com.evermind.server.http.EvermindHttpServletRequest.unprivileged_getSession(EvermindHttpServletRequest.java:2609)
    06/12/12 20:44:06      at com.evermind.server.http.EvermindHttpServletRequest.getSession(EvermindHttpServletRequest.java:2592)
    06/12/12 20:44:06      at oracle.jbo.http.HttpSessionCookieHelperImpl.generateSessionId(HttpSessionCookieHelperImpl.java:175)
    06/12/12 20:44:06      at oracle.jbo.http.HttpSessionCookieFactory.createSessionCookie(HttpSessionCookieFactory.java:113)
    06/12/12 20:44:06      at oracle.jbo.common.ampool.ApplicationPoolImpl.createSessionCookie(ApplicationPoolImpl.java:452)
    06/12/12 20:44:06      at oracle.jbo.client.Configuration.getApplicationModule(Configuration.java:1540)
    06/12/12 20:44:06      at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1504)
    06/12/12 20:44:06      at ut.ThreadWorker.run(ThreadWorker.java:48)
    06/12/12 20:44:06      at java.lang.Thread.run(Thread.java:595)
    Please, anybody have access to sources, what you can say about this trace or do you have another ideas how to launch module from user thread?
    Thanks in advance!
    Ilya.

    Repost.
    Now I am trying to solve this issue by investigating, why module is running without errors if launched from console. In this case ApplicationPoolImpl.createSessionCookie is also fired, but don't try to obtain HttpSession from web container. When module is launched from background thread the pool ans session factory trying to do it (and error in EvermindHttpServletRequest.java occurs because there is no any requests).
    Ilya.

  • User Threads for concurrent processing

    Is it adviasble to create threads inside Session beans. I want to query 2 different
    database/dataservers concurrently. These are huge quries. I have heard that creating
    user threads are not advisable and against J2EE. What are other ways of doing
    concurrent processing in EJB.

    Rajesh wrote:
    Rob,
    We need to build a session bean which would basically query 2 different
    data base. This seesion bean then collects the result from these queries to come
    back so that we can post it on the web.
    We can use JMS and callback interface but the problem here is these queries
    bring back large data. With JMS we would be basically using double the memory.
    One for storing data in the JMS and then in the session bean. With threads we
    can make these threads write to the same memory/datastructure. You don't need to store the data in JMS. Just use JMS to do the async
    work and the notification when the work is done. Your code that picks
    up the response/data can still consult your datastructure.
    -- Rob
    >
    >
    >
    Rob Woollen <[email protected]> wrote:
    Right, it's generally not recommended that you create threads.
    What are your desired semantics? JMS is a nice way to do asynchronous
    work.
    Should the session bean wait for the queries to return, or is there some
    callback interface?
    -- Rob
    hsejar wrote:
    Is it adviasble to create threads inside Session beans. I want to query2 different
    database/dataservers concurrently. These are huge quries. I have heardthat creating
    user threads are not advisable and against J2EE. What are other waysof doing
    concurrent processing in EJB.

  • Risk, if any, of closing ServletOutputStream using a user thread?

    Hello All,
    What is the risk of writing/flushing/closing ServletOutputStream using a user thread other than the HTTP thread associated with the request?
    I want to do that to implement client request timeouts. Currently in our application, for every request received we are creating a new thread to make the HTTP thread timeout after a configurable amount of time is elapsed. Though creating a new thread is doing the job just fine but that approach is creating another problem that the servers are not scaling to the load we receive. We frequently get "unable to create threads due to unavailable memory" errors. At any point in time, any of our servers receive ~200 requests, which means that server has to create/handle 400+ threads. If the servers are slow due to external systems, then a lot more threads will be accumulated in the server. When the thread count reaches 500+ it fails to accept any further requests. So as a possible alternative to current approach, I am thinking of running few threads (may be a couple of threads) in the background and timeout the requests by closing the associated ServletOutputStream with TimeoutException.
    Note: I know that as another possible solution, I can go for few more servers in the cluster but before that I want to check if the above approach is a possible solution because it is less complex and saves money on the hardware.
    Thanks,
    Srinivas

    Hello Kaj,
    Sorry for the cross-post. Actually, I couldn't decide if I should post it as a concurrency, Java Servlet or as a design question.
    Maxideon,
    Sure, it can be done with single thread also. I said a couple of threads because a single thread may not get sufficient CPU time to handle all timeouts. But otherwise yes, we can try it with single thread also.
    ejp,
    We do not own the client application. We are a web services application and there are many clients who consume our services.
    The standard solution to handle timeouts in the server is by creating an additional thread, which is what we have followed. Now, that design is posing a new problem to us.
    No. A custom TimeoutException.
    I want to use 2 or 3 user threads to timeout the request if needed. That way I do not have to create 1 thread for each request. In the current approach server creates/handles 400 threads for 200 requests. With the alternative solution I can make it to create/handle 202 or 203 threads for 200 requests.
    dubwai,
    Here I am answering to your reply to my same question in the other forum.
    The current design is working just fine for timeouts. But sometimes it is failing to scale to the load we receive. In the current design we have created 1 thread for each request to timeout HTTP thread, which means that for 200 requests we will have 400 threads (200 HTTP threads and 200 user threads) in the server. For some reason, if the load increases to 250 requests or if external systems are slow then more threads accumulate in the server and it fails to accept incoming requests when thread count reaches ~500. That is the problem we are having.
    In the alternative design I proposed that we will create just a couple (may be 2 or 3) of threads running in the background, instead of 1 thread for each request. These background threads monitor HTTP threads and timeout the request if needed by writing and closing ServlerOutputStream. This way server will have to create/handle only ~200 HTTP threads plus a couple of user threads. For this approach to work I have to close ServletOutputStream using background threads instead of HTTP thread and want to know what is the rick of doing that?
    To All,
    Here is a rough implementation of user thread. The HTTP thread registers itself in threadMap variable with its starttime and in threadResponse variable with its associated HttpServletResponse. This user thread uses these values to find request timeout (10 seconds) and close response if needed.
    public class TimeoutMonitor implements Runnable {
        public static Map<Thread, Long> threadMap = new HashMap<Thread, Long>();
        public static Map<Thread, HttpServletResponse> threadResponse =
            new HashMap<Thread, HttpServletResponse>();
         @Override
         public void run() {
             while(true) {
              try {
                  wait(1000);
                  Set<Thread> keys = threadMap.keySet();
                  Iterator<Thread> threads = keys.iterator();
                  while(threads.hasNext()) {
                      Thread thread = threads.next();
                      Long startTime = threadMap.get(thread);
                   if((System.currentTimeMillis() - startTime) > 10000) {
                       HttpServletResponse response =
                                    threadResponse.get(thread);
                       try {
                        PrintWriter writer = response.getWriter();
                        writer.write("Timeout Exception");
                        writer.flush();
                        writer.close();
                        threadMap.remove(thread);
                        threadResponse.remove(thread);
                       } catch (IOException e) {
                        e.printStackTrace();
              } catch (InterruptedException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
        }I have test run this program in tomcat and seem to be working fine. Please note that here response/writer are closed by user thread and not HTTP thread. My questions is, do you see any problem in doing that?
    Thanks,
    Srinivas

  • User threads can't access server context?

    Hi,
    I have centralized-file called Jndi that
    is used to access/lookup local interface for my bean.
    It seems to work fine on Jboss,
    but when I switched to OC4J it gave me this message:
    javax.naming.NamingException: Not in an application scope - start Orion with the -userThreads switch if using user-created threads
    I've already put this in Project Setting->Runner:
    -Doc4j.userThreads=true for the VM Option,
    But still didn't work.
    Any comment/suggestion?
    Thx.A.lot
    Sorry to bother you all
    ~Irfan

    Hi
    You should call:
    java -jar oc4j.jar -userThreads

  • JNDI, users & Threads

    We are getting a random application Error,
    javax.naming.NoPermissionException: User <anonymous> does not have permission
    on ... to perform lookup operation.
    Again, this happens very rarely. I was going through the WL Documentation about
    JNDI users and threads
    http://e-docs.bea.com/wls/docs81/jndi/jndi.html#478033
    The documentation talks about "threads" - are they talking about the WL Execute
    threads? We are not closing any of the JNDI contexts in our application, could
    this potentially result in context users being used incorrectly?
    Thanks, Krish

    http://e-docs.bea.com/wls/docs81/jndi/jndi.html#478033
    The documentation talks about "threads" - are they
    talking about the WL Execute
    threads? We are not closing any of the JNDI contexts
    in our application, could
    this potentially result in context users being used
    incorrectly?Its talking about client threads. If you have a swing app you have different threads and you need to be careful about correct association between the user and the thread.

  • Oracle Weblogic 12c F5 - Clear User Thread

    One user log into our financial system and entered a function to enter data. Did not logout, went to machine B and then log in and performed same function.
    I can see in the logs what happened, the first thread is on server01 and then on machine b she gets thread on server05.
    Unable to save on server05, so how would I clear her threads on the server....
    Thanks

    I am having the exact same issue with Weblogic 12c on Windows Server 2003 SP1 on Intel Itanium processor with Java SE 1.6u29 and JDeveloper 11.1.2.1.0.
    Please advise!
    Thanks in advance.
    P.S.
    Unfortunately, problem also confirmed on Windows 7 64bit and JRockit-jdk1.6.0_29-R28.2.0-4.1.0 and JDeveloper 11.1.2.1.0.
    LOG
    WARNING: Failed to save farm keystore. Reason {0}
    Dec 12, 2011 10:51:29 PM oracle.security.jps.internal.keystore.file.FileKeyStore
    Manager createKeyStore
    WARNING: Failed to save farm keystore. Reason {0}
    oracle.security.jps.service.keystore.KeyStoreServiceException: JPS-06513: Failed to save farm keystore. Reason at oracle.security.jps.internal.keystore.file.FileKeyStoreManager.create KeyStore(FileKeyStoreManager.java:309)
    Edited by: rade.radenkovic on Dec 12, 2011 1:53 PM

  • Number of threads in OC4J

    When I read the performance results of the oc4j there are diferent results for diferent number of threads. How can this be tuned? Is it in the xml config files?
    Thanks

    RqThrottle
    Specifies the maximum number of simultaneous request processing threads that the server can handle simultaneously per socket. Each request runs in its own thread.
    This value is adjusted on the HTTP Server>Advanced>Performance page.
    Note this value is generally associated with the web server component. There is no guarantee that a web server thread is one-to-one with a web container thread - although this seems completely plausible.
    Reggie

  • What the result while a user thread holding pidlock to sleep?

    I know pidlock is used to protect process create/exit/swap and so on. When a user kernel thread sleeps holding pidlock, the dispatcher doesn't work or system will hang? So what the real function of pidlock?
    Thanks?

    Hi, can't be sure out here, but it sounds that perhaps there may have been a hidden folder behind those other ones? Did you drag select?
    If it isn't that then perhaps som Disk/OS maintenance is in order.

  • User threads and local entity beans

    I have started a background thread to handle transferring large files via ftp. This thread needs to be able to access the entity beans via a local interface (to log its progress). I have started oc4j with -userThreads (debugger -Doc4j.userThreads=true) and I get the NameNotFoundException when trying to find the beans via a local home interface.
    The code looks like this:
    <code>
    InitialContext context = new InitialContext();
    JobLocalHome home = (JobLocalHome)context.lookup(JOB);
    JobLocal job = home.findByPrimaryKey("java:comp/env/ejb/JobLocal");
    </code>
    This code works perfectly when called from the context of another bean, but not from the background thread. Can background threads use local interfaces? Or do I have to have remote interfaces on these beans just to allow the background thread to operate?

    Hi - Resolved this one
    The Target for the compiler was set wrong in Jdeveloper!!!
    Set to "default" resolved this
    Tks

  • Are those Oracle threads "user threads" or "kernel threads"?

    Hi,
    As you know Oracle's architecture under windows OS is different from Unix/Linux and there is only one process (oracle.exe) and DBWr,LGWr and other pieces of instance implemented by threads whitin that process.
    I want to know if these threads are user mode threads or kernel mode threads?
    -Thanks

    varun81 wrote:
    OK you have said don't even think of updating these tables directly... May i know why are you saying that.Among other reasons, Oracle disallows updates to the data dictionary and you render your database unsupported as soon as you try. Plus, a lot of what needs to be updated are memory structures that Oracle happens to expose read-only views of. And the set of objects that are affected will potentially change across releases/ patches/ etc.
    Beyond that, what possible reason could you have for wanting to update dozens of objects to add a user? The CREATE USER statement is a far better interface for your application.
    Justin

  • How to terminate/destroy a user thread running in background?

    Hi All!
    I m using t.destroy() to stop a background running thread, as t.stop() is depricated in Java 2. I implement Runnable in the background thread. On calling t.destroy() NoSuchMethodException; don't know whats the problem there?

    I still don't see any solutions to the issues with performing a Runtime.exec, or stopping a thread from the outside.
    Here's my situation - I have need to make a framework that processes "work" asynchronously. Work is an abstract concept that is realized (an interface is implemented) by other classes. Work comes into the system and is persisted. A seperate mechanism gets the work and processes the work when possible.
    Processing "work" is an abstract concept that is realized (interface is implemented) by other classes.
    All the threading/asynchronous behavoir is in the framework.
    Thus I can't control how work processing occurs within the framework. At certain points I do have to be able to interrupt the work from the outside. Thus the framework threads are busy doing "work" (defined in a class not "known" to the framework) - but the framework has to shutdown.
    So I'm left with thread.stop
    Yes - the framework threads are designed around a volitile "continueProcessing" flag.
    Yes - some of the tasks can perform their work in piecemeal and use this flag.
    No - not all the work can be done in a piecemeal way.
    This whole framework is a solution to situations where multiple high-CPU, high-memory, asynchronous tasks get flooded into the app-server (we don't control the clients - they are outside this business).
    So we persist the request, and have a framework polling for more work. That way even if 10000 requests hit us as the same time (it has happened); we don't get floored.
    We tried sevlet and JMS processing, but those both have back-log limitations. We could poll for work, then send the request to a seperate JMS queue that terminates in a MDB but this exposes an entry point into work processing. And the whole point of this is to control the amount of processing occurring at any given time, without losing any of the requests.

  • Does user directory in oc4j requires entry in any XML files

    Hi All,
    I have created directory called "Sample".I have placed this directory inside web-apps in oc4j.Does this directory "Sample" requires any entry in the XML file.If so why???
    Thanks & Regards,
    Thirupathi.S

    Hi, Adam
    There are several ways that I can think of to accomplish what you want to do. The solution best fit for you depends on what you use to open a xml file.
    1. If you use basic file I/O functions to read your xml files:
    then you will need to use Search and Replace your xml string by using Regular Expression. If you do not know what it is, think of it as a advanced way to search within a text using wildcards. I really really recommend you to take some time to learn this as it helps your string manipulation in general.
    For example, if you want to remove all the xml tags like "<abc>" or "</abc>, it can be easily done by using a Search and Replace String function:
    In Search and Replace String node:
    >>input string = your xml string
    >>search string = "<[^>]*>" (do not include double quotes)
    >>replace all? = True
    (You may need to right click on the node and switch to 'Regular Expression' mode)
    2. If you use xml parser, then it is simple enough just to use "Text" method of the XML object to extract all xml tags and get a string.
    If you are using this option and have troubles doing it as you wish, let me know.
    Thanks.
    SK
    TailOfGon
    Certified LabVIEW Architect 2013

  • Classloader problem

    Hi,
    I am having a trouble while deploying two ears. I have one war file, which refers a certain java project. I have created a replica of this war file and have done some chnages so that I can have a separate set of portlets using the same code base.
    While these war files run fine when deployed separately (one ear per war), they create problem if both are run at once & I get ClassCastException. The possible reason is:
    - applicationA puts ClassA in session
    - applicationA is loaded properly
    - applicationB is trying to load, it searches for a particular attribute in session, which is available (kept by appA), and tries to type-cast it, resulting in ClassCaseException.
    My question is:
    1) What I am trying to achieve, is it do-able?
    2) If yes, why the session / context is shared among the two ear files.
    3) Does it have to do with classloader? I have changed the classloader mode to Parent_Last for all 4( both ear and both war).
    I am using RAD 6.0.1 and WPS 5.1.
    Please help. I am stuck since last two weeks :-(

    Let me try to shed some light on this:
    a) The reason why you're getting the s.o.p results you're seeing is because you're executing them from the old thread. If you were to execute the second s.o.p from the new thread without setting the class loader as suggested, you wouldn't get the same result. Just try that if you find some time.
    b) The ContextClassLoader is a "tricky" thing. It's actually a singleton mechanism that delegates the actual class loading to the appropriate class loader based on the execution context. OC4J has overloaded the mechanism of finding the right class loader based on execution context. The reason you always need to set the context class loader for new user threads in OC4J lies in the following JDK problem:
    When a new thread is created, the JDK attempts to set its context class loader to that of its "parent" (the thread that created it):
    Thread parent = currentThread();
    this.contextClassLoader = parent.contextClassLoader;
    What it should do is:
    this.contextClassLoader = parent.getContextClassLoader();
    The OC4J thread that is running (the "parent" in this case), is a subclass of Thread that has overridden the getContextClassLoader() method. That override does not return the base class field called "contextClassLoader", but does a lookup to find the correct loader. This lookup depends on other thread state. That thread state is not present on the new thread, so there is no way for the new thread to get the right loader.
    In any case, if you always follow the simple step of setting the context class loader for new threads as discussed earlier in this thread, then you should not see this issue.
    Hope this helps explain things!
    -lars

Maybe you are looking for