permaculture playing cards*
The moose likes JSF and the fly likes Core Java Server Faces 2 - Database (Ch 5) example, not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Core Java Server Faces 2 - Database (Ch 5) example, not working" Watch "Core Java Server Faces 2 - Database (Ch 5) example, not working" New topic
Author

Core Java Server Faces 2 - Database (Ch 5) example, not working

Camilo Morales
Ranch Hand

Joined: Jul 14, 2007
Posts: 91
Hey ranchers,

I'm kinda new in this technology and thats why Im reading this great book. I'm in chapter 5 and trying to run the Database example, but Glassfish keeps telling me that he can not find the Database that the CustomerBeans is looking up. I am VERY VERY noob in glassfish (how I miss you JBoss) but since all the examples are made to work with Netbeans and Glassfish, I thought that this was a great opportunity to get to know this two products. (I normally work with Eclipse and JBoss).

Anyway ... when I saw the lookup to the databse in the CustomerBean class, I thought (I hoped) that this database was like HiperSonic in JBoss, I mean, that it comes inside the AS, but the NameNotBound exception is telling that Glassfish can not find the database.

Here is the lookup I'm telling you:

DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mydb");


Could anyone tell me if I have to deploy the DB descriptor (and install a DB in my pc), and if so ,,, where should I put the descriptor (where is the JBoss_Root\server\default\deploy directory in Glassfish ??) ??

Thanks ranchers,


Camilo Morales<br />SCJP 5, SCBCD 5
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

I'm not sure if this can help you since I don't have any Core JavaServer Faces book. But I've used glassfish and NetBeans for quite some time.

If you want to configure the JDBC inside glassfish, you need to login to admin console, and then click Resources->JDBC Resources. Create a new JDBC resources. By default, the Derby connection pool has already been configured.

Hope this helps.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Or you can change the datasource to use defaultDS and just copy the war file into the deploy directory of your JBoss instance.

Mark
(Jboss employee)


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Camilo Morales
Ranch Hand

Joined: Jul 14, 2007
Posts: 91
Thank you both for your replies.

Yeah, with JBoss I just deleted the resource-ref from the web.xml and change the lookup to java:/DefaultDS and it works perfectly. Anyway, it was mission imposible to make it run in Glassfish ... I guess Im still on the beginning of the learning curve for this product.

Regards,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Core Java Server Faces 2 - Database (Ch 5) example, not working
 
Similar Threads
books for j2ee
Using ant create-tables in NetBeans 5.5
How to use configured datasource
Tomcat 7: Can I configure it so that I don't need to use “java:/comp/env” in the code?
Binding DataSource with JBoss