[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Refering to a datasource wih its ENC name

MarcusDidiusFalco do-not-reply at jboss.com
Wed Oct 24 05:25:38 EDT 2007


Hallo!

I have a datsource 

<datasources>
  |   <local-tx-datasource>
  |     <jndi-name>FencingDS</jndi-name>
  |     <connection-url>jdbc:mysql://localhost:3306/fencing</connection-url>
  |      .....
  |      </local-tx-datasource>
  | </datasources>

deployed. Using the JMX console it shows up in the JNDI java: Namespace under FencingDS.

So I want to get a connection from it in an EJB
ctx = new InitialContext();
  | DataSource ds = (DataSource) ctx.lookuk("java:/comp/env/jdbc/FencingDS");
  | Connection con = (Connection) ds.getConnection();

ejb-jar.xml:
<ejb-jar>
  | 	<enterprise-beans>
  | 		<session>
  | 			<description>TestBean </description>
  | 			<ejb-name>TestBean</ejb-name>
  | 				<resource-ref>
  | 					<description>Beschreibung der Resourcen</description>
  | 					<res-ref-name>jdbc/FencingDS</res-ref-name>
  | 					<res-type>javax.sql.DataSource</res-type>
  | 					<res-auth>Container</res-auth>
  | 				</resource-ref>
  | 		</session>
  | 	</enterprise-beans>
  | </ejb-jar>

In jboss.xml I try to map the global JNDI name to the ENC name:
<jboss>
  | 	<enterprise-beans>
  | 		<session>
  | 			<ejb-name>TestBean</ejb-name>
  | 			<resource-ref>
  | 				<res-ref-name>jdbc/FencingDS</res-ref-name>
  | 				<resource-name>java:FencingDS</resource-name>
  | 			</resource-ref>
  | 		</session>
  | 	</enterprise-beans>
  | </jboss>

But when I try to deploy the jar I always get an Exception
java.lang.RuntimeException: mapped-name is required for jdbc/FencingDS of deployment TestBean
and the EJB is not bound.

I have so far not found a reference how to do this right.

I would greatly appreciate any help.

Thanks,

Hans

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098189#4098189

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098189



More information about the jboss-user mailing list