Hi All...

After being told that Orion supports the PD1 spec for EJB 2.0 dependent 
objects I went through the PD1 spec carefully and compared it to the PD2 
spec and changed my code accordingly. In fact, I have created a very 
stripped down example that fails. I also have looked carefully at the 
LogEntry class in the ATM example and its associated deployment descriptors 
and AccountEJB class. The best I can get Orion to do is throw a null 
pointer exception (pasted below) at deployment time. I have been trying a 
variety of things for many hours so far Friday and this weekend and still 
just the same, cryptic null pointer error.

I have posted the code and deployment descriptors below. I realize the 
error is mine, since I can successfully deploy the ATM example.

If someone could take a look and let me know what I screwed up, I would be 
greatly appreciative. This whole mess is pretty straightforward. In the 
PersonEJB class you'll see I used AddrDo for the varible name as in 
getAddrDo(), but I also tried to use a different name than the type, sich 
as getAddress(). If I remove the dependent object portions of this code and 
descriptor it works fine, except of course without the dependent.

Also, there is a servlet and web descriptors and application descriptors I 
didn't post to save bandwidth. If thats needed I'll gladly post it.

Thanks to everyone in advance. I'm sorry I'm asking so much, but the side 
of my head is bashed in from the brick wall.

Jim


C:\orion>java -jar orion.jar
Auto-unpacking 
C:\Orion-test-apps\Test20CmpDo\rel\Sample20EbDo-ver001a.ear... do
ne.
Auto-unpacking 
C:\Orion-test-apps\Test20CmpDo\rel\Sample20EbDo-ver001a\Sample20E
bDo-ver001a-web.war... done.
Auto-deploying Sample20EbDo (Assembly had been updated)...
Auto-deploying Sample20EbDo-ver001a-ejb.jar (ejb-jar.xml had been touched 
since
the previous deployment)... java.lang.NullPointerException
        at 
com.evermind.server.ejb.deployment.ContainerManagedField.equals(JAX)
        at java.util.HashMap.put(Unknown Source)
        at java.util.HashSet.add(Unknown Source)
        at java.util.AbstractCollection.addAll(Unknown Source)
        at java.util.HashSet.<init>(Unknown Source)
        at com.evermind.server.ejb.deployment.Dependent.zk(JAX)
        at com.evermind.server.ejb.compilation.f4.<init>(JAX)
        at com.evermind.server.ejb.compilation.f9.ss(JAX)
        at com.evermind.server.ejb.EJBContainer.by(JAX)
        at com.evermind.server.Application.by(JAX)
        at com.evermind.server.Application.ge(JAX)
        at com.evermind.server.ApplicationServer.rn(JAX)
        at com.evermind.server.ApplicationServer.apr(JAX)
        at com.evermind.server.ApplicationServer.ge(JAX)
        at com.evermind.server.hf.run(JAX)
        at java.lang.Thread.run(Unknown Source)
        at com.evermind.util.f.run(JAX)





<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise 
JavaBeans 2.0//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">
<ejb-jar>
        <description>Test Sample EJB 2.0 EB</description>
        <display-name>Person</display-name>
        <enterprise-beans>
                <entity>
                  <cmp-version>2.0</cmp-version>
                        <description>Person has an address DO</description>
                        <display-name>Test20CmpDo.eb.Person</display-name>
                        <ejb-name>Test20CmpDo.eb.Person</ejb-name>
                        <home>Test20CmpDo.eb.PersonHome</home>
                        <remote>Test20CmpDo.eb.Person</remote>
                        <ejb-class>Test20CmpDo.eb.PersonEJB</ejb-class>
                        <persistence-type>Container</persistence-type>
                        <prim-key-class>java.lang.String</prim-key-class>
                        <reentrant>True</reentrant>

                        <!-- Same failure with & without the next line -->
                        <cmp-field><field-name>addrDo</field-name></cmp-field>
                        
                        <cmp-field><field-name>userId</field-name></cmp-field>
                        <cmp-field><field-name>firstName</field-name></cmp-field>
                        <cmp-field><field-name>lastName</field-name></cmp-field>

                        <primkey-field>userId</primkey-field>
                </entity>
        </enterprise-beans>

  <dependents>
                <dependent>
                        <dependent-name>addrDo</dependent-name>
                        <dependent-class>Test20CmpDo.eb.AddrDo</dependent-class>
                        <cmp-field>street</cmp-field>
                        <cmp-field>city</cmp-field>
                        <cmp-field>state</cmp-field>
                        <cmp-field>zip</cmp-field>
                </dependent>
        </dependents>

        <relationships>
                <ejb-relation>
                        <ejb-relation-name>User-Address</ejb-relation-name>
                        
                        <ejb-relationship-role>
 
        <ejb-relationship-role-name>User-has-Address</ejb-relationship-role-name>
                                <multiplicity>one</multiplicity>
                                
<role-source><ejb-name>Test20CmpDo.eb.PersonEJB</ejb-name></role-source>
                                <cmr-field>
                                        <cmr-field-name>addrDo</cmr-field-name>
                                        
<cmr-field-type>Test20CmpDo.eb.AddrDo</cmr-field-type>
                                </cmr-field>
                        </ejb-relationship-role>
        
                        <ejb-relationship-role>
 
        <ejb-relationship-role-name>Address-belongsto-User</ejb-relationship-role-
name>
                                <multiplicity>one</multiplicity>
                                
<role-source><dependent-name>addrDo</dependent-name></role-source>
                        </ejb-relationship-role>
                </ejb-relation>
        </relationships>

   <assembly-descriptor>
      <security-role>
         <description>Users</description>
         <role-name>users</role-name>
      </security-role>
   </assembly-descriptor>
</ejb-jar>

//-------------------------------------------------------------------
// AddrDo.java
package Test20CmpDo.eb;

import java.io.*;

// Make this Serializable because the example does. We
// get the same failure with or without it.
public abstract class AddrDo implements Serializable {

        // Required by PD1 but not PD2
        public abstract AddrDo deepCopy();


        // ---------------------------------------------------------------
        // Public accessor/setters here
        // ---------------------------------------------------------------
        public abstract void setStreet(String sa);
        public abstract String getStreet();

        public abstract void setCity(String city);
        public abstract String getCity();

        public abstract void setState(String state);
        public abstract String getState();

        public abstract void setZip(String zip);
        public abstract String getZip();
}

//-------------------------------------------------------------------
// Person.java
package Test20CmpDo.eb;

import java.rmi.RemoteException;
import javax.ejb.EJBObject;


public interface Person extends EJBObject {

        // This field will be the primary key field
    public String getUserId() throws RemoteException;
    public void setUserId(String id) throws RemoteException;

    public String getLastName() throws RemoteException;
    public void setLastName(String ln) throws RemoteException;

    public String getFirstName() throws RemoteException;
    public void setFirstName(String fn) throws RemoteException;
}


//-------------------------------------------------------------------
// PersonEJB.java
package Test20CmpDo.eb;

import java.rmi.RemoteException;

import java.sql.*;
import java.util.Enumeration;
import java.util.Vector;
import java.util.Date;

import javax.ejb.*;
import javax.naming.*;
import javax.sql.DataSource;
import javax.transaction.*;

public abstract class PersonEJB implements EntityBean {

    protected EntityContext ejbContext;
        
    public void setEntityContext(EntityContext ctx) {
      ejbContext = ctx;
    }

    public void unsetEntityContext() {
           ejbContext = null;
    }

    public void ejbRemove() throws RemoveException {
    }

    public void ejbLoad() {
    }

    public void ejbStore() {
    }
        
    public void ejbPostCreate() throws CreateException {
    }

    // ------------------------------------------------------------
    public String ejbCreate() {
                trace("ejbCreate() entered");
                
                initToNull();
                
                setUserId("jarcher");
                setFirstName("Jim");
                setLastName("Archer");

                addAddress();
                
        trace("ejbCreate() exiting");

      // In CMP, should return null.
      return null;
    }

    // ------------------------------------------------------------
    public void ejbPassivate() {}
    public void ejbActivate() {}

    // ------------------------------------------------------------
        private void initToNull()
        {
                trace("initToNull() entered");

                setUserId(null);
                setFirstName(null);
                setLastName(null);

                trace("initToNull() exiting");
        }

        // ---------------------------------------------------------    
        private void trace(String text)
        {
                java.util.Date now = new java.util.Date();
                System.out.println("PersonEJB: " + now + " " + text);
        }


        // Create, get & set methods for our Address dependent object
        public abstract AddrDo createAddrDo();
        public abstract AddrDo getAddrDo();
        public abstract void setAddrDo(AddrDo addrDo);


    // User Methods -------------------------------------------
    public abstract String getUserId();
    public abstract void setUserId(String id);

    public abstract String getFirstName();
    public abstract void setFirstName(String fn);
        
        public abstract String getLastName();
    public abstract void setLastName(String ln);

        public void addAddress()
        {
                AddrDo newAddr = createAddrDo();
                newAddr.setStreet("10 Crestview Drive");
                newAddr.setCity("Greenville");
                newAddr.setState("RI");
                newAddr.setZip("02828");
                
                setAddrDo(newAddr);
        }
 }

//-------------------------------------------------------------------
// PersonHome.java
package Test20CmpDo.eb;

import java.rmi.RemoteException;
import java.util.*;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
import javax.ejb.FinderException;


public interface PersonHome extends EJBHome {
    Person create()
       throws CreateException, RemoteException;

    Person findByPrimaryKey(String userId)
       throws FinderException, RemoteException;

/*
    Collection findByLastname(String lastname)
       throws FinderException, RemoteException;

    Collection findByFullName(String lastname, String firstname)
       throws FinderException, RemoteException;

    Collection findAll()
       throws FinderException, RemoteException;
*/      
}







Reply via email to