[jboss-user] [EJB 3.0] - Re: help getting started with eclipse

wiggy do-not-reply at jboss.com
Fri Sep 7 05:25:30 EDT 2007


I wondered about that also - but i dont think it is that, but just in case i created the table in the mysql db by hand - no difference.

In addition i've not actually deployed the code to the server - as it wont compile - so how could eclipse use the datasource when i'm not running the code ?

what i have at present is

1.  hand created catalog and one table crafted by hand using mysql admin 
     a user account and password created and granted all rights on the catlog which i called 'embed'

2.  in the AS i deployed a new JTA datasource call 'jdbc/embedDS and pointed it at the mysql url and catalog.


  | 
  | <datasources>
  | <xa-datasource> 
  | 	<jndi-name>jdbc/embedDS</jndi-name> 
  | 	<use-java-context>false</use-java-context>	
  | 	<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class > 
  | 	<xa-datasource-property name="URL">jdbc:mysql://localhost:3306/embed</xa-datasource-property> 
  | 	<user-name>embed</user-name> 
  | 	<password>embed</password> 
  | 	<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> 
  | 	<max-pool-size>5</max-pool-size> 
  | 	<min-pool-size>1</min-pool-size> 
  | 	<blocking-timeout-millis>2000</blocking-timeout-millis> 
  | 	<idle-timeout-minutes>2</idle-timeout-minutes> 
  | 	<track-connection-by-tx>true</track-connection-by-tx> 
  | 	<no-tx-separate-pools>false</no-tx-separate-pools> 
  | 	<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name> 
  | 	<metadata> 
  | 	    <type-mapping>mySQL</type-mapping> 
  | 	</metadata> 
  | </xa-datasource> 
  | 

that i think is okay (cant test it yet) but it appears in the JMX console as deployed - and i wrote an external jndi lookup to get a connection on theDS and close it (no sql commands) and that didnt error.

3.  I have created an EJB project in eclipse for ejb3 and perisistence facets.  I've setup the persistence XML ok (i hope) in the meta inf directory and pointed it a


  | 
  | <?xml version="1.0" encoding="UTF-8"?>
  | <persistence version="1.0" 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">
  |   <persistence-unit name="embedDS" transaction-type="JTA">
  |         <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |         <jta-data-source>jdbc/embedDS</jta-data-source>
  |         <class>org.model.Message</class>
  |         <properties>
  |             <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
  |             <property name="hibernate.show_sql" value="true"/>
  |         </properties>
  |     </persistence-unit>
  | </persistence>
  | 

4.  I have created the entity class in org.model as 

  | 
  | package org.model;
  | 
  | import javax.persistence.Column;
  | import javax.persistence.Entity;
  | import javax.persistence.GeneratedValue;
  | import javax.persistence.GenerationType;
  | import javax.persistence.Id;
  | import javax.persistence.*;
  | 
  | @Entity
  | @Table(name="message", catalog="embed")
  | public class Message 
  | {
  | 	private long messageID;
  | 	private String message;
  | 
  | 	@Id
  | 	@GeneratedValue(strategy=GenerationType.AUTO)
  | 	@Column(name="messageID")
  | 	public long getMessageID() {
  | 		return messageID;
  | 	}
  | 
  | 	public void setMessageID(long messageID) {
  | 		this.messageID = messageID;
  | 	}
  | 
  | 	public String getMessage() {
  | 		return message;
  | 	}
  | 
  | 	public void setMessage(String message) {
  | 		this.message = message;
  | 	}
  | 	
  | 	
  | 	
  | }
  | 

and thats the bit that has these blessed compile errors.

Given the bean hasnt been deployed - and i have set the hibernate properties to "create-drop" the tables i cant see how the compiler could be trying to use the datasource and getting confused.  It makes no difference whether i add or remove the table in mysql by hand or otherwise ?

my EJB project has the jboss4.2 jar set, including the mysql adapter jar and the the JRE 6 system library jar set.

Is there anything you can see that i'm doing stupid please 



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

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



More information about the jboss-user mailing list