A few things:
1) A DataSource does not require a PortableRemoteObject.narrow(). This is typically used
for EJB resources running outside of the container (ie thin client).
The real question you are facing is the 'location' of the DataaSource. Code
running within the application server can simply access the DataSource as follows:
|
| InitialContext jndiContext = new InitialContext();
| DataSource ds = (DataSource)jndiContext.lookup("java:DSName");
|
|
Note, it's better to use a resource-ref but that is for another discussion :-)
Code, running outside of JBoss wanting to access a DataSource needs to add the following
element to the *-ds.xml file
| <use-java-context>false</use-java-context>
|
At this point you can access the DataSource remotely be executing
|
| InitialContext jndiContext = new InitialContext();
| DataSource ds = (DataSource)jndiContext.lookup("DSName");
|
|
Note the difference in the JNDI name. Remote DataSource access uses the Global JNDI
namespace, not the ENC namespace reserved for J2EE application components.
A *BIG* word of caution here. DataSources are typicall not meant to be used outside of an
application server. Testing simply JDBC interactions is fine but you are strongly,
strongly, strongly encouraged not to do this in production environment. More on this can
be found here:
http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigDataSources
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4038338#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...