• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JDBC lookup failure through java:comp....

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have just started using oracle9iAS . I am able to access my datasource from a Java client with the following code:
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.PROVIDER_URL,"ormi://localhost");
env.put(Context.SECURITY_PRINCIPAL,"admin");
env.put(Context.SECURITY_CREDENTIALS,"ignite");
InitialContext ic = new InitialContext(env);
DataSource ds = (DataSource)ic.lookup("jdbc/OracleTestCoreDS");
System.out.println("Data source is : "+ds);

But the EJB-suggested way of looking up : "jva:comp/env/jdbc/OracleTestCoreDS" in my ic.lookup parameter is not working.
I have added the following resource-ref tag to my application-client.xml:
<resource-ref>
<res-ref-name>jdbc/OracleTestCoreDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth></resource-ref>

Can anyone let me know where i am going wrong? If the first lookup is working the proper registration of the data source is complete right? Is Any other orion specific file modification is required.
 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to Javaranch Subadhra Velu.

I'm guessing that you meant to ask this question in the Oracle forum, so I'll move it over there.

Hang on...


Pauline

oracle? orion? kinda like sweden and switzerland, they get mixed up all the time...
 
author & internet detective
Posts: 42135
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Subadra,

There is a typo in the above. "jva" should be "java". Was it just a typo in this post or in the code too?
 
Subadhra Velu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply...The error is only in the post... The code has the proper syntax.... I figured the answer out... I was using the wrong context factory... Since i had to access from java client i was supposed to use Applicationclientcontextfactory...... So,now it works.
 
Jeanne Boyarsky
author & internet detective
Posts: 42135
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for posting the solution so others reading this thread can learn what the answer was.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Subadhra,

I get the same exception as you get can you tell me what user name & password should i give for the
Context.SECURITY_PRINCIPAL and Context.SECURITY_CREDENTIALS

Now i'm giving the user name and password that i give to login into Oracle App Server





private HelloHome lookupHome()throws NamingException
{
// Lookup the beans home using JNDI
Context ctx = getInitialContext();
try
{

Object home = ctx.lookup(JNDI_NAME); // Getting error here
return (HelloHome) narrow(home, HelloHome.class);
}
catch (NamingException ne)
{
log(ne.toString());
log("The client was unable to lookup the EJBHome. Please make sure ");
log("that you have deployed the ejb with the JNDI name "+JNDI_NAME+" on the server at "+url);
throw ne;
}
}

private Context getInitialContext() throws NamingException
{
try
{
// Get an InitialContext
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.ApplicationClientInitialContextFactory");
//
h.put(Context.PROVIDER_URL, url);//ormi:localhost:23791
h.put(Context.SECURITY_PRINCIPAL, "ias_admin");
h.put(Context.SECURITY_CREDENTIALS, "system12");
return new InitialContext(h);
}
catch (NamingException ne)
{
log (ne.toString());
log("We were unable to get a connection to the server at "+url);
log("Please make sure that the server is running.");
throw ne;
}
}




java.lang.InstantiationException: Error communicating with server: Lookup error:
java.net.ConnectException: Connection refused: connect; nested exception is:
java.net.ConnectException: Connection refused: connect; nested exception
is:
javax.naming.NamingException: Lookup error: java.net.ConnectException: C
onnection refused: connect; nested exception is:
java.net.ConnectException: Connection refused: connect [Root exception i
s java.net.ConnectException: Connection refused: connect]
at com.evermind.server.ApplicationClientContext.createContext(Applicatio
nClientContext.java:61)
at com.evermind.server.ApplicationClientInitialContextFactory.getInitial
Context(ApplicationClientInitialContextFactory.java:155)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at Client.getInitialContext(Client.java:111)
at Client.lookupHome(Client.java:80)
at Client.<init>(Client.java:22)
at Client.main(Client.java:33)
javax.naming.NamingException: Error reading application-client descriptor: Error
communicating with server: Lookup error: java.net.ConnectException: Connection
refused: connect; nested exception is:
java.net.ConnectException: Connection refused: connect; nested exception
is:
javax.naming.NamingException: Lookup error: java.net.ConnectException: C
onnection refused: connect; nested exception is:
java.net.ConnectException: Connection refused: connect [Root exception i
s java.net.ConnectException: Connection refused: connect]
We were unable to get a connection to the server at ormi://localhost:23791
Please make sure that the server is running.
[ July 28, 2004: Message edited by: oman tel ]
 
Subadhra Velu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Oman,
By going through the exception stack ... just verify the following before proceeding any further..
1. that the server has been started properly... just restart to make sure
2. Since you are using ApplicationClientInitialContextFactory you must have an application-client.xml inside meta-inf folder parallel to your client class file
3. you are looking up an ejb. So, you have to specify the application name along with the url ... so your url should be ormi://localhost:23791/appname.
The application name is the name that the entry in the server.xml has been made with.
4. using the oracle app server's principal and credential should be fine. Put a little SOP and try out. If there is problem with principal and credential the error will be thrown during creating the initial context itself.Since you are saying the error is thrown during the lookup check out the provider url once again...
 
oman tel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to restart it & how to find the admin pwd .

Can u give you'r mail id .. so that i can send my jar to u .
I'm struggling for this for a couple of days.
Else can u plz send a mail to me

Srini
[ July 29, 2004: Message edited by: oman tel ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic