I am facing problems in looking up a URL object from JNDI , in an
EJB , deployed in Weblogic 8.1 .
According to the Weblogic Docs , at
(
http://edocs.beasys.com/wls/docs91/ejb/implementing.html)
"Configuring EJBs to Send Requests to a URL"
I have provided an entry for Resource Ref in ejb-jar.xml as
<resource-ref>
<res-ref-name>url/FileURL</res-ref-name>
<res-type>java.net.URL</res-type>
<res-auth>Container</res-auth>
</resource-ref>
and an entry for resource-description in weblogic-ejb-jar.xml as
<resource-description>
<res-ref-name>
url/FileURL
</res-ref-name>
<jndi-name>
http://www.rediff.com/ </jndi-name>
</resource-description>
In the business method in ejb the code to do the lookup is as follows
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:7001");
h.put(Context.SECURITY_PRINCIPAL, "weblogic");
h.put(Context.SECURITY_CREDENTIALS, "weblogic");
Context ctx = new InitialContext(h);
URL url = (URL) ctx.lookup("java:comp/env/url/FileURL");
URLConnection connection = url.openConnection();
When executing this method, a Naming execption is thrown which states
javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException: While trying to lookup 'http:./www.redif
f.com/' didn't find subcontext 'http:' Resolved ; remaining name 'http://www/rediff/com/'
I have tried the above using a file url (
file:///c:/a.txt)
as well and got the same error.
If anyone has succeffully used java.net.URL as a resource from EJB in Weblogic , do let me know .
Else , pls suggest , what could be going wrong in the above scenerio .
Thanks in Advance
Tarun