aspose file tools*
The moose likes JBoss/WildFly and the fly likes OracleDS not Bound in JBOSS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "OracleDS not Bound in JBOSS" Watch "OracleDS not Bound in JBOSS" New topic
Author

OracleDS not Bound in JBOSS

Sowjanya Venkiteela
Greenhorn

Joined: Nov 25, 2009
Posts: 17
Dear All,

I want to establish the connection to Database.My Application server is JBOSS.

My Client code is as follows:
package ejb.bean.oracle.ejb30;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;

import javax.naming.*;
import javax.sql.DataSource;

import oracle.jdbc.pool.OracleDataSource;

class SC_Connection {

static Connection con = null;
public static Connection getConnection()
{
try
{
Properties properties=new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.setProperty(Context.URL_PKG_PREFIXES, "org.jnp.interfacesrg.jboss.naming");
properties.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
Context ctx = new InitialContext(properties);


DataSource ds= (DataSource)ctx.lookup("OracleDS");
con = ds.getConnection();
System.out.println("connection opened >>>> " + con);
}
catch(Exception e) {

e.printStackTrace();
}
return con;
}

public static void closeConnection()
{
try{
if(con!=null)con.close();
System.out.println("Connection closed");
}catch(Exception e){}
}
public static void main(String str[])
{
SC_Connection.getConnection();
}


}

I pasted my oracle-ds.xml in server/default/deploy.

Oracle-ds.xml:
----------------

<datasources>
<local-tx-datasource>
<jndi-name>OracleDS</jndi-name>
<connection-url>jdbcracle:thin:@localhost:1521:sid</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>root</user-name>
<password>password</password>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>

</datasources>


But when I run the program I am getting the following exception:

javax.naming.NameNotFoundException: OracleDS not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(Unknown Source)
at ejb.bean.oracle.ejb30.SC_Connection.getConnection(SC_Connection.java:32)
at ejb.bean.oracle.ejb30.SC_Connection.main(SC_Connection.java:59)


Help appreciated,
Thanks in Advance.

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10213
    
166

Moving to JBoss forum


[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10213
    
166

See this
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OracleDS not Bound in JBOSS