How to use JPA in a worker thread?

I'm using WebLogic 10.3.5.0 with JPA 2.0 and have the following scenario:
- user needs to start a task takes some time to complete;
- this task needs to read and write to DB;
One solution would be to write a worker and use the WorkManager feature to start this from an session EJB.
How should I use JPA from this worker to access the DB in a transactional manner?

You should be able to use it as normal.
Your worker class is probably not injected like your SessionBean, so you would either need to pass the EntityManager, or look it up either through JNDI if container managed, or Persistence if application managed.
For transactions, you either need to use JTA directly if using JTA, or use JPA transactions if using RESOURCE_LOCAL.

Similar Messages

  • How to use employee Skills in work center

    Dear PP Gurus,
    How can I map various skills employee in on work center? Example a work center consist of 10 work men out of which 4 are highly skilled, 3 are skilled and 3 are semi skilled. How can I map this in one work cnetr and use for capacity planning?
    Regards,
    PPQMUSER

    HI,
    do like this.
    define, 2 work centers one for skilled and other for unskilled.
    classify them and mention the values as skilled and unskilled.
    now, classify the operation of the routing and give values as skilled and unskilled for work center class type 19.
    and also, in IMG or workcenter settings, select work center until release.
    now, you create production order, (which contains either skilled or unskilled workcenter) you do capacity levelling.
    in the meantime, even if someone wants to release, he cannot do that until you confirm the resource to use.
    now, according to your capacity levelling you can choose the corresponding workcenter. classification helps you in choosing it.
    and release the production order.
    hope this helps.
    thanks,
    regards,
    sandeep

  • How to use ImageContr​ol on another thread out main

    Hi All,
    I'm looking to use ImageControl (ImageControl.fp) on another thread out main thread 
    In my second thread i try to update image but i have a error (This panel operation can be performed (if a top-level panel) only in the thread in which the panel was created, or (if a child panel) only in the thread in which the top-level parent panel was created.)
    Here my code
    Main thread :
    ImageControl_ConvertFromDecoration (panelHandle, PANEL_IMAGECTRL, 0);
    ImageControl_SetZoomToFit (panelHandle, PANEL_IMAGECTRL, 1);
    ImageControl_SetAttribute (panelHandle, PANEL_IMAGECTRL, ATTR_IMAGECTRL_SHOW_SCROLLBARS, 0);
     hdleThread = CreateThread(NULL, 0,  (LPTHREAD_START_ROUTINE) ThreadTest,  NULL,  0, &idThread);
    Secand thread :
    int ThreadTest (void * data)
    ImageControl_SetZoomToFit (panelHandle, PANEL_IMAGECTRL, 1);
    iIdError  =    ImageControl_SetAttribute (panelHandle, PANEL_IMAGECTRL, ATTR_IMAGECTRL_IMAGE, imageToDisplay);
    // iIdError  = -129
    Could you help me ?
    Thankyou

    many thanks.  I should have thought of the need for using the Target Display Mode. 
    tony

  • How to use the validation work in Both TAB and Mouse keys in Forms6i

    Hi,
    I have a validation script once it's validated it should execute the query.But using When-Validate-Item i can't use execute_query.I am able to use the validation in Key-Next-Item trigger but if the user moves the cursor using mouse then it's not working.
    How to use the validation script working in Both Scenarios(Tab and Mouse keys).
    Can anyone please give inputs to rectify the above issue?.

    So you have multiple fields, but on at least one of them if it's valid you immediately want to execute the query?
    You could create a hidden field in a control block Query_Now default 'N'. In a WHEN-VALIDATE-ITEM on your item, if it's determined to be valid, then set Query_Now to 'Y'.
    In a WHEN-NEW-ITEM-INSTANCE at block level, check if Query_Now is 'Y'. If it is then execute the query (and set it back to 'N').

  • Why can't i use JPA?

    i am using Eclipse. i installed Java EE 1.6.24.
    However, i cannot access: javax.persistence.*, it doesn't even show up in content assist. i realized this could be an Eclipse thing, but does anyone have anything else i can check?
    should i go look in the actual java jar file and see if the package exists?
    any help is appreciated....

    Kayaman wrote:
    pedron wrote:
    in Eclipse the entire API is (usually) available and ready for import. However, for me the entire javax.persistence.* is NOT available at all. Since when? Also what do you consider "the entire API"?
    All my projects have a suitable library in the project path (usually with the source code or at least the javadoc attached). Which library does your project have?Look, like i said, i'm new to this, that's why i came to the forum to ask the question. i've used a bunch of different stuff in Eclipse. I know about importing jars, libraries, all that stuff.
    However, i've googled how to use JPA and it says that it's part of Java EE 6, which i've installed and am now using in Eclipse as my active JRE. (I've been using 1.6 for awhile, but i just installed 1.6.24.)
    As far as i have seen in my, albeit limited, experience, is that libraries that are said to be in the Java EE 6 (like, for instance, annotations) are just there, with no special library import. I can get content assist to find, for instance, javax.annotation.*, but not javax.persistence.*, and that's where i'm confused.
    So, maybe i don't know libraries very well, that's fine. But i've never seen it said anywhere that i've read that i need to import some special library to run JPA. Is this the case? I'm not trying to burden the forum. i've done some research and am looking to find what i'm lacking in information. the snide comments don't help anyone... (not yours)
    thanks

  • How to find Number of working threads using java executor framework

    I'm creating a java thread pool using java 1.5 executor framework.
    private ExecutorService executorService = Executors.newFixedThreadPool(threadPoolSize);
    public <T> Future<T> submit(Callable<T> task) {
              return executorService.submit(task);
    }Now I want to get the number of working thread at runtime. Is there any java api available to do this using java 1.5 executor framework?
    Thanks,
    Arpan

    If the ExecutorService you are working on is a ThreadPoolExecutor then you can use ThreadPoolExecutor#getActiveCount() to get the count of threads actually running tasks. There is no such method on the ExecutorService interface though.

  • How can I use a Selector in a thread safe way?

    Hello,
    I'm using a server socket with a java.nio.channels.Selector contemporarily by 3 different threads (this number may change in the future).
    From the javadoc: Selectors are themselves safe for use by multiple concurrent threads; their key sets, however, are not.
    Following this advise, I wrote code in this way:
             List keys = new LinkedList(); //private key list for each thread
             while (true) {
              keys.clear();
              synchronized(selector) {
                  int num = selector.select();
                  if (num == 0)
                   continue;
                  Set selectedKeys = selector.selectedKeys();
                  //I expected this code to produce disjoint key sets on each thread...
                  keys.addAll(selectedKeys);
                  selectedKeys.clear();
              Iterator it = keys.iterator();
              while (it.hasNext()) {
                  SelectionKey key = (SelectionKey) it.next();
                  if ((key.readyOps() & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT) {
                   Socket s = serverSocket.accept();
                   SocketChannel sc = s.getChannel();
                   sc.configureBlocking( false );
                   sc.register( selector, SelectionKey.OP_READ );
                  } else if ((key.readyOps() & SelectionKey.OP_READ) == SelectionKey.OP_READ) {
    //.....Unfortunately synchronizing on the selector didn't have the effect I expected. When another thread select()s, it sees the same key list as the other thread that select()ed previously. When control arrives to serverSocket.accept(), one thread goes ahead and the other two catch an IllegalBlockingModeException.
    I'm not willing to handle this exception, the right thing to do is giving disjoint key sets to each thread. How can I achieve this goal?
    Thanks in advance

    A single thread won't be enough cause after reading data from the socket I do some processing on it that may take long.So despatch that processing to a separate thread.
    Most of this processing is I/O boundI/O bound on the socket? or something else? If it's I/O bound on the socket that's even more of a reason to use a single thread.
    Anyway I think I'll use a single thread with the selector, put incoming data in a queue and let other 2 or 3 threads read from it.Precisely. Ditto outbound data.
    Thanks for your replies. But I'm still curious: why is a selector thread safe if it can't be used with multiple threads because of it's semantics?It can, but there are synchronization issues to overcome (with Selector.wakeup()), and generally the cost of solving these is much higher than the cost of a single-threaded selector solution with worker threads for the application processing.

  • How to use multiple threads and swing for displaying status/interaction

    I have a Swing-app which have to show progress and allow userinteraction for these tasks:
    * First:
    retrieve a list of IDs(String) from the database (single thread running)
    * Second:
    some work on the id-list and list written to hd (same thread as above)
    * Third:
    retrieve Objects (based on the id-list) from different sources (Multiple Threads are running)
    To show the status I have a JProgressBar (indeterminate while task1&2 running) and
    a JTextArea showing the current status (connect,retrieve list, sort, ...)
    When task3 is starting the JTextArea have to disappear and be replaced by a ScrollPane
    with an array of Labels/TextAreas showing the status of each thread.
    While theses threads are working, the ID-list will be consumed and the JProgressBar
    shows the remaining precentage of the hole progress.
    Everything is working so far (excepts UI :) , the problem(s) I have:
    I need the threads to interacts with the user through the ui. e.g: "Connection to db-xyz lost! reconnect?"
    But I don&#180;t know how to do this correctly.
    I think one way would be to send an event to the ui... but how?
    (the ui must know which thread is calling to unpause it after user answered)
    I know that threads should NOT change the swing(-container) - How do I notify the ui that a thread has a question?
    Since these threads are really time-consuming the UI is not updated frequently,
    how can I increase this? (perhaps using another thread-priority?)
    thanks for help!

    if/when your threads need to interact with the UI, they can create a Runnable & send it to SwingUtilities.invokeLater or invokeAndWait. This Runnable can popup a message to the user, and act on the choice of the user (reconnect, cancel, ...). This action could be something which "unpauses" the task thread.
    You may need to do synchronisation between the code in the Runnable & the Thread to which it is related - so the latter Thread knows when the user has made the choice.

  • How to increase the number of HTTP Worker Threads?

    Hi Buddy,
    I am using the lateset NW AS Java. It's a DEV system and the number of HTTP Worker Threads is 5.
    Do you know how to increase the number?
    What is the number in a Production System?
    Thank you!

    Parameter name: FCAServerThreadCount
    It's under Service->http.
    Use config tool for NW70.
    For NW71 and above use NWA and config tool.
    Also refer this -
    http://wiki.sdn.sap.com/wiki/display/JSTSG/%28JSTSG%29%28Web%29FAQ-FCAServerThreadCount

  • I cannot get the edge dection tool to work i use to use it all the time but now i can't, how do i get it to work?

    I use to use the edge detection tool all the time but now I can't, how do I get it to work again.  When I try to use it, it will show the o with the line in side.

    A lot more information about your hardware and software is needed.
    BOILERPLATE TEXT:
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CC", but something like CC2014.v.2.2) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    a screen shot of your settings or of the image could be very helpful too,
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • Using worker threads in a Servlet

    Hello friends.
    I am hoping for a sanity check on a design decision I am considering. I have a Servlet that implements a web service that generates an XML document on demand. Depending on the request, the servlet will assemble the XML document from a number of external web services. I guess its somewhat like a mashup.
    I am seeing some significant performance issues doing the external web service requests synchronously. So I am considering using some kind of ThreadPool collect all my data from the web services. Once all the data is available, I will assemble my XML document and return the Response from the Servlet.
    I would appreciate any comments or feedback on this approach. Specifically:
    - Are there any concerns in using a ThreadPool of some kind within a Servlet? I know the Servlet container is multi-threaded, so I guess the ThreadPool would be shared across all threads. Or I suppose I could have a thread local instance of a thread pool. Thoughts?
    - I am using Tomcat 6 as my Servlet container. Any issues with this approach on that container?
    - I have done a lot of multi-threaded programming in the past, but have not used anything from the java.util.concurrency package yet. Are there any classes in this package that might help with my approach? Any other resources worth checking out?
    Thank you all for your help.
    Jeff

    Thanks sjasja.
    I definitely think I should use a ThreadPool. For me its not about how many threads can be created then destroyed in 1 second, its how many simultaneous threads can run at once. I am using Tomcat servlet container, with the default configuration of 200 maxThreads. If my application gets a heavy load and each of those threads creates 50 worker threads, I am going to reach an OutOfMemoryException for sure.
    My only concern is that if all 200 Tomcat threads really are being used, will most of the worker threads jobs spend too much time waiting in the ThreadPool queue? I guess that will have to just take some testing to find the optimal number of threadpool threads.
    Thanks for your additional thoughts.
    Jeff

  • How do I troubleshoot installation/distribution of a LabVIEW .exe which processes data using Matlab when it works on some computers but not others?

    I've been given the unenviable task of troubleshooting and installing/distributing software written by a former co-worker. I've modified the LabVIEW code and built an .exe file. I've successfully installed the Labview .exe file on several computers, but it won't work on some others. What's more baffling is that I installed it successfully on one computer, uninstalled it, and tried reinstalling it with no success. In fact, it's a new error (Dr. Watson for Windows NT application error). It doesn't help that I have different versions of LabVIEW and Matlab on the target computers. Some have LabVIEW 5.1, some
    have 5.0, and some don't have it at all. Some have Matlab 5.2, some have 5.3 (R11) and some have 6.0 (R12). It's also not clear to me where the Matlab m files should be located. I'm not sure if it's a LabVIEW Runtime Engine problem, or if it's a Matlab problem. I've also wondered how LabVIEW and Matlab talk to each other. When LabVIEW calls Matlab, it seems that Matlab is running in the background. In other words, clicking on the Matlab Command Window and typing "whos" or any other command/variable doesn't work.

    Jay del Rosario wrote:
    >
    > How do I troubleshoot installation/distribution of a LabVIEW .exe
    > which processes data using Matlab when it works on some computers but
    > not others?
    Poke around zone.ni.com and
    http://digital.natinst.com/public.nsf/$$Search/ .
    Good luck, Mark

  • I am trying to open a website that is using Microsoft content viewer, and the page does not show. Any ideas on how to view this site using firefox. It works on IE.

    I am participating in an online class whose website uses Microsoft Content Viewer to view the class content. The browser opens a new page, but nothing is there. At the top of the tab it says Microsoft Content Viewer, and nothing else. Can anyone tell me how to view my course using Firefox? I would prefer not to use IE, but it works there.

    When originally creating the pdf, you would need to choose another pdf conversion setting. In Word if you use the pdf menu, change your settings there: Adobe PDF > Change Conversion Settings. I would use High Quality Print instead. If you use the File > Print method, click the Properties button next to the Adobe PDF printer selection.
    For your already created form, you can change the file so your users will not encounter issues. In Acrobat 9, which hopefully is similar in process to 8: Advanced > Preflight > Profile tab > PDF/A compliance > Remove PDF/A information.(You'll have to unsecure your form first).
    You can read about PDF/A files in the Help.

  • Okay so I set up my Time Capsule already and is now backing up 2 of my iMacs. Works great. What I want to know is how to use the TC to directly store files? I want to do this to delete some files but still have them on the TC for future reference..

    Okay so I set up my Time Capsule already and is now backing up 2 of my iMacs. Works great. What I want to know is how to use the TC to directly store files? I want to do this to delete some files on iMac 20inch but still have them on the TC for future reference..eg some movies on iTunes. I want to directly save them on the drive so I can delete them from iTunes and gain some storage. (Ps on iMac 20 inch (it's almost full - 320 GB) when I enter time machine, a tab comes up on finder which reads "Time Machine backups" it's able to be ejected like a disc or a connected device. On the iMac 20 inch, I dragged some files onto there as if using it like a hard drive. Is this the correct method? Then I went to my 27inch iMac and saw the "Time Machine Backups" hoping to see the files I dragged from the 20inch iMac. But the files were not there except a folder that said "Backups.backupdb". Can someone help me?

    It's not a good idea to use a network disk for both Time Machine backups and other things.  By design Time Machine will eventually consume all the space on its output disk, which will then cause problem for your other files.  I'd store those other files on an external disk connected to the Time Capsule.  The problem with that is that Time Machine will only back up files that are local to your Mac.  That means that you'll only have one copy of the files on or attached to your Time Capsule.
    By the way, you've been misled by poor field labeling on this forum into typing a large part of your message into the field intended for the subject.  In the future just type a short summary of your post into that field and type the whole message into the field below that.

  • I am on windows 8 platform, i used adobe elements to work on my image - the output is in dng format, how do i convert this to jpg format?

    i am on windows 8 platform, i used adobe elements to work on my image - the output is in dng format, how do i convert this to jpg format?

    When you make a DNG that's like making another raw file, so you will need to convert the DNG file just like your original raw. Don't use the Save button in the raw converter. That's just a link to the DNG converter. Normally you would click Open instead and then save in the editor as a jpg or other image format of your choice.

Maybe you are looking for

  • Wireless module not working(70​1)

    Hello, i recently formatted my laptop and then i  found that at startup my laptop is saying Wireless module not found(701) It says it may be not installed correctly or not functioning. So i disassembled my laptop to see any connection problem and tri

  • Lumia 520 volume

    Hi, i am using Lumia 520 with Windows 8.1 software, currently i am facing problem in volume if i play music i cant able to listen but  music  can listen  in headphone, surprise is in FM i can play the music in Loudspeaker even i am getting calls, all

  • Programme RM06INP0 is NOT updaing Net price value at in ME13 screen in ECC

    Hi Experts , We are on  ECC 6.04 with SRM 7. We are using PIR as one of the SoS in Shopping cart in Classic scenario. When we are running the programme RM06INP0 in ECC in foreground /background to update the Net price field ( NETPR), but  it is only

  • Protect the Trash with password !

    Hi everyone, Can anyone tell me if there is a way to password protect my trash can so nobody can delete files from my pc without me there if i forgot lock my mac. I've looked everywhere and found nothing. But there must be away. Please it's so import

  • "RAM Preview needs 2 or more frames" CS6 on CC and CC 2014

    The message "" RAM Preview needs 2 or more frames "'is appearing in all software is tested CS6, CC and CC2014. Retina I'm using a Macbook (OS X Maverics) brand new, the error appears right after about 10 minutes of use, and just back to work after re