How to use EntityManager in a thread inside a J2EE container

Hi,
I'm looking for a usage pattern to use an EntityManager inside a thread of J2EE container. I used injection to inject an EntityManager in a EJB3 service and I can use the em with no problem. But the problem occurs when the service spin a thread and operations of the EntityManager (which is obtained using JNDI lookup ) inside that thread always fails.
What is the correct usage pattern to obtain/use an EntityManager inside a thread of a J2EE container?
Thanks.

What you are trying to do should work as long as you are using the Measurement Studio C++ classes in MStudio version 6.0 or later.
What version of Measurement Studio are you using? Could you post a simple program that demonstrates the problem?
There is a fundamental limitation in Windows that prevents you from using a Window handle (HWND) in a different thread than the one that created it. However, the Measurement Studio C++ classes (e.g. CNiGraph) are designed to automatically handle accessing the underlying handle from multiple threads. This is done through standard COM marshaling mechanisms and was implemented in version 6.0 of Measurement Studio.
David Rohacek
National Instruments

Similar Messages

  • Using JCo as an RFCServer in a J2EE Container (Threading Issue)

    Hello,
    I want to use JCo as an RFCServer in a J2EE Container
    (e.g. JBoss, BEA WLS or WAS6.40).
    Threrefore I use a the JCo.Server class
    as shown in Example5 in the JCo Examples.
    But the JCo.Server class starts a thread (JCo.ServerThread) for each Server(Listener).
    According to the J2EE specs it is not allowed
    to start (user) threads in a J2EE Container,
    because the container does the whole thread
    manangement/lifecycle.
    If JCo creates threads on its own, this might
    lead to erros. For Example: BEA WLS stores
    information in ThreadLocal variables and if you
    call a SessionBean from the JCoServer.handleRequest method
    the Container will (perhaps) fail, because the
    thread created by JCo does not have the ThreadLocals
    needed by the container.
    I know that there is the IServerThread interface in JCo,
    but I don't know how to use it in a J2EE Container.
    What is the correct way to implement a JCo Server
    in a J2EE container?
    Does anyone know a working solution of a JCo Server
    in the BEA Application Server?
    Thanks,
        Joachim

    Joachim,
    As you wrote, it may not be a good idea to use JCO.Server's inside a J2EE container; i suggest you to build an 'adapter' for this purpose.
    An adapter is a program that can listen for any type of event and, once the event has been identified (type and specific data), the adapter will handle it accordingly.
    In this case, you can create a program that starts a JCO.Server (as in Example5) and use JMS to send messages (built from the info gathered from the JCO.Function call) to a Message Driven Bean in the J2EE container.
    Hope this helps.
    RaTB

  • How to use notification with parallel thread

    Hi,
    I am learning to use Notification to communicate between thread. I still don't know how to use it. In my current project I have a case to use this so I think I should implement this technique. My example is I have a main sequence in that I make a new thread. What I want is the new thread will do a task A when receive a notfication or to exit the thread when the main sequence stop.
    I am not sure if using notification is a best practice here? Or should I use a reference data?
    What about if I want my thread to do task B if it receive another notification. Is notification still be helpful?
    Regards,
    Thang Nguyen
    Solved!
    Go to Solution.

    Hello,
    You can use Notification to handle parallel threads. I often create two sequences : one containing the process A of your example (StartProcessA). and a second one to stop this process (StopProcessA). In StartProcessA, I create a Notification, with a defined name (as string constante, "StopProcessANotifier" for instance) in the setup group. Then I have the process, in a loop. At the end of this loop, I check the Notification (Wait) with a  timeout enabled, and no error if a timeout occurs. this way, the Notification Wait can be used as loop timing, and if the notification is Set in MainSequence, this exit the loop (pick a look at Notification property Step.Result.TimeoutOccured).
    To sum up, use a first sequence call in MainSequence, calling StartProcessA, with NewThread option, and do not forget to call StopProcessA at the end of you MainSequence. The Cleanup group is a very good location, because it will be executed even in case of error.
    This is a very simple use of Notification. Note, I believe that make it simple is often the most important but also the most complicated thing to do 
    Hope this helps....
    .mrLeft{float:left} .mrInfo{border-left:solid 1px #989898;font-size:x-small;color:#989898}
    Mathieu R.  
      CTD - Certified TestStand Developer / Développeur TestStand Certifié  
      CLAD - Certified LabVIEW Associate Developer  

  • How to use j2se 1.4 logging features with j2ee 1.3

    Hi,
    We have developed an EJB that will run in the j2ee 1.3 container of weblogic 5.0
    We would like to use the logging features of j2se 1.4 in our ejb.
    Can this be done ?
    How do I install and use j2se 1.4 a long side of j2ee 1.3 ?
    Is this a recognised configuration ?
    Many Thanks,
    Mark.

    Is it possible to install j2se 1.4 on the same machine
    that is running weblogic with j2ee 1.3 ? Yes.
    If it is.... How do we do it ?Just install it in different directory - the installer will do this for you by default anyway.
    How do we protect our code running in the j2ee 1.3 container from
    mistakenly using the classes provided with j2se 1.4 ?Thats what PATH and CLASSPATH environment variables are for. Read the tutorials on the left there for more information.
    Do we end up with 2 separate VMs one a implementing
    j2ee 1.3 and one a j2se 1.4 ?You end up with as many as you run.
    Every time you run java (java.exe on windows, just plain java on UNIX) you run the version of the VM that's on your PATH.
    It's quite normal to have (on the same machine) a 1.3 VM running Weblogic and a number of 1.4 VM's as clients of that Weblogic installation.
    I think I'm right in saying that 1.4 VM's are (in some cases) regarded by BEA as supported clients of a Weblogic server running in a 1.3 VM, but you'd have to check their e-docs site for exact details.

  • How to use external library in EAR deployed onto J2EE engine

    For certain reasons some classes in .jar file in operation system level should be used in the EAR project I've deployed onto J2EE Engine.
    Can some one tell me what steps I should perform to acheive this?

    hey there,
    Think im already late for this... but it may be useful to someone who reads this forum later.
    I am struggling with exactly the same problem for the past more than 24
    odd hours now. The sad part - Im sure I have seen this being done in a
    matter of a few minutes when my team mate had an older version on NWDS.
    (I am currently using SP16 NWDS). May be this indeed is a bug that SAP
    needs to fix in its SP16 NWDS release.
    I need to use the HSSF POI libraries for my webdynpro components and
    have been trying ALL possible options given out here on SDN. To mention a
    few, I have tried -
    1) Jarrod's method of making a Java DC and then declaring a usage
    dependency for it inside a J2EE Server (library) DC. It didnt work... it
    gave me a warning that an illegal reference has been made to the runtime
    public part. And the final SDA file generated in the J2EE server
    component DC DIDNOT contain the jar files that I had added to the public part
    of the Java DC. On investigating further, I found that there were NO
    entities present in BOTH the public parts of the Java DC, even though the
    folder actually contained all the required .jar files.
    2) Creating an External Library DC, adding the JAR files to the
    'libraries' folder. Creating two public parts, one for assembly and the second
    for compilation. Then adding this DC as a 'Used DC' into a J2EE Server
    (library) DC. Yet, the .sda file that is created on building the J2ee
    Server (library) DC DOESNOT contain the JAR files.
    3) Creating an external library DC, adding the JAR files to the
    'libraries' folder. Creating two public parts, one for assembly and the second
    for compilation. Then adding this DC as a 'Used  DC' into a webdynpro
    DC. On building this webdynpro DC, the .ear file DOESNOT contain the JAR
    files.
    4) Directly adding the JAR files to my own webdynpro component in the
    'src/packages' folder. This didnt work because on rebuilding the
    project, the JAR files get deleted on their own.
    5) Renaming my .JAR files to .ZIP, extracting the entire package
    structure into folders, copy pasting this entire folder structure along with
    its .class files into the src/packages folder. On rebuilding, the NWDS
    deletes these folders and files on its own / behaves erratically. Also
    copy pasted these .class files along with the proper package structure
    into the '/bin' directory of my webdynpro application, but it still
    didnt work.
    The only thing that I have to try yet is to shift to SP10 of NWDS,
    build this external library project and get the required JAR files put on
    the wendynpro server. After that I might choose to get back onto the
    SP16 version and hopefully continue productive work... !
    Regards,
    Navneet.

  • How to use Wait Screen and Thread?

    Greetings,
    I was wondering If I could ask a question...
    Here it goes:
    How can I use a Wait Screen in a MIDlet so that I can do the Following:
    1.- Create and Open an Http Connection[b[i]](using an Object which extends Thread) in a Form by pressing an OKCommand.
    2 .- Show the Wait Screen Until the Thread Object finishes execution(finishes whatever is inside run() method)
    3.- Finally show the Result(s) of the Connection(bytes obtained from URL) in another Form.
    First of all, Is what I ask even possible? and more importantly...
    Can a Wait Screen actually Detect when a Thread finished execution? so that only when the thread finishes the program proceeds to the next statement?
    Thank you very much in advance!
    Sincerely, your friend,
    Jose

    Thank you very much Sir, I suppose that narrows it down a bit,
    Because I definitely need my applications as standard as possible.
    But good to know there's a way to do it.
    Well, Thank you very much as usual!
    Sincerely,
    Keep up with the fantastic job you do every day!
    God Bless.
    J

  • How to use select a vi function inside a loop?

    I am modifying the notifier basics part 2.vi to send a notifier to each of 64 sub-vi's. How can you use the 'select a vi' function inside a loop for 64 iterations to access the individual filenames??
    Attachments:
    Notifier_BASICS_Part_2.vi ‏87 KB

    If all you are trying to do is send notifiers to each of these 64 subVIs, I would suggest not doing it in a loop, but rather just placing the 64 subVIs in your diagram.
    The alternative is of course to use the call by reference node and have an array of VI names. This is a little cleaner on the diagram, but 1) doesn't occur in parallel and 2) is a bit tricky. Additionally, you have to be sure that your array of filenames is correct, and that you NEVER move or rename those VIs. Of course, you could always put them in a directory and create an array by reading the directory contents.
    Either way, good luck, it doesn't sound like fun.

  • How to use the google search from inside a java program

    Hi guys
    How can i use google search in my java program?
    What will be the type of the reply i get back from google?
    Thanks in advance
    [http://javamilestone.blogspot.com/|http://javamilestone.blogspot.com/]

    Hi,
    You have here some examples about how to make search on google from a Java application.
    The type of reply is JSON
    Here some documentation about it:
    [http://code.google.com/apis/ajaxsearch/documentation/#fonje|http://code.google.com/apis/ajaxsearch/documentation/#fonje]
    And here some snippets:
    [http://code.google.com/apis/ajaxsearch/documentation/#fonje_snippets|http://code.google.com/apis/ajaxsearch/documentation/#fonje_snippets]
    Regards,
    David.

  • How to use the sleep and thread?

    I'm coding a program to move a player on the screen,
    but the program directly run to the end,
    the animation part dose not display,
    how can i modify my code to show the movement of the player?
    here is the run function,
    Thread t, w;
    public void run() {
         while (isClick) {
              try {
                   repaint();
                   t.sleep(500);
                   int j = playerStep + 40;
                   while(playerStep < j) {
                        try {
                             playerStep += 10;
                             repaint();
                             w.sleep(300);
                        } catch (InterruptedException err) {
                             JOptionPane.showMessageDialog(null, "Moving error!");
              } catch (InterruptedException err) {
                   JOptionPane.showMessageDialog(null, "Drawing error!");
              isClick = false;
              repaint();
    }Thanks a lot.

    what is the value of isClick variable when your program is starting?

  • Spawning Threads inside the Web Container

    What are the ramifications of a developer spawning off threads from a "helper"
    object called from a servlet service() method ?
    Thanks in advance.

    That's what I said, it is not at all advisable but if you know what you
    are doing it can work just fine.
    The biggest issue is migration since the behavior is not defined in the
    spec and thus all vendors can implement it differently and it can change
    from version to version, which in turn defeats the J2EE portability
    advantage.
    That is why I highly recommended using JMX timers since it is going to
    be available on all J2EE servers and then the only vendor dependent
    thing is to get the MBeanServer.
    Dejan
    DN wrote:
    Hello
    I was also doing the same thing from my servlet but using another class which
    extends thread.
    I was using JDBC calls in the new thread , eventhough it worked fine I was getting
    warning messages in the console when I was using WSAD.(websphere studio).
    My app is deployed to WLS , i did not see any messages in WLS.
    When I post this issue in a forum , some one advised me that it is not advisable
    to open up threads from the servlets and this is what he said 'quote'
    so eventually (i.e.
    J2EE 1.4) spun threads from a Servlet accessing a
    database outside of a transaction will not be
    supported either.
    "Deyan D. Bektchiev" <[email protected]> wrote:
    Whit,
    If you are not careful you can very well starve the JVM, lose your
    security, transaction contexts and probably some other bad things I
    don't know about...
    But having said all those scary things, I must admit that we do it all
    the time and don't have any issues with that.
    For most purposes you should try to use the JMX timer service instead
    of
    spawning your own threads. You callback will be called in a different
    thread from the Weblogic thread pool and I guess this will be sufficient
    for most cases.
    Regards,
    Dejan
    Whit Armstrong wrote:
    What are the ramifications of a developer spawning off threads from
    a "helper"
    object called from a servlet service() method ?
    Thanks in advance.

  • How to use a update statement which has a string containing '&' -  Pls help

    When used the following select statment in SQL plus it is working fine:
    SELECT * FROM REDEMPTION_OFFERS
    WHERE portfolio=203 AND display_description= '$100 Bed Bath'||' & '||'Beyond Gift Card' AND ext_redemption_type_lc = 'ERT_CERT'
    But when using the same statement in a Update statement it is not working. Can some one please help me: Thanks in advance
    UPDATE REDEMPTION_OFFERS SET LONG_DESCRIPTION = 'null'
    WHERE portfolio=203 AND display_description= '$100 Bed Bath'||' & '||'Beyond Gift Card' AND ext_redemption_type_lc = 'ERT_CERT'

    When used the following select statment in SQL plus
    it is working fine:
    SELECT * FROM REDEMPTION_OFFERS
    WHERE portfolio=203 AND display_description= '$100
    Bed Bath'||' & '||'Beyond Gift Card' AND
    ext_redemption_type_lc = 'ERT_CERT'
    But when using the same statement in a Update
    statement it is not working. Can some one please
    help me: Thanks in advance
    UPDATE REDEMPTION_OFFERS SET LONG_DESCRIPTION =
    'null'
    WHERE portfolio=203 AND display_description= '$100
    Bed Bath'||' & '||'Beyond Gift Card' AND
    ext_redemption_type_lc = 'ERT_CERT'looks like You are using the UPDATE statement in SQL*PLUS too. Your statement is also working....
    SQL> select * from a;
            F1 F2        F3
             1           BED BATH
             2           BED BATH
             5           BED BATH
             3           BED BATH
            -2           BED BATH
            -4           BED BATH
            -1           BED BATH
    7 rows selected.
    SQL> update a set f3 = 'BED '||'&'||' BATH';
    7 rows updated.
    SQL> select * from a;
            F1 F2        F3
             1           BED & BATH
             2           BED & BATH
             5           BED & BATH
             3           BED & BATH
            -2           BED & BATH
            -4           BED & BATH
            -1           BED & BATH
    7 rows selected.

  • Java.util.concurrent.ExecutorService inside J2EE Container

    I want to use the JDK 1.5 concurrency class ExecutorService for concurrent execution of data-access logic inside my oc4j web-application.
    I'm using the Factory Executors.newFixedThreadPool(6) for creating a thread-pool.
    I know that it's not a good practice to create new threads inside a j2ee container.
    Is there anything I have to think of or beware of??
    Perhaps anybody here has experience using the java.util.concurrent.Executor inside OC4J or an other j2ee container.
    Thanks, Harald

    Yes, I have used java.util.concurrent.Executor in weblogic 10 server.
    You can really improve the performance of the EJB application if you use the thread pool carefully with limited size say 100 threads, by creating a single instance of thread pool for the whole J2EE application.
    You have to control the life cycle of thread pool using the container's life cycle methods, create the thread pool only once and destroy every time you recycle your app.
    Good luck with the implementation :)

  • How to use Direct Access URL in the FORM tag

    I want to substitute the pageid url (/servlet/page?_pageid=161&_dad=portal30&_schema=PORTAL30) with the direct access urls (pls/portal30/url/page/my_page) to address the pageid conflict between development server and production server.
    It works perfectly fine in the redirection code such as:
    self.location.href="/pls/portal30/url/page/next_page". But I got "Page can not be found" error message when I use it in the <FORM> tag:
    <FORM ACTION="/pls/portal30/url/page/next_page" METHOD="POST" NAME="my_form">
    Does anyone out there know how to use the direct access url inside the <FORM> tag? I am trying not to write a bunch of code just to retrieve and insert the pageid at the run time.
    Thanks in advance.
    Arthur

    Use condition. If you are validating a record, just out the desired check in the condition field for that specific item.
    Thanks
    Nagamohan

  • How to use the "Flash Field"?

    Hi Everyone,
    I'm trying to figure out how to use the new "Flash Field" inside my form.
    The form we are working on required the user to interact with the "Flash Field" (i.e., click on the bar on a bar-chart) and the "Flash Field" should return some value (defined in the Flash logic) should be returned to the host (the PDF form) as the FlashField.rawValue, for example.
    BTW: The SWF object that is consumed by the "Flash Field" is built by the Flash Builder latest edition (4.5). So we do have a total control on the logic inside the SWF project.
    The Q here is: What is the possibility to modify my code inside my Flash project so it can expose the SWF object computed value to the rawValue property of the Flash Field?
    Appreciating your collaboration....
    BR,
    Yasser

    Hi,
    Have a look at the Flash object Reference Card and the Flash object examples here: http://assure.ly/rqCuEn.
    Hope that helps,
    Niall

  • How to use the BAPI BAPI_ALM_ORDER_MAINTAIN

    HI experts,
    I am using BAPI_ALM_ORDER_MAINTAIN to update the Object list in ECC 6.0 for a service order txn code IE31.
    I dont know how to use this BAPI_ALM_ORDER_MAINTAIN for object list updation.
    It will be very helpful if anyone who worked on this or know about BAPI_ALM_ORDER_MAINTAIN how to use, plz reply this thread.
    I am really searching for along time about the bapi, but couldnt getany thing.
    the doc of BAPI_ALM_ORDER_MAINTAIN is very vague, that i m not able to understand.
    So, sap persons, plz reply this thread,
    Ntk

    Friends,
    I am getting the following message with the FM BAPI_ALM_ORDER_MAINTAIN,  "Order  is changed, but not created".
    But when i see the Service Order, im not able to see the new equipments added in the Object tab.
    Here is my code...
    DATA: l_alm_bapi TYPE c,
          T_METHODS TYPE STANDARD TABLE OF bapi_alm_order_method,
          ls_methodS TYPE bapi_alm_order_method,
          LS_OBJ type bapi_alm_order_objectlist,
          lt_OBJ type standard table of bapi_alm_order_objectlist,
          lt_operation
             TYPE STANDARD TABLE OF bapi_alm_order_objectlist,
          ls_operation TYPE bapi_alm_order_objectlist,
          lt_oBJ_up
             TYPE STANDARD TABLE OF bapi_alm_order_olist_up,
          ls_oBJ_up TYPE bapi_alm_order_olist_up,
          lt_return TYPE STANDARD TABLE OF bapiret2,
                lt_return1 like BAPIRET2,
          ls_return TYPE bapiret2,
          LS_NUMBERS TYPE   BAPI_ALM_NUMBERS,
         T_NUMBERS TYPE STANDARD TABLE OF BAPI_ALM_NUMBERS.
    CLEAR T_METHODS.
    LS_METHODS-REFNUMBER = 1.
    LS_METHODS-OBJECTTYPE = ''.
    LS_METHODS-METHOD = 'SAVE'.
    LS_METHODS-OBJECTKEY = '%00000000001'..
    APPEND LS_METHODS TO T_METHODS.
    LS_METHODS-REFNUMBER = 1.
    LS_METHODS-OBJECTTYPE = 'OBJECTLIST'.
    LS_METHODS-METHOD = 'CHANGE'.
    LS_METHODS-OBJECTKEY = '%00000000001'..
    APPEND  LS_METHODS TO T_METHODS.
    CLEAR T_NUMBERS.
    LS_NUMBERS-AUFNR_IN = '000004010558'..
    APPEND LS_NUMBERS TO  T_NUMBERS.
    LS_OBJ-COUNTER = 1.
    LS_OBJ-FUNCT_LOC = '5619'.
    LS_OBJ-EQUIPMENT = '0000010000292'.
    LS_OBJ-SORTFIELD = 'X'.
    ls_oBJ-PROCESSING_IND = 'X'.
    ls_oBJ-SERIALNO = ''.
    ls_oBJ-SERMAT = '0010-30000'.
    ls_oBJ-DESCRIPTN = 'MAIN UNIT DR300'.
    APPEND LS_OBJ TO LT_OBJ.
    LS_OBJ_UP-SORTFIELD = 'X'.
    LS_OBJ_UP-PROCESSING_IND = 'X'.
    APPEND LS_OBJ_UP TO LT_OBJ_UP.
    CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
      TABLES
        IT_METHODS              = T_METHODS
      IT_HEADER               =
      IT_HEADER_UP            =
      IT_HEADER_SRV           =
      IT_HEADER_SRV_UP        =
      IT_USERSTATUS           =
      IT_PARTNER              =
      IT_PARTNER_UP           =
      IT_OPERATION            =
      IT_OPERATION_UP         =
      IT_RELATION             =
      IT_RELATION_UP          =
      IT_COMPONENT            =
      IT_COMPONENT_UP         =
       IT_OBJECTLIST           = LT_OBJ
       IT_OBJECTLIST_UP        = LT_OBJ_UP
      IT_OLIST_RELATION       =
      IT_TEXT                 =
      IT_TEXT_LINES           =
      IT_SRULE                =
      IT_SRULE_UP             =
      IT_TASKLISTS            =
      EXTENSION_IN            =
       RETURN                  = LT_RETURN
       ET_NUMBERS              = T_NUMBERS.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT =
    IMPORTING
    RETURN = lt_return1.
    Kindly help me out anyone who has worked with these FM. I am not able to do this.

Maybe you are looking for

  • IPhone G3 Battery and Performance Issues

    I have a 16GB iPhone G3 (OS 3.1.2). It's only about 6 months old though it is the 4th iPhone G3 I've had since Sept '08. The others have been replaced by Apple for battery failure, modem failure and inability to stay 'connected' to a charging device

  • Auto trigger of Purchase requsitions in Sales Order in case of Third party

    Hi, In a third party sales scenario, where do we set the automatic creation of Purchase requsitions when we create a third party sales order. I checked the Item category configuartion but couldn't figure it out anywhere.

  • Panels to be displayed when clicking on a button: general question

    Hi there, I want to design a GUI that will look something like: | | | | | | | | | | | | | | | | | | | | | | | A | B | C | D | E | F | That should be two panels: - bottom panel: just a some buttons (A, B, C...) - top panel: to start with, it'll be emp

  • Debugging JSPs and inspecting variables

    I've got the debugger running in a jsp, the breakpoints trigger but I can't inspect/watch/view any variables - it just prints up a question mark. This makes the debugger a bit pointless. I used to be able to see them, and I've looked all through the

  • Getting Videos shot into FCE

    So i have watched the Tutorial DVD and it didn't help, or maybe i just can't find it, but i can get my raw film into FCE from the camera. Do i need to change the setup to somthing like NTSC Firewire or what? I am using a DV in/out cable to go straigh