1

I created a Web project in eclipse and adding a glassfish-resource.xml init and configure it with my database url. also I added a persistence.xml unit in my project and add a jta-datasource for my datasource defined in glassfish-resource.xml but when the application is being deployed on glassfish in ide I got error that : Lookup failed for 'java:module/jdbc/sportal' in SerialContext

my glassfish-resource.xml:

<resources>
<jdbc-connection-pool name="java:module/jdbc/sportalPool"
    res-type="javax.sql.DataSource" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
    pool-resize-quantity="1" max-pool-size="5" steady-pool-size="0"
    statement-timeout-in-seconds="30">
    <property name="User" value="root"></property>
    <property name="Password" value="1234"></property>
    <property name="portNumber" value="3306"></property>
    <property name="dataBaseName" value="sportal"></property>
    <property name="serverName" value="192.168.2.7"></property>
</jdbc-connection-pool>
<jdbc-resource pool-name="java:module/jdbc/sportalPool"
    jndi-name="java:module/jdbc/sportal"></jdbc-resource>

and my persistence.xml is:

<persistence version="2.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_2_0.xsd">
<persistence-unit name="PU" transaction-type="JTA">
    <jta-data-source>java:module/jdbc/sportal</jta-data-source>
    <properties>
        <property name="eclipselink.ddl-generation" value="create-tables" />
        <property name="eclipselink.logging.level" value="FINE" />
    </properties>
</persistence-unit>

I get the same error with "java:app/..." instead of "java:module/..." too.

My glassfish version is Open edition 3.0.1, JPA2, eclipse Helios

RGDS

Nav
  • 4,450
  • 10
  • 53
  • 84

2 Answers2

0

Most likely the jdbc-resource is not created when Glassfish starts. Go to Glassfish Admin console and look under JDBC Resources to check whether your sportal resource has been created or not.

I don't know if Eclipse Glassfish module can do this automatically using glassfish-resources.xml, all I know is that Netbeans 7 created the jdbc resources automatically when Glassfish starts (or does it create it when I reverse engineer my database table?)?

Either way you have to create the JDBC Resource first.

Lydon Ch
  • 8,637
  • 20
  • 79
  • 132
-1

Try using just "jdbc/sportal" as the JNDI and DS name, the prefix may be confusing things.

James
  • 17,965
  • 11
  • 91
  • 146