Skip to Content
0
Former Member
Oct 11, 2005 at 01:33 PM

Swing Application connecting to datasource returning a NamingException

80 Views

hello i created a swing that calls a data source of a webas 6.40 sp14

the lookup :

public static Context lookup()

{

if (ctx != null )return ctx;

else

try {

Properties props = new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");

props.put(Context.PROVIDER_URL, "10.2.82.78:50004");

props.put(Context.SECURITY_PRINCIPAL, "admin");

props.put(Context.SECURITY_CREDENTIALS, "password");

tx = new InitialContext(props);

return ctx;

}catch(Exception e){

e.printStackTrace();

return null;

}

}

the connection to the datasource :

public static Connection ConnectToDB(){

try {

if(ctx == null ){ Context ctx = SwingPanel.lookup(); }

Object o = ctx.lookup("jdbc/oracle");

javax.sql.DataSource ds = (javax.sql.DataSource) o ;

java.sql.Connection con = ds.getConnection();

return con;

}catch(Exception e){

e.printStackTrace();

return null;

the error :

com.sap.engine.services.jndi.persistent.exceptions.NamingException: Exception during lookup operation of object with name jdbc/oracle, cannot resolve object reference. [Root exception is com.sap.engine.services.connector.exceptions.BaseResourceException: Cannot lookup ManageConnectionFactory "oracle". Cannot deserialize object: java.lang.NullPointerException

at com.sap.engine.services.dbpool.spi.CPManagedConnectionFactoryImpl.readObject(CPManagedConnectionFactoryImpl.java:307)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

the following jars are in order :

connector , jdbc , jdbc20, logging , ojdbc14 (oracle ) ,sapj2eeclient ,exception , tools

the datasource is working , because in another part of the code i call a CMP EJB that uses this datasource . but on this part i have to use a direct connection to the datasource , any ideas