score:2

Accepted answer

there are a number of issues i think.

first, the persistence.xml looks a bit odd, i would have expected something like this:

<?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="jpaproject2" transaction-type="jta">
    <provider>oracle.toplink.essentials.persistenceprovider</provider>
    <jta-data-source>jdbc/sample</jta-data-source>
    <class>model.customer</class>
</persistence-unit>
</persistence>

that is, a provider field, and the necessary fields to indicate that you're running in a server (jta-data-source). of course, jta-data-source has to refer to a datasource that you configured in glassfish.

next, i think it's quite odd that your application runs on ports 4848, normally that's the administrative listener for glassfish, and i'd expect only the admin console to run there. did you reconfigure your glassfish's ports?

one thing that puzzles me is how you got this far with such a configuration: it looks like toplink thinks it has to contact a derby running on localhost (port 1527 is standard for derby) so maybe there's still some other persistence.xml floating around? please check that.

about tutorials: i use glassfish a lot, but always with netbeans. here are a couple of links to tutorials from the netbeans site, they might help you.

it may be easiest to just install netbeans, follow the tutorials and have a look at all the files that get generated, netbeans automates the creation of a lot of this stuff and i have no idea what degree of assistance eclipse gives you with these files.

here is a rather complete tutorial based on eclipse: http://wiki.eclipse.org/eclipselink/examples/jpa/glassfishv2_web_tutorial

a last one: a tutorial for gf3 should get you going on gf2 as well, at least for these technologies (servlet and jpa). ok, gf3 comes with eclipselink instead of toplink essentials, but these two are not that different at all.

edit: when i saw tle trying to connect to a derby on localhost i forgot the part about mysql. this has been corrected now - references to how you should start derby have been removed.


Related Query

More Query from same tag