Hi,

Jeff Barnes wrote:
> First, I don't understand how to use ejx. I assume the
> methodology code, create deployment descriptor, create
> jboss.xml, create jaws.xml. I have code. I don't have
> any config files. So, I open ejx and click 'New
> ejb-jar.xml'. What next? The only notable actions are
> "new" and "open" and the rest of the menu bar. I don't
> understand how to create the ejb-jar.xml. What works
> for everyone else? Do I need to create the files
> manually then edit with ejx?

I agree. There seems to be no actionable widgets in the GUI to add a new
bean, etc. I gave up and did my xml manually. I have snipped some examples
below so you can copy/apply them.

> Second, I don't know how to use jboss cmp with oracle.
> I have the drivers. What do I do now?

You have to edit conf/jboss.conf and perhaps conf/jboss.properties. Again, I
have snipped samples below.

Note that the <resource-ref> blocks were supplied by Dave Smith in answer to
one of my queries a few days ago. Thanks again Dave!

> Sorry for the naive questions, but I'm at the point
> where I've exhausted the alternatives.
>
> Jeff Barnes

No problem, Jeff. I think you are in good company.

Cheers,
Vaughn

=== place something like this in conf/jboss.conf ===

<MLET CODE = "org.jboss.jdbc.DataSourceImpl"
ARCHIVE="jboss.jar,cloudscape.jar" CODEBASE="../lib/ext/">
   <ARG TYPE="java.lang.String"
VALUE="jdbc:cloudscape:CloudscapeDB;create=true">
   <ARG TYPE="java.lang.String" VALUE="Cloudscape">
   <ARG TYPE="java.lang.String" VALUE="COM.cloudscape.core.JDBCDriver">
   <ARG TYPE="java.lang.String" VALUE="">
   <ARG TYPE="java.lang.String" VALUE="">
</MLET>

-- Note: the first line is the db access url; second is the db name as you
refer to it in xml and apps; third is name of driver; forth and fifth is
username and password, perhaps "scott" and "tiger" for Oracle :-) Sorry I
don't have a specific Oracle example at this time. Please post your results
when you get it working...

=== perhaps place something like this in conf/jboss.properties ===

cloudscape.system.home=/c:/work/app/cloudscape

-- Note: This line allows cloudscape's in-VM engine to access the database
w/o doing client-server. I think this nullifies the use of the first line
above in the conf/jboss.conf example... You will likely not put anything
like this in your properties file since Oracle will be client-server, but I
am just documenting it here for others.

=== ejb-jar.xml ===

-- Note: This example only shows how to use BMP and how to access the
database from within a session bean by doing direct queries. If you want to
do CMP you may have to use other examples, such as bank.jar (source url
posted a few days ago). I think you will be most interested in the
<resource-ref /> blocks.

<?xml version="1.0" encoding="Cp1252"?>

<ejb-jar>
     <description>Some Application</description>
     <display-name>SomeApp</display-name>
     <enterprise-beans>

      <session>
        <display-name>MainAccessBean</display-name>
        <ejb-name>MainAccessBean</ejb-name>
        <home>com.co.app.ejb.main.MainAccessHome</home>
        <remote>com.co.app.ejb.main.MainAccess</remote>
        <ejb-class>com.co.app.ejb.main.MainAccessBean</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Bean</transaction-type>
<!-- stateful session bean not working -- commented out for now
        <ejb-ref>
          <ejb-ref-name>ejb/GroupBean</ejb-ref-name>
          <ejb-ref-type>Session</ejb-ref-type>
          <home>com.co.app.ejb.group.GroupHome</home>
          <remote>com.co.app.ejb.group.Group</remote>
          <ejb-link>GroupBean</ejb-link>
        </ejb-ref>
-->
        <resource-ref>
          <description>Default datasource</description>
          <res-ref-name>jdbc/Cloudscape</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
        </resource-ref>
      </session>

<!-- note: stateful session bean not working at this time
-->
      <session>
        <display-name>GroupBean</display-name>
        <ejb-name>GroupBean</ejb-name>
        <home>com.co.app.ejb.group.GroupHome</home>
        <remote>com.co.app.ejb.group.Group</remote>
        <ejb-class>com.co.app.ejb.group.GroupBean</ejb-class>
        <session-type>Stateful</session-type>
        <transaction-type>Container</transaction-type>
        <ejb-ref>
          <ejb-ref-name>ejb/ItemBean</ejb-ref-name>
          <ejb-ref-type>Entity</ejb-ref-type>
          <home>com.co.app.ejb.item.ItemHome</home>
          <remote>com.co.app.ejb.item.Item</remote>
          <ejb-link>ItemBean</ejb-link>
        </ejb-ref>
        <resource-ref>
          <description>Default data source</description>
          <res-ref-name>jdbc/Cloudscape</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
        </resource-ref>
      </session>

      <entity>
        <display-name>ItemBean</display-name>
        <ejb-name>ItemBean</ejb-name>
        <home>com.co.app.ejb.item.ItemHome</home>
        <remote>com.co.app.ejb.item.Item</remote>
        <ejb-class>com.co.app.ejb.item.ItemBean</ejb-class>
        <persistence-type>Bean</persistence-type>
        <prim-key-class>java.lang.Integer</prim-key-class>
        <reentrant>False</reentrant>
        <resource-ref>
          <description>Default data source</description>
          <res-ref-name>jdbc/Cloudscape</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
        </resource-ref>
      </entity>
     </enterprise-beans>
   </ejb-jar>

=== jboss.xml ===

-- Note: I think you will be most interested in the <resource-ref /> blocks.

<?xml version="1.0" encoding="Cp1252"?>

<jboss>
  <enterprise-beans>

    <session>
      <ejb-name>MainAccessBean</ejb-name>
      <jndi-name>appname/MainAccess</jndi-name>
      <configuration-name>Default Stateless SessionBean</configuration-name>
<!-- stateful session beans not working -- commented out for now
      <ejb-ref>
        <ejb-ref-name>ejb/GroupBean</ejb-ref-name>
        <jndi-name></jndi-name>
      </ejb-ref>
-->
      <resource-ref>
        <res-ref-name>jdbc/Cloudscape</res-ref-name>
        <resource-name>jdbc/Cloudscape</resource-name>
      </resource-ref>
    </session>

    <session>
      <ejb-name>GroupBean</ejb-name>
      <jndi-name>appname/Group</jndi-name>
      <configuration-name>Stateful SessionBean</configuration-name>
      <ejb-ref>
        <ejb-ref-name>ejb/ItemBean</ejb-ref-name>
        <jndi-name></jndi-name>
      </ejb-ref>
      <resource-ref>
        <res-ref-name>jdbc/Cloudscape</res-ref-name>
        <resource-name>jdbc/Cloudscape</resource-name>
      </resource-ref>
    </session>

    <entity>
      <ejb-name>ItemBean</ejb-name>
      <jndi-name>appname/Item</jndi-name>
      <configuration-name>BMP EntityBean</configuration-name>
      <resource-ref>
        <res-ref-name>jdbc/Cloudscape</res-ref-name>
        <resource-name>jdbc/Cloudscape</resource-name>
      </resource-ref>
    </entity>

    <secure>false</secure>

  </enterprise-beans>

-- -- --  from here to eof is standard stuff; get it from an example or
tutorial...

=== finally, a code snippet for doing database access; BMP, that is ===

-- Note: don't for get to do ds.close() in your calling method to return the
connection to the pool...

  private Connection connectToDatabase() throws NamingException,
SQLException
  {
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup("Cloudscape");
    return ds.getConnection();
  }




--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to