jQuery in Action, 2nd edition*
The moose likes JBoss/WildFly and the fly likes won't create tables with jaws.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "won Watch "won New topic
Author

won't create tables with jaws.xml

Matthew Webster
Ranch Hand

Joined: May 10, 2001
Posts: 51
Hi peeps,
I've had a look through the back-dated articles, so if the answer to this is there, I'm afraid I missed it.
When I have the ejb-jar.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<description>Service test application</description>
<display-name>Service EJBs</display-name>
<enterprise-beans>
<entity>
<cmp-field>
<description>Primary key</description>
<field-name>index</field-name>
</cmp-field>
<cmp-field>
<description>Description reference to translation table</description>
<field-name>description</field-name>
</cmp-field>
<cmp-field>
<description>Index entry</description>
<field-name>entry</field-name>
</cmp-field>
<cmp-field>
<description>Jndi name of bean used to access this entry's data</description>
<field-name>jndi</field-name>
</cmp-field>
<cmp-field>
<description>The locale this note is used in</description>
<field-name>locale</field-name>
</cmp-field>
<cmp-field>
<description>ID of the editor of this value</description>
<field-name>editor</field-name>
</cmp-field>
<cmp-field>
<description>The date this value was edited</description>
<field-name>edit_date</field-name>
</cmp-field>
<cmp-field>
<description>ID of the creator of this record</description>
<field-name>author</field-name>
</cmp-field>
<cmp-field>
<description>Date this record was created</description>
<field-name>auth_date</field-name>
</cmp-field>
<ejb-name>IndexEJB</ejb-name>
<local-home>server.entity.index.LocalIndexHome</local-home>
<prim-key-class>java.lang.Integer</prim-key-class>
<primkey-field>index</primkey-field>
<local>server.entity.index.LocalIndex</local>
<ejb-class>server.entity.index.IndexBean</ejb-class>
<persistence-type>Container</persistence-type>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>INDEX</abstract-schema-name>
</entity>

</enterprise-beans>


<assembly-descriptor>

<container-transaction>
<description>Transaction attributes for 'IndexEJB' methods</description>
<method>
<ejb-name>IndexEJB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>

<security-role>
<description>This role represents everyone who is allowed full access bean.</description>
<role-name>everyone</role-name>
</security-role>
</assembly-descriptor>

</ejb-jar>

On it's own this causes JBoss to create the table in my MySQL database.
(Problem One: I cannot actually see the table in the database. I have only one installation of MySQL and only one database. Though this is not a MySQL question as that is not my main concern here.)
Problem Two: When I use the JAWS.xml file...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jaws PUBLIC
"-//JBoss//DTD JAWS 2.4//EN"
"http://www.jboss.org/j2ee/dtd/jaws_2_4.dtd">
<jaws>
<datasource>java:/MysqlDS</datasource>
<type-mapping>mySQL</type-mapping>
<debug>true</debug>
<default-entity>
<select-for-update>false</select-for-update>
<create-table>true</create-table>
<remove-table>false</remove-table>
<time-out>300</time-out>
<tuned-updates>true</tuned-updates>
<pk-constraint>false</pk-constraint>
</default-entity>

<enterprise-beans>

<entity>
<ejb-name>IndexEJB</ejb-name>
<table-name>INDEX</table-name>
<read-only>false</read-only>
<create-table>true</create-table>

<cmp-field>
<field-name>index</field-name>
<column-name>INDEX</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>NUMBER(10)</sql-type>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<column-name>DESCRIPTION</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>NUMBER(10)</sql-type>
</cmp-field>
<cmp-field>
<field-name>entry</field-name>
<column-name>ENTRY</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(256)</sql-type>
</cmp-field>
<cmp-field>
<field-name>jndi</field-name>
<column-name>JNDI</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(256)</sql-type>
</cmp-field>

<cmp-field>
<field-name>locale</field-name>
<column-name>LOCALE</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(10)</sql-type>
</cmp-field>
<cmp-field>
<field-name>editor</field-name>
<column-name>EDITOR</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(10)</sql-type>
</cmp-field>
<cmp-field>
<field-name>edit_date</field-name>
<column-name>EDIT_DATE</column-name>
<jdbc-type>DATE</jdbc-type>
<sql-type>DATE</sql-type>
</cmp-field>
<cmp-field>
<field-name>author</field-name>
<column-name>AUTHOR</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(10)</sql-type>
</cmp-field>
<cmp-field>
<field-name>auth_date</field-name>
<column-name>AUTH_DATE</column-name>
<jdbc-type>DATE</jdbc-type>
<sql-type>DATE</sql-type>
</cmp-field>
</entity>

