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]

Reply via email to