NullPointerException at EJB-Relationship

Hi:
I'm trying to create a relationship between to CMP 2.0 entites using JDeveloper.
It's a unidirectional One-to-Many relation between Car-producer and Car-typs.
The car-type-bean has the producer number as a foreign key.
I have generated the EJB'S with UML class diagramm.
There is a Session Bean Interface with a local reference to the Entity Beans.
If I test my Session Bean with the Oracle9i JDeveloper's Embedded Oracle9iAS J2EE Server there
is a NullPointerException after deploying the Beans.
Note: There is no error if I have only Session Bean with one Entity Bean without any relationships.
the log-File is :
D:\jdeveloper\jdk\bin\javaw.exe -ojvm -classpath D:\jdeveloper\j2ee\home\oc4j.jar -Xverify:none -Doracle.j2ee.dont.use.memory.archive=true
com.evermind.server.OC4JServer -config D:\jdeveloper\jdev\system9.0.3.1.1107\oc4j-config\server.xml
[Starting OC4J using the following ports: HTTP=8992, RMI=23892, JMS=9231.]
[waiting for the server to complete its initialization...]
Embedded OC4J startup time: 2464 ms.
Copying default deployment descriptor from archive at D:\jdeveloper\jdev\mywork\Workspace1\Project1\classes/META-INF/orion-ejb-jar.xml
to deployment directory D:\jdeveloper\jdev\system9.0.3.1.1107\oc4j-config\application-deployments\current-workspace-app\classes...
Auto-deploying file:/D:/jdeveloper/jdev/mywork/Workspace1/Project1/classes/ (No previous deployment found)... java.lang.NullPointerException
     void com.evermind.server.ejb.compilation.CMPObjectCompilation.processContainerManagedField(com.evermind.server.ejb.deployment.ContainerManagedField, com.evermind.util.ByteString, boolean)
          CMPObjectCompilation.java:314
     void com.evermind.server.ejb.compilation.CMPObjectCompilation.processFields()
          CMPObjectCompilation.java:235
     void com.evermind.server.ejb.compilation.PersistenceManagerCompilation.compile()
          PersistenceManagerCompilation.java:59
     void com.evermind.server.ejb.compilation.EntityBeanCompilation.compile()
          EntityBeanCompilation.java:332
     void com.evermind.server.ejb.compilation.Compilation.compile()
          Compilation.java:288
     void com.evermind.server.ejb.EJBContainer.postInit(com.evermind.server.ejb.EJBContainerConfig, com.evermind.server.administration.ApplicationInstallation)
          EJBContainer.java:551
     void com.evermind.server.Application.postInit(com.evermind.server.ApplicationConfig, com.evermind.server.administration.ApplicationInstallation)
          Application.java:431
     void com.evermind.server.Application.setConfig(com.evermind.server.ApplicationConfig, com.evermind.server.administration.ApplicationInstallation)
          Application.java:136
     void com.evermind.server.ApplicationServer.addApplication(com.evermind.server.ApplicationConfig, com.evermind.server.Application, com.evermind.server.administration.ApplicationInstallation)
          ApplicationServer.java:1635
     com.evermind.server.Application com.evermind.server.ApplicationServer.getApplication(java.lang.String, com.evermind.util.ErrorHandler)
          ApplicationServer.java:2130
     void com.evermind.server.XMLApplicationServerConfig.initHttp(com.evermind.server.ApplicationServer)
          XMLApplicationServerConfig.java:1550
     void com.evermind.server.ApplicationServerLauncher.run()
          ApplicationServerLauncher.java:97
     void java.lang.Thread.run()
          Thread.java:484
Please help with any idea.
Thanks.

Uta-
It looks like you're running JDev 9.0.3.1. If it's not too much trouble, can you try this again with 9.0.3.2? There have been a number of codegen fixes since 9.0.3.1, so it would be best to rule them out first.
If that doesn't fix things, or if that's not convenient, can you include the details of your car-producer and car-types schema objects? This will give me some more info to go on.
Thanks,
Jon

