[jboss-user] [EJB 3.0] - Re: Can a Stateless bean make a call to an entity bean to pe

oskar.carlstedt do-not-reply at jboss.com
Wed Jun 27 04:54:24 EDT 2007


Hi!

It seems like JBoss can't find your datasource. It also looks like you are using toplink, are you? The example bellow is for the normal JBoss EJB3 (on top of Hibernate). Anyway, the configuration shall still be the same (please correct me if I'm wrong) except some of the properties in persistence.xml.

So, you shall have a persistence.xml file packed with your ejb-jar-file. The file looks something like (the example is using MySQL-dialect. You shall probably use the Oracle dialect):

  | <persistence xmlns="http://java.sun.com/xml/ns/persistence"
  |     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
  |      http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
  |     version="1.0">
  |     <persistence-unit name="my-ejbs">
  |         <jta-data-source>
  | 		    <!--
  | 			    THIS NAME SHALL MAP AGAINST THE JNDI-NAME OF YOUR DATA SOURCE FILE
  | 			-->
  |             java:/service-fundorder-DS
  |         </jta-data-source>
  |         <properties>
  |             <property name="show_sql" value="true" />
  |             <property name="dialect"
  |                 value="org.hibernate.dialect.MySQLDialect" />
  |         </properties>
  |     </persistence-unit>
  | </persistence>
  | 

Then you must deploy a data-source-file that defines the connection to the database. The filename must end with -ds.xml, e.g. my-service.ds.xml This file looks something like (also MySQL). THere are plenty of such example files in the JBoss distro under docs/examples/jta:

  | <?xml version="1.0" encoding="UTF-8"?>
  | <datasources>
  |     <local-tx-datasource>
  |         
  |         <!--
  |             JNDI NAME OF DATA SOURCE - THIS NAME IS MAPPED IN PERSISTENCE.XML IN YOUR EAR FILE
  |         -->
  |         <jndi-name>my-service-DS</jndi-name>
  |         
  |         <!--
  |             Connect parameters
  |         -->
  |         <connection-url>
  |             jdbc:${jdbc.vendor}://${db.host}:${db.port}/${db.name}
  |         </connection-url>
  |         <user-name>${db.username}</user-name>
  |         <password>${db.password}</password>
  |         <driver-class>${jdbc.driverclass}</driver-class>
  |         
  |         <!--
  |             Minimum and maximum poolsize
  |         -->
  |         <min-pool-size>0</min-pool-size>
  |         <max-pool-size>5</max-pool-size>
  |         
  |         <!--
  |             No of minutes in idle state until connection is destroyed 
  |         -->
  |         <idle-timeout-minutes>1</idle-timeout-minutes>
  |         
  |         <!--
  |             Class used to detect if connection is valid or not. Using MySQL, this
  |             class shall only be used on drivers after 3.22.1 with "ping" support
  |         -->
  |         <valid-connection-checker-class-name>
  |             org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker
  |         </valid-connection-checker-class-name>
  |         
  |         <!--
  |             Class used when sorting exceptions
  |         -->
  |         <exception-sorter-class-name>
  |             org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
  |         </exception-sorter-class-name>
  |         
  | 
  |         <!--
  |             corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional)
  |         -->
  |         <metadata>
  |             <type-mapping>mySQL</type-mapping>
  |         </metadata>
  |     </local-tx-datasource>
  | </datasources>
  | 

Kind regards
//Oskar

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

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



More information about the jboss-user mailing list