aspose file tools*
The moose likes JBoss/WildFly and the fly likes Problem with JBoss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Problem with JBoss" Watch "Problem with JBoss" New topic
Author

Problem with JBoss

Richard Wilson
Ranch Hand

Joined: Jan 12, 2002
Posts: 57
Hi,can anyone tell me how to get datasource from Jboss.
i have set all the necessary Driver and data source name in mssql-ds.xml file.But when i want to get Connection from my application:
ctx=new InitialContext();
Object ds=ctx.lookup("java:/DataSource");
It complains Name Not Bound Exception.But when i configure the same data source in jboss-cmp.xml file and run ejb,it runs correctly.
Can any one tell me why?I am in urgent.


Richard Wilson
Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
Hi Welcome to the club ,pal.Looks like that I'm not the only one who's upto his head with JBoss.You can check my posting about the same problem in this forum a few days back....
Richard Wilson
Ranch Hand

Joined: Jan 12, 2002
Posts: 57
Hi,I still dont know why that problem occurs and how to solve it in JBoss?
Anyone know?
Thank you very much!
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Originally posted by Richard Wilson:
Hi,can anyone tell me how to get datasource from Jboss.
i have set all the necessary Driver and data source name in mssql-ds.xml file.But when i want to get Connection from my application:
ctx=new InitialContext();
Object ds=ctx.lookup("java:/DataSource");
It complains Name Not Bound Exception.But when i configure the same data source in jboss-cmp.xml file and run ejb,it runs correctly.
Can any one tell me why?I am in urgent.

Two questions:
1) Have you tried ctx.lookup("java:comp/env/DataSource") ?
2) Have you added a resource reference to your application? It would look like the following:
In the web.xml add:

In the jboss-web.xml:

Moving to the JBoss Forum for further discussion...
norman richards
Author
Ranch Hand

Joined: Jul 21, 2003
Posts: 367
Are you are the datasource is deployed correctly? Go to the JMX console and look for service=JNDIView. Select that and invoke the list() method. You can see your whole JNDI space.

Look for the java: section and see if your datasource shows up there. If it does, you should be able to look it up using that global name. The name you use is the one you specificy in the your -ds.xml file in the jndi-name attribute. Just check the right name and make sure it is showing up in the JNDIView and you should be able to look it up. (if it doesn't show up, check your log carefully for deployment problems like not having the JDBC driver
loaded)

Once you are sure you are deployed, you'll want to look at what Chris just wrote and do the lookups using a local name instead of the global name.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with JBoss
 
Similar Threads
Change datasource of BMP during runtime
Oracle 8i conig with JBoss 3.0.2
Commons-dbcp - getting the active database connections
JBOSS DataSource/Tomcat App - Unable to get connection, DataSource invalid
Accessing a datasource from outside JBoss