Similar Messages

  • Setting not null EJB relationships

    I have a table with a one to one relation to another table through a foreign key. The foreign key is a not null column. OC4J won't let me set the relationship in ejbCreate, but because the field is not null I can't set it in ejbPostCreate. Do I have any options besides making the column accept null values?

    You have two options.
    Option: 1
    Declare the not null constraint as deferrable; the constraint are checked only when the data is committed
    Option 2:
    In the Entity Bean, you have to add an addition cmp-field ( customerid) for the FK in addition to the existing CMR ( altered ejb-jar.xml & orion-ejb-jar).
    You have to set the customerid in the ejbCreate segment & set up the relationship in the ejbPostCreate section.
    regards
    Debu

  • EJB relationship no working -- The collection is obtained by another transa

    Hi guys,
    I have two entity beans, and defined 1:n relationship following the proper procedure. However when I call the getter, I got following execption:
    com.sap.engine.services.ejb.exceptions.BaseIllegalStateException: The collection is obtained by another transaction.
    My code is following:
    try {
        TimeStatusPK pk = new TimeStatusPK();
        pk.employeeID = employeeID;
        TimeStatusEntityLocal ts = tsHome.findByPrimaryKey(pk);
        Collection distribution = ts.getDistributionByStatus();
        Iterator it = distribution.iterator();
    } catch (Exception e) {
        throw new TES_Exception(e);
    exception occurs when calling distribution.iterator();  Looks like the return collection ( from the 1:n relationship) can not be touched because it's used by other object. I have no idea why this happens, searched in sdn, didn't find hte right answer. Please give me hints.
    Thanks
    Jayson

    Jayson, mark your bean`s transaction type as "Bean":
    <session>
    <transaction-type>Bean</transaction-type>
    </session>
    and modify code like this:
    try {
    _context.getUserTransaction().begin();
    TimeStatusPK pk = new TimeStatusPK();
    pk.employeeID = employeeID;
    TimeStatusEntityLocal ts = tsHome.findByPrimaryKey(pk);
    Collection distribution = ts.getDistributionByStatus();
    Iterator it = distribution.iterator();
    _context.getUserTransaction().commit(); //SessionContext _context . set it in setSessionContext method
    } catch (Exception e) {
    try{
    _context.getUserTransaction().rollback();
    }catch(Exception e)
    throw new TES_Exception(e);

  • Entity EJB Relationships Architectural Question

    I need to create a hierarchy of simple objects. I will call my object
    "Part" for simplicity. I have two Oracle tables to maintain my Part
    hierarchy. The first table contains the detail for the part: number and
    name. The second table maintains the relationship: parent_number and
    child_number. I built Entity EJBs with CMP for both tables, but I don't
    know if that is the "best practices" approach. If it is, how do I define
    the relationships (EJB 2.0)? If it is not, how would you build it?
    Thanks for helping me out,
    Thomas A. Valletta

    Thanks Slava,
    You deserve more than a free trip to a conference for the time and effort
    that you put into this board. I think you should be able to write this off
    as a charitable contribution on your taxes. If you need someone to sign the
    receipt, just let me know.
    Anyway, back to my hierarchy issue(s). I found some information that
    weblogic will set-up this kind of many-to-many relationship for you if you
    set it up correctly in the weblogic-cmp-rdbms-jar.xml and the ejb-jar.xml.
    So I went through the DTDs, but despite the examples the help is extremely
    vague. Has anyone done this? Could anyone recommend where I could find
    something more on the topic (books, magazine articles, online documentation,
    code, etc)?
    Thanks again,
    Thomas A. Valletta
    "Slava Imeshev" <[email protected]> wrote in message
    news:3ec552f9$[email protected]..
    Hi Thomas,
    "Thomas A. Valletta" <[email protected]> wrote in message
    news:[email protected]..
    I need to create a hierarchy of simple objects. I will call my object
    "Part" for simplicity. I have two Oracle tables to maintain my Part
    hierarchy. The first table contains the detail for the part: number and
    name. The second table maintains the relationship: parent_number and
    child_number. I built Entity EJBs with CMP for both tables, but I don't
    know if that is the "best practices" approach. If it is, how do I
    define
    the relationships (EJB 2.0)? If it is not, how would you build it?The best approach is the one that works for you. If the
    combination of two beans works, leave it as is and
    go ahead with next tasks.
    Regards,
    Slava Imeshev

  • CreateEntityManagerFactory() throws NullPointerException for ejb jse client

    Dear experts!
    I am trying to create a java standard edition client, to test outside the weblogic server, my ejb 3 entities, declared as shown in the following persistence.xml.
    The java code, and stacktrace follows also. I have read about some relevant bugs in eclipselink back in 2006, or 7 or 8 and mostly unanswered threads :
    CreateEntityManagerFactory null pointer exception and
    Returned null to createEntityManagerFactory about tomcat and oc4j.
    Persistence.createEntityManagerFactory() throw NullPointerException in oc4j
    I am using JDeveloper 11g Studio Edition Version 11.1.1.3.0, Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660.
    Any helping hand available?
    Thank you very much in advance!
    NA
    package chapter12javaseclient;
    import actionbazaar.buslogic.BidException;
    import actionbazaar.persistence.Bid;
    import actionbazaar.persistence.Bidder;
    import actionbazaar.persistence.Item;
    import java.util.HashMap;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
    import org.eclipse.persistence.config.EntityManagerProperties;
    public class PlaceBidBeanJavaSE {
    private static EntityManagerFactory emf;
    private static EntityManager em;
    public static void main(String[] args) {
    String userId= "idiot";
    Long itemId = new Long (1);
    Double bidPrice = 2001.50;
    try {
    if (emf == null){
    emf = Persistence.createEntityManagerFactory("actionBazaar");
    System.out.println("EntityManagerFactory created!");
    getEntityManager();
    System.out.println("EntityManager created!");
    addBid(userId,itemId,bidPrice);
    commitTransaction();
    } finally {       
    // close the EntityManager when done
    em.close();
    emf.close();
    private static void getEntityManager() {
    HashMap emProps = new HashMap();
    emProps.put(EntityManagerProperties.JDBC_USER, "ab");
    emProps.put(EntityManagerProperties.JDBC_PASSWORD, "ab");
    System.out.println("Creating entity manager");
    em = emf.createEntityManager(emProps);
    em.getTransaction().begin();
    private static void commitTransaction() {
    em.getTransaction().commit();
    private static Long addBid(String userId, Long itemId, Double bidPrice) throws BidException {
    Item item = em.find(Item.class,itemId);
    if (item == null)
    throw new BidException("Invalid Item Id");
    Bidder bidder = em.find(Bidder.class,userId);
    if (bidder == null)
    throw new BidException("Invalid Bidder Id");
    Bid bid = new Bid();
    bid.setItem(item);
    bid.setBidBidder(bidder);
    bid.setBidPrice(bidPrice);
    em.persist(bid);
    return bid.getBidId();
    <?xml version="1.0" encoding="UTF-8" ?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="actionBazaar" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>actionbazaar.persistence.Bid</class>
    <class>actionbazaar.persistence.Item</class>
    <class>actionbazaar.persistence.User</class>
    <class>actionbazaar.persistence.Bidder</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
    <property name="eclipselink.target-server" value="WebLogic_10"/>
    <property name="eclipselink.target-database" value="Oracle11"/>
    <property name="javax.persistence.jdbc.driver"
    value="oracle.jdbc.OracleDriver"/>
    <property name="javax.persistence.jdbc.password"
    value="ab"/>
    <property name="javax.persistence.jdbc.url"
    value="jdbc:oracle:thin:@hera:1521:orcl"/>
    <property name="javax.persistence.jdbc.user" value="ab"/>
    <property name="eclipselink.logging.level" value="ALL"/>
    </properties>
    </persistence-unit>
    </persistence>
    The log output follows:
    C:\Oracle\Middleware\jdev_11gR1\jdk160_18\bin\javaw.exe -client -classpath C:\MyWork\11g\ejb3inaction\.adf;C:\MyWork\11g\ejb3inaction\Chapter12JavaSEClient\classes;C:\MyWork\11g\ejb3inaction\Chapter12\classes;C:\Oracle\Middleware\jdev_11gR1\modules\javax.ejb_3.0.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\com.oracle.toplink_1.0.0.0_11-1-1-3-0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\org.eclipse.persistence_1.0.0.0_2-0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\com.bea.core.antlr.runtime_2.7.7.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.toplink_11.1.1\javax.persistence_2.0_preview.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.xdk_11.1.0\xmlparserv2.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.xdk_11.1.0\xml.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jsf_1.0.0.0_1-2.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.enterprise.deploy_1.2.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.interceptor_1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jms_1.1.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jsp_1.1.0.0_2-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jws_2.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.activation_1.1.0.0_1-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.mail_1.1.0.0_1-4-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.soap_1.3.1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.rpc_1.2.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.ws_2.1.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.management.j2ee_1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.resource_1.5.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.servlet_1.0.0.0_2-5.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.transaction_1.0.0.0_1-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.stream_1.1.1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.security.jacc_1.0.0.0_1-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.registry_1.0.0.0_1-0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.persistence_1.0.0.0_1-0-2.jar;C:\Oracle\Middleware\jdev_11gR1\wlserver_10.3\server\lib\weblogic.jar;C:\Oracle\Middleware\jdev_11gR1\wlserver_10.3\server\ext\jdbc\oracle\11g\ojdbc6.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-collation.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-lcsd.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-mapping.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-servlet.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-translation.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-utility.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.odl_11.1.1\ojdl.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.dms_11.1.1\dms.jar -Djavax.net.ssl.trustStore=C:\Oracle\Middleware\jdev_11gR1\wlserver_10.3\server\lib\DemoTrust.jks chapter12javaseclient.PlaceBidBeanJavaSE
    [EL Finest]: 2010-06-25 09:23:10.495--ServerSession(229902)--Thread(Thread[main,5,main])--Begin predeploying Persistence Unit actionBazaar; session file:/C:/MyWork/11g/ejb3inaction/Chapter12JavaSEClient/classes/_actionBazaar; state Initial; factoryCount 0
    [EL Finest]: 2010-06-25 09:23:10.518--ServerSession(229902)--Thread(Thread[main,5,main])--property=eclipselink.orm.throw.exceptions; default value=true
    [EL Finer]: 2010-06-25 09:23:10.532--ServerSession(229902)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/C:/MyWork/11g/ejb3inaction/Chapter12JavaSEClient/classes/
    [EL Finer]: 2010-06-25 09:23:10.537--ServerSession(229902)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/C:/MyWork/11g/ejb3inaction/Chapter12JavaSEClient/classes/
    [EL Config]: 2010-06-25 09:23:10.652--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.Item] is set to [PROPERTY].
    [EL Config]: 2010-06-25 09:23:10.696--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to many mapping element [method getCategorySet] is being defaulted to: class actionbazaar.persistence.Category.
    [EL Config]: 2010-06-25 09:23:10.702--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [method getBids] is being defaulted to: class actionbazaar.persistence.Bid.
    [EL Config]: 2010-06-25 09:23:10.71--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [method getSeller] is being defaulted to: class actionbazaar.persistence.Seller.
    [EL Config]: 2010-06-25 09:23:10.71--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.User] is set to [PROPERTY].
    [EL Config]: 2010-06-25 09:23:10.711--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [method getCategories] is being defaulted to: class actionbazaar.persistence.Category.
    [EL Config]: 2010-06-25 09:23:10.716--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to one mapping element [method getBillingInfo] is being defaulted to: class actionbazaar.persistence.BillingInfo.
    [EL Config]: 2010-06-25 09:23:10.717--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to one mapping element [method getContactInfo] is being defaulted to: class actionbazaar.persistence.ContactInfo.
    [EL Config]: 2010-06-25 09:23:10.718--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.Bidder] is set to [PROPERTY].
    [EL Config]: 2010-06-25 09:23:10.72--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [method getBids] is being defaulted to: class actionbazaar.persistence.Bid.
    [EL Config]: 2010-06-25 09:23:10.721--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.Bid] is set to [PROPERTY].
    [EL Config]: 2010-06-25 09:23:10.721--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [method getBidBidder] is being defaulted to: class actionbazaar.persistence.Bidder.
    [EL Config]: 2010-06-25 09:23:10.721--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [method getItem] is being defaulted to: class actionbazaar.persistence.Item.
    [EL Config]: 2010-06-25 09:23:10.722--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.Item] is being defaulted to: Item.
    [EL Config]: 2010-06-25 09:23:10.746--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.Bidder] is being defaulted to: Bidder.
    [EL Config]: 2010-06-25 09:23:10.746--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.User] is being defaulted to: User.
    [EL Config]: 2010-06-25 09:23:10.753--ServerSession(229902)--Thread(Thread[main,5,main])--The table name for entity [class actionbazaar.persistence.Bidder] is being defaulted to: USERS.
    [EL Config]: 2010-06-25 09:23:10.753--ServerSession(229902)--Thread(Thread[main,5,main])--The discriminator column name for the root inheritance class [class actionbazaar.persistence.Bidder] is being defaulted to: DTYPE.
    [EL Config]: 2010-06-25 09:23:10.755--ServerSession(229902)--Thread(Thread[main,5,main])--The primary key column name for the inheritance class [class actionbazaar.persistence.Bidder] is being defaulted to: USER_ID.
    [EL Config]: 2010-06-25 09:23:10.755--ServerSession(229902)--Thread(Thread[main,5,main])--The foreign key column name for the inheritance class [class actionbazaar.persistence.Bidder] is being defaulted to: USER_ID.
    [EL Config]: 2010-06-25 09:23:10.758--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.Bid] is being defaulted to: Bid.
    Exception in thread "main" java.lang.NullPointerException
         at chapter12javaseclient.PlaceBidBeanJavaSE.main(PlaceBidBeanJavaSE.java:43)
    Process exited with exit code 1.

    Thank you for your reply!
    The client now works correctly. It seems that the line
    em = emf.createEntityManager(emProps);//
    throws an exception when no argument is given for em = emf.createEntityManager();// emProps missing!
    There was also a warning in jdev editor, about the line you mentioned:
    <property name="eclipselink.target-server" value="WebLogic 10"/>
    Carry on with your good work!
    The updated persistence.xml and java source code shown below:
    <?xml version="1.0" encoding="UTF-8" ?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="actionBazaar" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>actionbazaar.persistence.Bid</class>
    <class>actionbazaar.persistence.Item</class>
    <class>actionbazaar.persistence.User</class>
    <class>actionbazaar.persistence.Bidder</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
    <property name="eclipselink.target-database" value="Oracle11"/>
    <property name="javax.persistence.jdbc.driver"
    value="oracle.jdbc.OracleDriver"/>
    <property name="javax.persistence.jdbc.password"
    value="29E8BD11B89A62E3862F19C4F84B7DB0"/>
    <property name="javax.persistence.jdbc.user" value="ab"/>
    <property name="eclipselink.logging.level" value="ALL"/>
    <property name="eclipselink.orm.validate.schema" value="true"/>
    <property name="javax.persistence.jdbc.url"
    value="jdbc:oracle:thin:@hera:1521:orcl"/>
    </properties>
    </persistence-unit>
    </persistence>
    package chapter12javaseclient;
    import actionbazaar.buslogic.BidException;
    import actionbazaar.persistence.Bid;
    import actionbazaar.persistence.Bidder;
    import actionbazaar.persistence.Item;
    import java.util.HashMap;
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
    import org.eclipse.persistence.config.EntityManagerProperties;
    public class PlaceBidBeanJavaSE {
    private static EntityManagerFactory emf;
    private static EntityManager em;
    private static Hashtable emProps = new Hashtable();
    public static void main(String[] args) {
    String userId= "idiot";
    Long itemId = new Long (2);
    Double bidPrice = 2002.50;
    try {
    if (emf == null){
    emf = Persistence.createEntityManagerFactory("actionBazaar");
    System.out.println("EntityManagerFactory created!");
    getEntityManager();
    System.out.println("EntityManager created!");
    addBid(userId,itemId,bidPrice);
    commitTransaction();
    } finally {       
    // close the EntityManager when done
    em.close();
    emf.close();
    private static void getEntityManager() {
    try {
    System.out.println("Creating entity manager");
    em = emf.createEntityManager(emProps);// if argument is missing exception is thrown!
    em.getTransaction().begin();
    } catch (Exception ne) {
    // TODO: Add catch code
    ne.printStackTrace();
    private static void commitTransaction() {
    em.getTransaction().commit();
    private static Long addBid(String userId, Long itemId, Double bidPrice) throws BidException {
    Item item = em.find(Item.class,itemId);
    if (item == null)
    throw new BidException("Invalid Item Id");
    Bidder bidder = em.find(Bidder.class,userId);
    if (bidder == null)
    throw new BidException("Invalid Bidder Id");
    Bid bid = new Bid();
    bid.setItem(item);
    bid.setBidBidder(bidder);
    bid.setBidPrice(bidPrice);
    em.persist(bid);
    return bid.getBidId();
    NA
    [http://nickaiva.blogspot.com/]

  • EJB Relationships

    I am trying to set up a 1:N relationship between two ejb's. I have them both
    in separate directories using separate Deployment Descriptors. I am trying to
    define a relationship in the EJB that manages the relationship to the other ejb's.
    When I try to compile, I get an error saying the other ejb could not be found.
    Do both ejb's have to be defined in one ejb-jar.xml? Or can they be in separate
    directories, each with its own ejb-jar.xml?
    Either way, how do I set it up so I can establish a relationship between
    two esisting ejb's?

    The 2 ejbs need to be in the same jar (and thus in the same Deployment Descriptor)

  • EJB Relationship FUBAR

    In evaluating the latest release of JDeveloper (9.0.3), I have noticed that the CMP EJB wizard does not produce compilable code when generating default relationships. It appears that the set methods for the PrimaryKey and ID values are not generated properly. I guess I have to create those methods manually.
    Is this the way JDev is supposed to work ?
    I have not found any information in the JDeveloper docs that cover this issue. Any help would be appreciated.
    TIA.
    Steve Guilford...>>>

    Steve-
    Can you describe what is wrong with the CMR setters? Are you working with basic (single column) or compound (multi-column) primary/foreign keys?
    There may be some issues lurking when using multi-column PK's, particularly if the PK includes a foreign key (if represented by a CMR field), but in some cases these are caused by an invalid CMR condition (such as a non-deferred NOT NULL constraint on a FK column -- the EJB spec implicitly prevents this condition).
    If you can send me your schema or codegen details, I'll be happy to take a look.
    Jon

  • Problems with EJB Relationships

    Hi,
    I'm having a problems using relationships in EJB. There are two entities: User and Profile. The User entity is a simple entity, with some String fields and two Integer fields (the primary key and the foreign key - coming from Profile). The Profile entity has some String fields and an Integer field (the primary key).
    There is no problem when executing the ejbCreate() method on the Profile entity. Everything goes fine. But, when executing the ejbCreate() on the User entity, the following message appears:
    javax.ejb.CreateException: Could not create entity:java.sql.SQLException: ORA-06550: line 1, column 83:
    PL/SQL: ORA-00957: duplicate column name
    ORA-06550: line 1, column 7:
    PL/SQL: SQL Statement ignored
    The relationship between the two entities is like that:
    "UserBean"
    * Returns the profileId
    * @return the profileId
    * @ejb.persistent-field
    * @ejb.persistence
    * column-name="PROFILE_ID"
    * sql-type="NUMBER"
    * @ejb.interface-method
    * @ejb.relation
    * name="profile-user"
    * role-name="user-has-profile"
    * target-ejb="Profile"
    * target-multiple="no"
    * target-role-name="profile-is-in-user"
    * @jboss.relation
    * fk-column="profile_id"
    * related-pk-field="profileId"
    public abstract java.lang.Integer getProfileId();
    * Sets the profileId
    * @param java.lang.Integer the new profileId value
    * @ejb.interface-method
    public abstract void setProfileId(java.lang.Integer profileId);
    "ProfileBean"
    * Returns a Collection of Usuario
    * @return a Collection of Usuario
    * @ejb.interface-method
    * view-type="both"
    * @ejb.relation
    * name="perfil-usuario"
    * role-name="perfil-tem-usuario"
    public abstract java.util.Collection getUsuario();
    public abstract void setUsuario(java.util.Collection usuario);
    I'm using JBOSS 3.2 application server.
    Have anyone seen this??
    Thank you,
    Wilson

    I've already discovered what happened. The column-name attribute in the @ejb.persistence tag should always be in lower-case.

  • Ejb relationships using cmp field

    I have defined a cmp relationship using cmr field. Als defined getter/setter for that field.
    When I call the getter method container returns all the records for relation.
    getter/setter is implemented by container.
    My question is can we define in which order relationships record should be retrieved. I mean can we specify Order By caluse for that.

    if you want to do this you just have to use Map on collection side of your relationship like this:
    @OneToMany(cascade={CascadeType.ALL})
        @JoinColumn(name="CUSTOMER_ID")
    @MapKey(name="number")
    @OrderBy
    ("number ASC")
        public Map<String, Phone> getPhoneNumbers

  • Sevlet - ejb relationship

    hi. i have a rather simple question. if a servlet were to instantiate
              and ejb, would there be a way for that ejb to get access to the
              servlet's session context. i know that an ejb can get access to its
              container via SessionContext, but what about a session of a servlet
              which called the ejb? thanks!!!
              

    A servlet will do that exactly the same way as a client application.
              except if you are running in the same VM, you can do "new InitialContext()"
              without any parameters.
              Filip
              ~
              Namaste - I bow to the divine in you
              ~
              Filip Hanik
              Software Architect
              [email protected]
              www.filip.net
              "Mikhail Perelman" <[email protected]> wrote in message
              news:[email protected]..
              > hi. i have a rather simple question. if a servlet were to instantiate
              > and ejb, would there be a way for that ejb to get access to the
              > servlet's session context. i know that an ejb can get access to its
              > container via SessionContext, but what about a session of a servlet
              > which called the ejb? thanks!!!
              >
              

  • EJB relationship

    Hi there! I have a few questions related to this topic, wish you guys could help me:
    1st - I can't remember, do the entities used in a relation must lie in the same jar? Or could they be distributed in diffent jars in a unique ear?
    2nd - In a relationship, when adding a parent and a child, don't the CMP engine adds the child automatic for me? Do I need to transverse the Collection and call childhome.create() for each child of a given parent?
    3rd - kinda related to the question above. I know that deletes can be "cascaded" what about updates? Do I need to transverse the Collection either or in this case it's a different scenario?
    Thanks all
    Vinicius Carvalho

    1- it doesnt matter where u deploy them - as long as their home interfaces(remote/local) are well configured to correct JNDI name.
    2- im not sure i understand your question - the good practice is like
    _ cmp - category
    session bean
    _cmp -item
    if you want to add a child :
    (session bean): Item = ItemHome.create();
    (session bean): CategoryRemote.addItem(Item)
    (categoryBean): public addItem(Item item){
    Collection items = getItems();
    items.add(item)}
    and thats it! hope it helps,
    3-depends on Application server each AS has diffrent way to configure relations
    you have to remeber one thing with persistence:
    every action you make is made of 2 actions
    a.store changes in DB
    b.store object's state
    last tip - dont use entity beans!!!!! - www.hibernate.org - check it out its like magic........

  • Problems with EJB relationship mapping (annotations)

    So, I'm part of a group working on a web-based project management system, and we're having some trouble with the relationship mapping between the entity beans.
    I've been mainly working on a class called WorkPackage. So the mappings I've got:
    Within the WorkPackage class
    (A work package is one "module" of work within a project)
            @Entity
            @Table(name="WorkPackage")
            @IdClass(WorkPackagePK.class)
            public class WorkPackage implements java.io.Serializable
            @Id
            @Column(name="wpID")
            public String getWpID() { return wpID; }
         public void setWpID(String id) { this.wpID = id; }
         @Id
            @Column(name="projID")
            public String getProjId() { return projId; }
         public void setProjId(String projId) { this.projId = projId; }
            @ManyToOne // bidirectional - owner side
         @JoinColumn(name="projID")
         public Project getProject() { return project; }
         public void setProject(Project project) { this.project = project; }      And on the Project side
            @Entity
            @Table(name="Project")
            public class Project implements java.io.Serializable
            @Id
            @Column(name="projID")
            public String getId() { return id; }
         public void setId(String id) { this.id = id; }
           @OneToMany(mappedBy="project") // biderctional - target side
         public Set<WorkPackage> getWorkPackages() { return workPackages; }
         public void setWorkPackages(Set<WorkPackage> workPackages) { this.workPackages = workPackages; } The problem here is that its apparently seeing 'projID' as attempting to be mapped to 2 columns within the 'workpackage' table in the database instead of using the @Id one as the id, and the other as the foreign key to the 'project' table.
    So, when I try to add a workpackage to the database via a JSF page, it gives me the error 'java.sql.BatchUpdateException: Column 'projID' specified twice'.
    Maybe its something to do with variable in the project class being called 'id' even though its mapped to the database column 'projID'
    Edited by: wormdundee on Mar 1, 2008 2:26 PM

    I think the trouble is that you overrode the column names for the projID and project properties to the same value. Try
    @Entity
            @Table(name="WorkPackage")
            @IdClass(WorkPackagePK.class)
            public class WorkPackage implements java.io.Serializable
            @Id
            @Column(name="WP_WP_ID")
            public String getWpID() { return wpID; }
         public void setWpID(String id) { this.wpID = id; }
         @Id
            @Column(name="WP_PROJ_ID")
            public String getProjId() { return projId; }
         public void setProjId(String projId) { this.projId = projId; }
            @ManyToOne // bidirectional - owner side
         @JoinColumn(name="WP_PROJECT_PROJ_ID")
         public Project getProject() { return project; }
         public void setProject(Project project) { this.project = project; }

  • Defining a many-to-many relationship with CMP EJBs  : does it work for you

    Curious to know whether someone has been able to set up a many to many relationship between two entity beans.
    I have been struggling with this for days now and I can't get it to work.
    In my test project I have two entity beans, resp. Consultant and Solution.
    Consultant has a cmr field called 'solutions', which is a collection object from the opposite side (Solution).
    This is the source of the ejb-jar.xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
         <description>EJB JAR description</description>
         <display-name>EJB JAR</display-name>
         <enterprise-beans>
              <session>
                   <ejb-name>ProfilerBean</ejb-name>
                   <home>com.atosorigin.tcc.testing.ejbses.profiling.ProfilerHome</home>
                   <remote>com.atosorigin.tcc.testing.ejbses.profiling.Profiler</remote>
                   <local-home>com.atosorigin.tcc.testing.ejbses.profiling.ProfilerLocalHome</local-home>
                   <local>com.atosorigin.tcc.testing.ejbses.profiling.ProfilerLocal</local>
                   <ejb-class>com.atosorigin.tcc.testing.ejbses.profiling.ProfilerBean</ejb-class>
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>
                   <ejb-local-ref>
                        <ejb-ref-name>EJBTesting/Solution</ejb-ref-name>
                        <ejb-ref-type>Entity</ejb-ref-type>
                        <local-home>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionLocalHome</local-home>
                        <local>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionLocal</local>
                        <ejb-link>SolutionBean</ejb-link>
                   </ejb-local-ref>
                   <ejb-local-ref>
                        <ejb-ref-name>EJBTesting/Consultant</ejb-ref-name>
                        <ejb-ref-type>Entity</ejb-ref-type>
                        <local-home>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantLocalHome</local-home>
                        <local>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantLocal</local>
                        <ejb-link>ConsultantBean</ejb-link>
                   </ejb-local-ref>
              </session>
              <entity>
                   <ejb-name>ConsultantBean</ejb-name>
                   <home>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantHome</home>
                   <remote>com.atosorigin.tcc.testing.ejbcmp.profiling.Consultant</remote>
                   <local-home>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantLocalHome</local-home>
                   <local>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantLocal</local>
                   <ejb-class>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantBean</ejb-class>
                   <persistence-type>Container</persistence-type>
                   <prim-key-class>java.lang.String</prim-key-class>
                   <reentrant>False</reentrant>
                   <cmp-version>2.x</cmp-version>
                   <abstract-schema-name>Consultant</abstract-schema-name>
                   <cmp-field>
                        <field-name>firstname</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>lastname</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>country</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>id</field-name>
                   </cmp-field>
                   <primkey-field>id</primkey-field>
                   <query>
                        <query-method>
                             <method-name>findBySolution</method-name>
                             <method-params>
                                  <method-param>java.lang.String</method-param>
                             </method-params>
                        </query-method>
                        <ejb-ql>SELECT Object(c) FROM Consultant AS c,
                        IN(c.solutions) s WHERE s.id = ?1 </ejb-ql>
                   </query>
              </entity>
              <entity>
                   <ejb-name>SolutionBean</ejb-name>
                   <home>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionHome</home>
                   <remote>com.atosorigin.tcc.testing.ejbcmp.profiling.Solution</remote>
                   <local-home>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionLocalHome</local-home>
                   <local>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionLocal</local>
                   <ejb-class>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionBean</ejb-class>
                   <persistence-type>Container</persistence-type>
                   <prim-key-class>java.lang.String</prim-key-class>
                   <reentrant>False</reentrant>
                   <cmp-version>2.x</cmp-version>
                   <abstract-schema-name>Solution</abstract-schema-name>
                   <cmp-field>
                        <field-name>description</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>name</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>parent</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>id</field-name>
                   </cmp-field>
                   <primkey-field>id</primkey-field>
                   <query>
                        <query-method>
                             <method-name>findChildSolutions</method-name>
                             <method-params>
                                  <method-param>java.lang.String</method-param>
                             </method-params>
                        </query-method>
                        <ejb-ql>SELECT Object(s) FROM Solution AS s WHERE
                        s.parent = ?1</ejb-ql>
                   </query>
                   <query>
                        <query-method>
                             <method-name>findTopLevelSolutions</method-name>
                             <method-params/>
                        </query-method>
                        <ejb-ql>Select Object(s) FROM Solution AS s WHERE
                        (s.parent = &apos;none&apos;)</ejb-ql>
                   </query>
              </entity>
         </enterprise-beans>
         <relationships>
              <ejb-relation>
                   <description>A consultant may have one or more areas of expertise</description>
                   <ejb-relation-name>Consultant_Solutions</ejb-relation-name>
                   <ejb-relationship-role>
                        <ejb-relationship-role-name>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantBean</ejb-relationship-role-name>
                        <multiplicity>Many</multiplicity>
                        <relationship-role-source>
                             <ejb-name>ConsultantBean</ejb-name>
                        </relationship-role-source>
                        <cmr-field>
                             <cmr-field-name>solutions</cmr-field-name>
                             <cmr-field-type>java.util.Collection</cmr-field-type>
                        </cmr-field>
                   </ejb-relationship-role>
                   <ejb-relationship-role>
                        <ejb-relationship-role-name>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionBean</ejb-relationship-role-name>
                        <multiplicity>Many</multiplicity>
                        <relationship-role-source>
                             <ejb-name>SolutionBean</ejb-name>
                        </relationship-role-source>
                   </ejb-relationship-role>
              </ejb-relation>
         </relationships>
         <assembly-descriptor>
              <container-transaction>
                   <description>container-transaction</description>
                   <method>
                        <ejb-name>SolutionBean</ejb-name>
                        <method-name>*</method-name>
                   </method>
                   <method>
                        <ejb-name>ProfilerBean</ejb-name>
                        <method-name>*</method-name>
                   </method>
                   <method>
                        <ejb-name>ConsultantBean</ejb-name>
                        <method-name>*</method-name>
                   </method>
                   <trans-attribute>Required</trans-attribute>
              </container-transaction>
         </assembly-descriptor>
    </ejb-jar>
    I created a stateless session bean as a business facade for the two entity beans. I then created a webservice to test the beans.
    What works :
    - create a consultant
    - get a consultant
    - create a solution
    - get a solution
    (basically everything that doesn't involve the relationship field.
    However, what doesn't work is the method call assignSolution:
    - assign solution : this is implemented as follows
    Business Method.
         public void assignSolution(String consultantID, String solutionID)
              throws ProfilingException {
              // TODO : Implement
              ConsultantLocal cons = null;
              SolutionLocal sol = null;
              try {
                   cons = consHome.findByPrimaryKey(consultantID);
                   sol = solHome.findByPrimaryKey(solutionID);
                   Collection solutions = cons.getSolutions();
                   solutions.add(sol);
                   //sol.getConsultants().add(cons);
              } catch (FinderException ex) {
                   ex.printStackTrace();
                   throw new ProfilingException("failed to retrieve data from DB", ex);
    As you can see I am trying to use the CM Relationship in this methhod. Adding the solution to a consultant should be as simple as adding a solution object to the collection retrieved with the getSolutions accessor. The Container is expected to persist the information in my MAXDB database.
    However this doesn't happen.
    The ORM details as defined in the persistent.xml follows :
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE persistent-ejb-map SYSTEM "persistent.dtd">
    <persistent-ejb-map>
         <locking
              type="Table"/>
         <db-properties>
              <data-source-name>TCC_PORTAL_PROFILER</data-source-name>
              <database-vendor
                   name="SAPDB"/>
         </db-properties>
         <entity-beans>
              <entity-bean>
                   <ejb-name>ConsultantBean</ejb-name>
                   <table-name>PFL_CONSULTANTS</table-name>
                   <field-map
                        key-type="NoKey">
                        <field-name>firstname</field-name>
                        <column>
                             <column-name>FIRSTNAME</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>lastname</field-name>
                        <column>
                             <column-name>LASTNAME</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>country</field-name>
                        <column>
                             <column-name>COUNTRY</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="PrimaryKey">
                        <field-name>id</field-name>
                        <column>
                             <column-name>ID</column-name>
                        </column>
                   </field-map>
                   <finder-descriptor>
                        <method-name>findBySolution</method-name>
                        <method-params>
                             <method-param>java.lang.String</method-param>
                        </method-params>
                        <load-selected-objects
                             lock="read"/>
                   </finder-descriptor>
              </entity-bean>
              <entity-bean>
                   <ejb-name>SolutionBean</ejb-name>
                   <table-name>PFL_SAPSOLUTIONS</table-name>
                   <field-map
                        key-type="NoKey">
                        <field-name>description</field-name>
                        <column>
                             <column-name>DESCRIPTION</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>name</field-name>
                        <column>
                             <column-name>NAME</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>parent</field-name>
                        <column>
                             <column-name>PARENTID</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="PrimaryKey">
                        <field-name>id</field-name>
                        <column>
                             <column-name>ID</column-name>
                        </column>
                   </field-map>
                   <finder-descriptor>
                        <method-name>findChildSolutions</method-name>
                        <method-params>
                             <method-param>java.lang.String</method-param>
                        </method-params>
                        <load-selected-objects
                             lock="read"/>
                   </finder-descriptor>
                   <finder-descriptor>
                        <method-name>findTopLevelSolutions</method-name>
                        <method-params/>
                        <load-selected-objects
                             lock="read"/>
                   </finder-descriptor>
              </entity-bean>
         </entity-beans>
         <relationships>
              <table-relation>
                   <help-table>PFL_CONS_SOL_MAP</help-table>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>ConsultantBean</ejb-name>
                        <cmr-field>solutions</cmr-field>
                        <fk-column>
                             <column-name>CONSULTANTID</column-name>
                             <pk-field-name>id</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>SolutionBean</ejb-name>
                        <fk-column>
                             <column-name>SOLUTIONID</column-name>
                             <pk-field-name>id</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
              </table-relation>
         </relationships>
    </persistent-ejb-map>
    The error in the default trace file when calling the method states, there is an "inconsistency in the number of primary keys". Details follow.
    #1.5#000F1F188E5C004400000000000010480003E76C80EFD57A#1098880364327#com.sap.engine.services.ejb#com.atosorigin.tcc/EJBCMPProfilingTest#com.sap.engine.services.ejb#Guest#2####4d2b2370281411d9a40d000f1f188e5c#SAPEngine_Application_Thread[impl:3]_31##0#0#Error##Java###
    [EXCEPTION]
    #1#com.sap.engine.services.ejb.exceptions.BaseRemoteException: Exception in method assignSolution.
         at com.atosorigin.tcc.testing.ejbses.profiling.ProfilerObjectImpl0.assignSolution(ProfilerObjectImpl0.java:822)
         at com.atosorigin.tcc.testing.ejbses.profiling.Profiler_Stub.assignSolution(Profiler_Stub.java:533)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)
         at $Proxy73.assignSolution(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:146)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:68)
         at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
         at SoapServlet.doPost(SoapServlet.java:51)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:339)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:317)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:810)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:238)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Caused by: com.sap.engine.services.applocking.exception.SAPAppLockingIllegalArgumentException: Inconsistency in number of primary keys
         at com.sap.engine.services.applocking.TableLockingImpl.getArgument(TableLockingImpl.java:385)
         at com.sap.engine.services.applocking.TableLockingImpl.lock(TableLockingImpl.java:128)
         at com.sap.engine.services.applocking.TableLockingImpl.lock(TableLockingImpl.java:138)
         at com.sap.engine.services.ejb.entity.pm.lock.TableLockingSystem.write(TableLockingSystem.java:82)
         at com.sap.engine.services.ejb.entity.pm.PersistentM2M.create(PersistentM2M.java:172)
         at com.sap.engine.services.ejb.entity.pm.PersistentCacheM2M.add(PersistentCacheM2M.java:197)
         at com.sap.engine.services.ejb.entity.pm.multiple.CollectionM2M.add(CollectionM2M.java:57)
         at com.atosorigin.tcc.testing.ejbses.profiling.ProfilerBean.assignSolution(ProfilerBean.java:201)
         at com.atosorigin.tcc.testing.ejbses.profiling.ProfilerObjectImpl0.assignSolution(ProfilerObjectImpl0.java:771)
         ... 32 more
    I can't figure out what the problem is with the ORM mapping defined.
    On the database level I have three tables. Consultant maps to PFL_CONSULTANT, Solution to PFL_SAPSOLUTIONS. The third table PFL_CONS_SOL_MAP is the help table used for the relationship (having two fields, which are in fact foreign keys from the other two tables to express the assignment of solutions to consultants (where a consultant can have one or more solutions).
    ps. : I am running Netweaver Developer Workplace (Netweaver 2004, at stack level 5)
    Message was edited by: Theo Paesen

    Hm, after disabling 'automatic locking' it works.

  • Help: IllegalExpressionException vs. EJB 2.1 many-to-many relationship

    Using Oracle WebLogic 11g (10.3.4). The appc tool is generating a warning regarding an illegal EJB QL expression for a many-to-may relationship in an EJB 2 Bean.
    Details:
    * Entity Bean "MSProduktKonfiguration"
    * Entity Bean "MSAngebot"
    * n-m relationship betwenn these two Entites, from MSProduktKonfiguration to MSAngebot by cmr field angebotLocal, from MSAngebot to MSProduktKonfiguration by cmr field produktKonfigurationenLocal
    * Join table "MS_PRODUKT.ANGEBOT_POSITION"
    Warnings from appc:
    [java] Warning: [EJB:013094]The SELECT clause of this query contains an identifier 'bean.angebotLocal' that ends in a cmr-field. The EJB 2.1 specification section 11.2.7.1 requires that any related null objects belonging to the set corresponding to this cmr-field must be returned by this query however the database that will be used to execute this query does not sufficiently support SQL outer joins, therefore this query will not return any null objects that might otherwise be returned.
    [java] Warning: [EJB:013094]The SELECT clause of this query contains an identifier 'bean.produktKonfigurationenLocal' that ends in a cmr-field. The EJB 2.1 specification section 11.2.7.1 requires that any related null objects belonging to the set corresponding to this cmr-field must be returned by this query however the database that will be used to execute this query does not sufficiently support SQL outer joins, therefore this query will not return any null objects that might otherwise be returned.
    I have no clue what's going on there. Maybe someone can help me out.
    Snippet from the ejb-jar.xml Deployment Descriptor:
    <ejb-relation id="EJBRelation_9">
    <ejb-relation-name>Angebot-ProduktKonfiguration</ejb-relation-name>
    <ejb-relationship-role id="EJBRelationshipRole_17">
    <ejb-relationship-role-name>ProduktKonfigurationen-Have-Angebote</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <relationship-role-source id="RoleSource_17">
    <ejb-name>MSProduktKonfiguration</ejb-name>
    </relationship-role-source>
    <cmr-field id="CMRField_9">
    <cmr-field-name>angebotLocal</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role id="EJBRelationshipRole_18">
    <ejb-relationship-role-name>Angebote-Have-ProduktKonfigurationen</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <relationship-role-source id="RoleSource_18">
    <ejb-name>MSAngebot</ejb-name>
    </relationship-role-source>
    <cmr-field id="CMRField_10">
    <cmr-field-name>produktKonfigurationenLocal</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    Snippet from the weblogic-cmp-rdbms-jar.xml Deployment Descriptor:
    <weblogic-rdbms-relation>
    <relation-name>Angebot-ProduktKonfiguration</relation-name>
    <table-name>MS_PRODUKT.ANGEBOT_POSITION</table-name>
    <weblogic-relationship-role>
    <relationship-role-name>Angebote-Have-ProduktKonfigurationen</relationship-role-name>
    <relationship-role-map>
    <column-map>
    <foreign-key-column>angebot_id</foreign-key-column>
    <key-column>angebot_id</key-column>
    </column-map>
    </relationship-role-map>
    </weblogic-relationship-role>
    <weblogic-relationship-role>
    <relationship-role-name>ProduktKonfigurationen-Have-Angebote</relationship-role-name>
    <relationship-role-map>
    <column-map>
    <foreign-key-column>produkt_konfiguration_id</foreign-key-column>
    <key-column>produkt_konfiguration_id</key-column>
    </column-map>
    </relationship-role-map>
    </weblogic-relationship-role>
    </weblogic-rdbms-relation>

    Hi,
    There are many differences between EJB 1.1 and 2.0. Most of these are
    regarding CMP entity EJBs. I would say you should go with 2.0 if you have
    entity EJBs.
    Also EJB 2.0 has local interfaces and message-driven beans (JMS listeners).
    Emmanuel
    "Brian" <[email protected]> wrote in message
    news:3cf3b4eb$[email protected]..
    >
    Our standard development tool here is WebGain Visual Cafe 4.5.1. I am toldthat this
    tool does not support EJB 2.0. We are generating EJB's through the wizardbased interface
    of Visual Cafe.
    Is there a compelling reason to use EJB 2.0 instead of 1.1, even thoughthe tool
    doesn't support it? Is the time saved by automatic generation of EJB 1.1beans outweighed
    by improvements in EJB 2.0?
    Thanks for you help!

  • NullPointerException thrown when using get method in CMR relationship outsi

    We are using weblogic 9.1 CMP entity beans with BEA's XA oracle driver. We have a bean called User that has a many address beans. When calling the getAddresses method on a UserLocal a NullPointerException gets thrown if the stateless session bean method that is marked as @LocalMethod(transactionAttribute=Constants.TransactionAttribute.SUPPORTS). If we change it to REQUIRED the method returns addresses successfully. Does anyone have any ideas as to what could be causing this? Below is the stack trace.
    My best guess is that an exception is occurring and when weblogic tries to handle the exception EJBRuntimeUtils.throwEJBException encounters the NullPointerException.
    javax.ejb.EJBException: EJB Exception: : java.lang.NullPointerException
    at gov.nasa.echo.dataaccessobjects.user.echo_user_User_l47u68__WebLogic_CMP_RDBMS_addresses_Set.<init>(echo_user_User_l47u68__WebLogic_CMP_RDBMS_addresses_Set.java
    :93)
    at gov.nasa.echo.dataaccessobjects.user.echo_user_User_l47u68__WebLogic_CMP_RDBMS.getAddresses(echo_user_User_l47u68__WebLogic_CMP_RDBMS.java:1161)
    at gov.nasa.echo.dataaccessobjects.user.echo_user_User_l47u68_ELOImpl.getAddresses(echo_user_User_l47u68_ELOImpl.java:770)
    at gov.nasa.echo.subsystems.user.UserTypeMap.convertUser(UserTypeMap.java:66)
    at gov.nasa.echo.subsystems.user.UserSubsystem.getUserByUserId(UserSubsystem.java:321)
    at gov.nasa.echo.subsystems.user.UserSubsystem.getUsersByUserId(UserSubsystem.java:302)
    at gov.nasa.echo.services.authentication.AuthenticationServiceBean.login(AuthenticationServiceBean.java:442)
    at gov.nasa.echo.services.authentication.AuthenticationServiceBean_plcr77_ELOImpl.login(AuthenticationServiceBean_plcr77_ELOImpl.java:1001)
    at gov.nasa.echo.v8.AuthenticationServicePortImpl.login(AuthenticationServicePortImpl.java:105)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at weblogic.wsee.component.pojo.JavaClassComponent.invoke(JavaClassComponent.java:91)
    at weblogic.wsee.ws.dispatch.server.ComponentHandler.handleRequest(ComponentHandler.java:68)
    at weblogic.wsee.handler.HandlerIterator.handleRequest(HandlerIterator.java:127)
    at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:84)
    at weblogic.wsee.ws.WsSkel.invoke(WsSkel.java:60)
    at weblogic.wsee.server.servlet.SoapProcessor.handlePost(SoapProcessor.java:66)
    at weblogic.wsee.server.servlet.SoapProcessor.process(SoapProcessor.java:44)
    at weblogic.wsee.server.servlet.BaseWSServlet$AuthorizedInvoke.run(BaseWSServlet.java:124)
    at weblogic.wsee.server.servlet.BaseWSServlet.service(BaseWSServlet.java:53)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:165)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3153)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1973)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1880)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1310)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    ; nested exception is: java.lang.NullPointerException
    at weblogic.ejb.container.internal.EJBRuntimeUtils.throwEJBException(EJBRuntimeUtils.java:141)
    at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:643)
    at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:604)
    at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:347)
    at weblogic.ejb.container.internal.BaseLocalObject.postInvokeTxRetry(BaseLocalObject.java:286)
    Truncated. see log file for complete stacktrace

    Jason Gilman wrote:
    We are using weblogic 9.1 CMP entity beans with BEA's XA oracle driver. We have a bean called User that has a many address beans. When calling the getAddresses method on a UserLocal a NullPointerException gets thrown if the stateless session bean method that is marked as @LocalMethod(transactionAttribute=Constants.TransactionAttribute.SUPPORTS). If we change it to REQUIRED the method returns addresses successfully. Does anyone have any ideas as to what could be causing this? Below is the stack trace
    My best guess is that an exception is occurring and when weblogic tries to handle the exception EJBRuntimeUtils.throwEJBException encounters the NullPointerException.
    Open an official support case. This has nothing to do with jdbc.
    Joe
    >
    >
    javax.ejb.EJBException: EJB Exception: : java.lang.NullPointerException
    at gov.nasa.echo.dataaccessobjects.user.echo_user_User_l47u68__WebLogic_CMP_RDBMS_addresses_Set.<init>(echo_user_User_l47u68__WebLogic_CMP_RDBMS_addresses_Set.java
    :93)
    at gov.nasa.echo.dataaccessobjects.user.echo_user_User_l47u68__WebLogic_CMP_RDBMS.getAddresses(echo_user_User_l47u68__WebLogic_CMP_RDBMS.java:1161)
    at gov.nasa.echo.dataaccessobjects.user.echo_user_User_l47u68_ELOImpl.getAddresses(echo_user_User_l47u68_ELOImpl.java:770)
    at gov.nasa.echo.subsystems.user.UserTypeMap.convertUser(UserTypeMap.java:66)
    at gov.nasa.echo.subsystems.user.UserSubsystem.getUserByUserId(UserSubsystem.java:321)
    at gov.nasa.echo.subsystems.user.UserSubsystem.getUsersByUserId(UserSubsystem.java:302)
    at gov.nasa.echo.services.authentication.AuthenticationServiceBean.login(AuthenticationServiceBean.java:442)
    at gov.nasa.echo.services.authentication.AuthenticationServiceBean_plcr77_ELOImpl.login(AuthenticationServiceBean_plcr77_ELOImpl.java:1001)
    at gov.nasa.echo.v8.AuthenticationServicePortImpl.login(AuthenticationServicePortImpl.java:105)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at weblogic.wsee.component.pojo.JavaClassComponent.invoke(JavaClassComponent.java:91)
    at weblogic.wsee.ws.dispatch.server.ComponentHandler.handleRequest(ComponentHandler.java:68)
    at weblogic.wsee.handler.HandlerIterator.handleRequest(HandlerIterator.java:127)
    at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:84)
    at weblogic.wsee.ws.WsSkel.invoke(WsSkel.java:60)
    at weblogic.wsee.server.servlet.SoapProcessor.handlePost(SoapProcessor.java:66)
    at weblogic.wsee.server.servlet.SoapProcessor.process(SoapProcessor.java:44)
    at weblogic.wsee.server.servlet.BaseWSServlet$AuthorizedInvoke.run(BaseWSServlet.java:124)
    at weblogic.wsee.server.servlet.BaseWSServlet.service(BaseWSServlet.java:53)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:165)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3153)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1973)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1880)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1310)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    ; nested exception is: java.lang.NullPointerException
    at weblogic.ejb.container.internal.EJBRuntimeUtils.throwEJBException(EJBRuntimeUtils.java:141)
    at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:643)
    at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:604)
    at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:347)
    at weblogic.ejb.container.internal.BaseLocalObject.postInvokeTxRetry(BaseLocalObject.java:286)
    Truncated. see log file for complete stacktrace

Maybe you are looking for

  • How to remove encryption in digital signature

    How to remove the encryption in the digital signatur I sign document and signature encrypt document hence not allowing future amendments.  How to remove encryption ??

  • Multiple items in custom form

    I'm new to Service Manager customization and try to do this task ,  I have custom management pack for our configuration items , I added a CI class "ITServer" which would have multiple harddisks, I created a Hard Disk Class and make a relationship (1

  • Cash Flow Report (FSI3/FSI5) pulling double value

    Dear SAP Experts I am creating a Cash Flow Statement via FSI3 /FSI5. While selecting key figure "Total Credit Postings" system is pulling the double values for the assigned GL. Please see below; Please see the output. GL total credit value is 269610.

  • Recommended update procedure and safe boot

    I have noticed the flurry of problems after the two most recent security updates (2008-002 and 2008-003 PPC.) I have been performing routine maintenance including repairing the disk and permissions, as well as running the cron scripts. I am aware of

  • Having trouble with software update today for ipod touch

    I connected my touch to my WindowXP machine today and itunes indicated there was an update for the device (1.1.2...i believe). I was already running the latest version of itunes. The touch update downloaded and then ran for a long time but never seem