Skip to main content

Glassfish 3.1.2 embedded jdbc-connection-pool not working

Please note these forums are being decommissioned and use the new and improved forums at
3 replies [Last post]
Joined: 2013-06-20

Hi, I have an ear which has an ejb module and a web module. In my ejb module I created glassfish-resources.xml under META-INF folder. In one of my EJB's constructor I created and InitialContext to lookup my jndi.

<jdbc-connection-pool name="mydb_pool" ping="true" ...>
  <property name="User" value="usr" />
  <property name="Password" value="my1DB" />
  <property name="dataBaseName" value="mydb" />
  <property name="serverName" value="localhost" />
  <property name="portNumber" value="1234" />
<jdbc-resource pool-name="my_pool" jndi-name="jdbc/mydb" />

public class EmployeeService {
  public EmployeeService() {
    InitialContext context = new InitialContext();
    dataSource = (DataSource)

I deployed my application from command line using

asadmin --user admin --host localhost --port 20048 deploy --force simple-ejb-project-ear.ear

Then I get an error in server log that the Name cannot be found.

Then I removed the lookup in my EJB and tried to list the resources in my application's submodules to check whether the resources are being created or not. I used

asadmin --user admin --host localhost --port 20048 list-applications --subcomponents --resources

I was able to see the resources being created. But when I try to lookup I get an error.

Can anyone please help me. Thank you all in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2013-06-20

Holy shit!! Its working if I use @Resources annotation. But with InitialContext its not working.

Any ideas?

Joined: 2005-04-04

Look at "Table 2 Operations Allowed in the Methods of a Stateless
Session Bean" - JNDI access will work only starting with the PostConstruct.


On 6/26/13 4:12 AM, wrote:
> Holy shit!! Its working if I use @Resources annotation. But with
> InitialContext its not working. Any ideas?
> --
> [Message sent by forum member 'krishnathanuku']
> View Post:

Joined: 2013-06-20

Thank you mvatkina. Thanks a lot.