ajm
ajm

Reputation: 13203

How do I setup a jndi datasource in glassfish 3.1?

I need to setup jndi datasource in my web application deployed on the glassfish server. I don't want to use glassfish admin console for creating connection pool and jndi datasource. (This works though.)

I would want to use some xml files like context.xml (used in tomcat) to specify the jndi datasource details which will be bundled with the application war file.

This way if I deploy my app war file I would not have to do any changes in the glassfish from the admin console.

Please help.

PS. I tried putting context.xml in war META-INF, but its not working. When I deploy my war on glassfish it says jndi name not found.

Upvotes: 1

Views: 3448

Answers (1)

MaDa
MaDa

Reputation: 10762

You can't set up resources on Glassfish application server from within an enterprise application; I would even say it's true for any Java EE-compliant application server. It's simply against EJB separation of roles: preparing the application is the role of Enterprise Bean Provider and Application Assembler, and installing it on the server belongs to the Deployer (see EJB 3.1 spec, chapter 2.2).

You surely don't have to set up everything manually, though. Glassfish has a command line tool asadmin, with the help of which you can script all operations accessible from the GUI admin console — take a look at the Glassfish Admin Guide.

Upvotes: 2

Related Questions