wood burning stoves 2.0*
The moose likes JSF and the fly likes Database connection using JBoss Seam & JBoss Tools for Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Database connection using JBoss Seam & JBoss Tools for Eclipse" Watch "Database connection using JBoss Seam & JBoss Tools for Eclipse" New topic
Author

Database connection using JBoss Seam & JBoss Tools for Eclipse

Peter Irmstadt
Greenhorn

Joined: Mar 01, 2009
Posts: 24
Hi!

I want to learn JBoss Seam using few books I bought. I'm quite new to Java EE and have only done a little bit using JSF. Nevertheless I read what the Seam framework does and think this is what I want to do.

I understood the main concept of JSF and Seam, but I can't get any database example to work. I am using JBoss Tools for Eclipse to generate the (EAR) projects and using MySQL as database backend.

What I didn't understand yet: Do I have to create the database tables or will the EJB component of Seam will do that from the entity beans?

I tried both, but it didn't work. I can't even get the registry example working. The errors vary, sometimes it is "javax.el.PropertyNotFoundException" and "Target unreachable" and sometimes it is "javax.ejb.EJBTransactionRolledbackException: Unknown entity".

There must be something I am doing wrong:

1) Creating a new EAR project using JBoss Tools
2) Choosing an existing MySQL database as data source (ping successful)
3) Creating a new entity bean using @Name, @Entity like



4) Create a new java class using @Stateless and @Name, as well as a manager class like



Where might be my mistake?

Thank you so much in advance!
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Usually JBoss provide a Data Source XML file you have to edit to set your database specifics. Have you looked at the JBoss AS Admin Guide?


SCJP, SCJD, SCWCD, SCBCD
Peter Irmstadt
Greenhorn

Joined: Mar 01, 2009
Posts: 24
Thank you for your answer!

Eclipse generates a file "projectname-ds.xml" that is deployed to the JBoss AS and should be a replacement for a direct server configuration shouldn't it?

I sometimes read about a file "persistence.xml". What is that file about? It isn't generated automatically by JBoss Tools. Do I need it?
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
When you have set up your JBoss first copy the server/default folder into your server/project folder or just rename the default folder into your project folder. Now you can create a mysql-ds.xml data source file. I don't know what the persistence.xml is. Which JBoss version do you use?
Peter Irmstadt
Greenhorn

Joined: Mar 01, 2009
Posts: 24
What server/project folder do you mean?

I use the JBoss AS version 4.2.3.GA as well as the newest version 5.
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
I don't know JBoss 5 but for JBoss 4.2.X you have a server directory once you installed your JBoss. The server directory contains a default directory (name default) which you can either rename to your project name or whatever name you like. Or you can copy and paste that default directory and rename it too.
 
GeeCON Prague 2014
 
subject: Database connection using JBoss Seam & JBoss Tools for Eclipse