</enterprise-beans>
</jaws>

JBoss refuses to create the tables in the database (they are not there to begin with and I get no message regarding their creation or lack of creation at all).

Apart from an explanation of the above problems, what I would really like is a description of exactly what is required to get JBoss to create a table from a bean definition and how that definition should be provided.
Thank you all in advance, and Happy New Year,
Matt.


Matthew Webster - eudoxus@freeuk.com<br /><a href="http://www.matthewwebster.homeunix.net/" target="_blank" rel="nofollow">http://www.matthewwebster.homeunix.net/</a>
Matthew Webster
Ranch Hand

Joined: May 10, 2001
Posts: 51
Ok, it appears that JBoss is actually creating the tables and dropping them immediately. I'm not sure why, so if anyone has any ideas on this I'd love to know.
Extract from log (which is another thing... anyone have good advice on configuring the logging in JBoss?)...
[15:39:41,661,JAWSPersistenceManager] Init SQL: CREATE TABLE INDEX (AUTHOR VARCHAR(10),EDIT_DATE DATE,EDITOR VARCHAR(10),INDEX NUMBER(10),AUTH_DATE DATE,LOCALE VARCHAR(10),ENTRY VARCHAR(256),DESCRIPTION NUMBER(10),JNDI VARCHAR(256))
[15:39:41,661,JAWSPersistenceManager] Destroy SQL: DROP TABLE INDEX
[15:39:41,661,JAWSPersistenceManager] Exists SQL: SELECT COUNT(*) FROM INDEX WHERE INDEX=?
Any ideas on what's going on here?

Matt.
Alexandre Marcondes
Greenhorn

Joined: Jan 31, 2003
Posts: 3
Matthew,
What is going on is that JBoss is setting up the queries it needs to create, drop, select, update and insert into that table. It is not executing the queries in any way ... it only reported what are the queries ...
What version of JBoss are you using?
Matthew Webster
Ranch Hand

Joined: May 10, 2001
Posts: 51
Thanx
I had got quite some way into working through all that - things took me away from it. I do, however, understand most of it now, having gone through the logs in detail and playing around with jaws.xml settings.
I'm using JBoss 2.4.4. I don't really have the time to get to grips with the latest version (due to getting to grips with lots of other things) unless anyone thinks it is really worth it- I've not heard good things so far.

Cheers,
Matt.
Bijoy Sivan
Greenhorn

