Norman-

I assume you are doing a CMP bean.  In that case, you also need to
identify the datasource in your jaws.xml file:  
   <jaws>
     <datasource>SQLServer</datasource>
     <type-mapping>SQLServer</type-mapping>
     <type-mappings>
       <type-mapping>
         <name>SQLServer</name>
etc.   Use EJX to set that up.  Just make sure to set the datasource to
the jboss.conf MLET name you gave below.

Actually (as was pointed out to me earlier today) the resource-ref in
ejb-jar.xml means nothing for setting your CMP datasource.  Also, the
jboss.xml file is not needed either.

As for why the bean picks up the right db on first deploy, but not on
restart of the server, I have been noticing rather peculiar behavior in
the autodeployer.  Notified these guys, but haven't heard back yet on
it, so may look into myself (no good debugger on hand for me yet)

Norrman Per wrote:
> 
> Hi,
> 
> As part of my EJB self-education, I tried hooking up MS SQL Server
> to Jboss (PR4). The problem is that my bean works when it is auto-deployed,
> but after jboss is restarted, it picks up the wrong data source.
> Maybe it's obvious .... but I can't see what's wrong.
> 
> I added an MLET section to jboss.conf, like so:
> 
> <MLET CODE = "org.jboss.jdbc.DataSourceImpl"
> ARCHIVE="jboss.jar,jdbc2_0-stdext.jar" CODEBASE="../lib/ext/">
>    <ARG TYPE="java.lang.String" VALUE="jdbc:odbc:cansql013">
>    <ARG TYPE="java.lang.String" VALUE="SQLServer">
>    <ARG TYPE="java.lang.String" VALUE="sun.jdbc.odbc.JdbcOdbcDriver">
>    <ARG TYPE="java.lang.String" VALUE="sa">
>    <ARG TYPE="java.lang.String" VALUE="">
> </MLET>
> 
> I also added the JDBC driver to jboss.properties.
> 
> I wanted to just test if I could read something from an existing
> table, so created a stateless session bean that obtains the datasource
> and performs a simple select. Here is my ejb-jar and jboss.xml,
> respectively:
> (They are both created using EJX, btw).
> 
> ejb-jar:
> <ejb-jar>
>      <enterprise-beans>
>        <session>
>          <display-name>My SessionBean</display-name>
>          <ejb-name>test.MySession</ejb-name>
>          <home>test.MySessionHome</home>
>          <remote>test.MySession</remote>
>          <ejb-class>test.MySessionBean</ejb-class>
>          <session-type>Stateless</session-type>
>          <transaction-type>Container</transaction-type>
>          <env-entry>
>            <env-entry-name>message</env-entry-name>
>            <env-entry-type>java.lang.String</env-entry-type>
>            <env-entry-value>This stuff is from the
> environment!</env-entry-value>
>          </env-entry>
>          <resource-ref>
>            <res-ref-name>jdbc/myDataSource</res-ref-name>
>            <res-type>javax.sql.DataSource</res-type>
>            <res-auth>Container</res-auth>
>          </resource-ref>
>        </session>
>      </enterprise-beans>
> </ejb-jar>
> 
> jboss.xml
> 
> <jboss>
>      <secure>false</secure>
>      <container-configurations />
>      <resource-managers>
>        <resource-manager res-class="org.jboss.ejb.deployment.JDBCResource">
>          <res-name>SQLServer</res-name>
>          <res-jndi-name>jdbc/myDataSource</res-jndi-name>
>        </resource-manager>
>      </resource-managers>
>      <enterprise-beans />
> </jboss>
> 
> So, to summarize:
> After auto-deploying the jar, everything works fine.
> After stopping and restarting jboss, jdbc/myDataSource seems to be bound to
> Hypersonic instead of SQLServer!
> 
> /Per Norrman
> 
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Problems?:           [EMAIL PROTECTED]

-- 
Jeffrey & Nikole Bonevich
Maxmillian Bonevich
Ann Arbor, Michigan
[EMAIL PROTECTED]
http://www.bonevich.com


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

Reply via email to