JPA: How do I get an EntityManager into a javabean

I have a javabean in a web app and I am trying to get an EntityManger but I don't think I can use resource injection. My web app is in an EAR file and my persistence unit is in a jar file that is also in the EAR file. Using the Persistence.createEntityManagerFactory doesn't work perhaps because it is only looking for a classpath?
Any ideas?
thanks,
Peter

Hey it is actually an Oracle Web Service not a Java Bean (sorry new code). But it is packaged as a war file so I added this to the web xml:
<persistence-context-ref>
          <persistence-context-ref-name>
               myEM
          </persistence-context-ref-name>
          <persistence-unit-name>VISIT_IDSM</persistence-unit-name>
     </persistence-context-ref>
on this line:
em = (EntityManager) new InitialContext().lookup("java:comp/env/myEM");
it throws this error:
08/06/04 15:58:00 com.evermind.server.ejb.exception.DeploymentException: [VIPS:vips-whit-rqs-ws-1.3-b1-001-SNAPSHOT
] - Unknown persistence unit with name "VISIT_IDSM".
looks like it still can't find that persistence unit. Both my war file and persistence jar file are packaged in an EAR file
let me know if you need any more info.
Peter

Similar Messages

Maybe you are looking for

  • Windows domain controller in a virtual machine: how dangerous is saving its state for a short period of time?

    I have a Windows Server 2012 R2 virtualization cluster. All the hosts are connected to an external storage system, and virtual machines' files are stored on external volumes (CSVs). All the hosts and virtual machines are a part of the same AD domain

  • How to install Studio, DataTools, SSIS and SSAS to SQL Server 2014 RTM DataWarehousing

    I have fresh installation of VM. Plan is to build DW and SSAS OLAP Cube. How to install needed services and tools as they are not installed as default? If I click SQL Server Installation Center and choose Installation and New SQL Server, I'm guided t

  • Alert for VM CPU percentage remain "Not activated"

    We created an alert rule for the CPU percentage of a VM with a low threshold (10%) for testing. The threshold was exceeded for several minutes - longer than the alert evaluation window. The rule was enabled, of course. However, there was neither an e

  • Cannot start photoshop

    Everytime I try to start photoshop, I get an error that the scrartch disks are full. I have 2 1 TB hard disks in raid 0. They are definatly not full! I tried crtl-shift-alt and deleted the presets, but get the same error. I am running win 7 64 bit!

  • Manugisitc Adapter

    Hello: Is there anyone using SAP-Manugistic Adapters for XI? or if anyone is interfacing with Manugistics from/to SAP, is the connection mostly with JDBC comm channels? Thanks George