Joined: Jan 30, 2003
Posts: 6
Hi,
>>>>On it's own this causes JBoss to create the table in my MySQL database.
>>>>>(Problem One: I cannot actually see the table in the database.
JBOSS comes with a default database server hypersonic. If the JBOSS is giving you the message that created "somebean" table successfully It has created the table in the default database(Hypersonic). If you have to change the database then you have to copy mysql-service.xml to the default/deploy directory from docs/examples/jca. Here you can configure the database location and which database your program is going to use for creating tables.
Hope this helps you
Bijoy
Fred Grott
Ranch Hand

Joined: Oct 05, 2002
Posts: 346
Originally posted by Matthew Webster:
Hi peeps,
I've had a look through the back-dated articles, so if the answer to this is there, I'm afraid I missed it.
When I have the ejb-jar.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<description>Service test application</description>
<display-name>Service EJBs</display-name>
<enterprise-beans>
<entity>
<cmp-field>
<description>Primary key</description>
<field-name>index</field-name>
</cmp-field>
<cmp-field>
<description>Description reference to translation table</description>
<field-name>description</field-name>
</cmp-field>
<cmp-field>
<description>Index entry</description>
<field-name>entry</field-name>
</cmp-field>
<cmp-field>
<description>Jndi name of bean used to access this entry's data</description>
<field-name>jndi</field-name>
</cmp-field>
<cmp-field>
<description>The locale this note is used in</description>
<field-name>locale</field-name>
</cmp-field>
<cmp-field>
<description>ID of the editor of this value</description>
<field-name>editor</field-name>
</cmp-field>
<cmp-field>
<description>The date this value was edited</description>
<field-name>edit_date</field-name>
</cmp-field>
<cmp-field>
<description>ID of the creator of this record</description>
<field-name>author</field-name>
</cmp-field>
<cmp-field>
<description>Date this record was created</description>
<field-name>auth_date</field-name>
</cmp-field>
<ejb-name>IndexEJB</ejb-name>
<local-home>server.entity.index.LocalIndexHome</local-home>
<prim-key-class>java.lang.Integer</prim-key-class>
<primkey-field>index</primkey-field>
<local>server.entity.index.LocalIndex</local>
<ejb-class>server.entity.index.IndexBean</ejb-class>
<persistence-type>Container</persistence-type>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>INDEX</abstract-schema-name>
</entity>

</enterprise-beans>


<assembly-descriptor>

<container-transaction>
<description>Transaction attributes for 'IndexEJB' methods</description>
<method>
<ejb-name>IndexEJB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>

<security-role>
<description>This role represents everyone who is allowed full access bean.</description>
<role-name>everyone</role-name>
</security-role>
</assembly-descriptor>

</ejb-jar>

On it's own this causes JBoss to create the table in my MySQL database.
(Problem One: I cannot actually see the table in the database. I have only one installation of MySQL and only one database. Though this is not a MySQL question as that is not my main concern here.)
Problem Two: When I use the JAWS.xml file...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jaws PUBLIC
"-//JBoss//DTD JAWS 2.4//EN"
"http://www.jboss.org/j2ee/dtd/jaws_2_4.dtd">
<jaws>
<datasource>java:/MysqlDS</datasource>
<type-mapping>mySQL</type-mapping>
<debug>true</debug>
<default-entity>
<select-for-update>false</select-for-update>
<create-table>true</create-table>
<remove-table>false</remove-table>
<time-out>300</time-out>
<tuned-updates>true</tuned-updates>
<pk-constraint>false</pk-constraint>
</default-entity>

<enterprise-beans>

<entity>
<ejb-name>IndexEJB</ejb-name>
<table-name>INDEX</table-name>
<read-only>false</read-only>
<create-table>true</create-table>

<cmp-field>
<field-name>index</field-name>
<column-name>INDEX</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>NUMBER(10)</sql-type>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<column-name>DESCRIPTION</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>NUMBER(10)</sql-type>
</cmp-field>
<cmp-field>
<field-name>entry</field-name>
<column-name>ENTRY</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(256)</sql-type>
</cmp-field>
<cmp-field>
<field-name>jndi</field-name>
<column-name>JNDI</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(256)</sql-type>
</cmp-field>

<cmp-field>
<field-name>locale</field-name>
<column-name>LOCALE</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(10)</sql-type>
</cmp-field>
<cmp-field>
<field-name>editor</field-name>
<column-name>EDITOR</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(10)</sql-type>
</cmp-field>
<cmp-field>
<field-name>edit_date</field-name>
<column-name>EDIT_DATE</column-name>
<jdbc-type>DATE</jdbc-type>
<sql-type>DATE</sql-type>
</cmp-field>
<cmp-field>
<field-name>author</field-name>
<column-name>AUTHOR</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(10)</sql-type>
</cmp-field>
<cmp-field>
<field-name>auth_date</field-name>
<column-name>AUTH_DATE</column-name>
<jdbc-type>DATE</jdbc-type>
<sql-type>DATE</sql-type>
</cmp-field>
</entity>

</enterprise-beans>
</jaws>

JBoss refuses to create the tables in the database (they are not there to begin with and I get no message regarding their creation or lack of creation at all).

Apart from an explanation of the above problems, what I would really like is a description of exactly what is required to get JBoss to create a table from a bean definition and how that definition should be provided.
Thank you all in advance, and Happy New Year,
Matt.


Matt do by chance have MySQL setup for INNODB type tables? If so you still need an index key for inndob tables ..mysql is dropping it in that case becasue you do not have the index column defined for innodb..if you have winMysql open when you do the start up you should see the mysql system errors that its not settingup the table..it will be an error -1 if you try the saem create table statement from a front end such as iSQL Viewer if you forget the index column when MySQL is set to INNODB tables..


MobileBytes blog - Sharing Technology - My Programming Knols
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: won't create tables with jaws.xml
 
Similar Threads
Can't deploy EJB to JBOSS after adding '@ejb.finder' clause
JBoss Primary Key Generation
CMP 2.0 problem in Jboss 4.0.2
CMP with JBOSS
CMR configuration confusion