users@glassfish.java.net

Re: Glassfish v3 and mysql database access using Eclipse Galileo

From: <glassfish_at_javadesktop.org>
Date: Fri, 19 Feb 2010 15:03:31 PST

Well, I've finally got past this problem and thought I would post what I did just in case in helps anyone else.

I'm not completely sure, but I think the base problem was the version of Java running on my Mac. I had the update for Java which gave me 1.6.0_17 as is needed by this version of Eclipse, but something wasn't set up correctly. When I did "java -version" at the terminal, it would tell me I was running the right version, but when I ran a test program from a browser window, it said I was still running 1.5.x. I even went to the Genius Bar at the Apple store and they couldn't figure out why it wasn't picking up 1.6, but I ended up just upgrading to Mac OS X 10.6.2 which runs the correct version of Java by default (I was running 10.5.8 previously).

After I upgraded, things still didn't work, so I completely deleted the GlassFish Tools bundle and Flash Builder 4 and reinstalled everything from scratch. I think it did change something because things seemed to operate slightly differently (e.g., the GlassFish v3 server was available by default and didn't have to be downloaded). Still, when I tried to run my little test app, it still couldn't access the database.

Finally, I randomly realized that I had the EntityManager injection located in a service file rather than in the bean file directly and once I moved it to the bean, the EntityManager variable was injected correctly. I'm not sure which of these things actually caused the problem or if it was a combination of all of them, but it finally happens correctly.

The last issue I had to get past was figuring out where the mysql-connector-java-5.1.7-bin.jar file should be. I put it in ~workspace/.metadata/.plugins/com.sun.enterprise.jst.server.sunappsrv92/domain1/lib/ext/ and restarted the server and was then finally able to access the database!
[Message sent by forum member 'drrevis' (renee_at_leadingstep.com)]

http://forums.java.net/jive/thread.jspa?messageID=387681