This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of React Cookbook: Recipes for Mastering the React Framework and have David Griffiths & Dawn Griffiths on-line!
See this thread for details.
Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

JNDI problem

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem,I have basically set jndi 2, 1 to access a db and the other to access a properties file so you can manage some parameters outside the application, the jdbc jndi is read properly, instead of the jndi properties file I should be in error.


first of all I will explain my setup, I have a tomcat server 5.5, Struts 1.3, winxp, sp1 helios eclipse.

then in web.xml I have these lines of code


instead of the server in the context.xml I have these lines

and finally to retrieve jndi use these instructions


db connection when the call goes alright, the db is read and written.
when I call the properties file back to me this error



Someone can help me? and sorry for my English
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to escape the backslash (I think)
url="C:\\deploy\\file.properties"
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And no problems with the English, welcome to the Ranch
 
satyro Bia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David O'Meara wrote:You need to escape the backslash (I think)
url="C:\\deploy\\file.properties"




thanks for reply and for welcome.

I have already tried this solution, with the same result error, I tried also
url="file:///C:/deploy/file.properties"
and
url="file://C:/deploy/file.properties"
and
url="file:///C://deploy//file.properties"

I'm going crazy
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like the first should be the correct one, do they all return the same error?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm also wondering if you should (could) store it as a String value (with escaped slashes) and then create a java.io.File from the String.
 
satyro Bia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David O'Meara wrote:It looks like the first should be the correct one, do they all return the same error?



same error...

David O'Meara wrote:I'm also wondering if you should (could) store it as a String value (with escaped slashes) and then create a java.io.File from the String.



you mean this?
String fi = (String)PortableRemoteObject.narrow(
env.lookup("url/fileprop"), String.class);

I tried now and the result is always that mistake
 
Greenhorn
Posts: 22
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can´t do this ?



simple as that..

why not?
 
satyro Bia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Victor Hugo Muniz Machado wrote:you can´t do this ?



simple as that..

why not?



for jdbc there are no problem.

i try this


getting the same error
 
Victor Hugo M Machado
Greenhorn
Posts: 22
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
take a look..

https://coderanch.com/t/87532/Tomcat/configure-JNDI-URL-resource
 
Victor Hugo M Machado
Greenhorn
Posts: 22
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
look here too
http://help.sap.com/saphelp_nw70/helpdata/en/15/6d56f65fb59e4db97253c89c5cfefd/content.htm


Example
Resource of Type javax.mail.Session
To get a resource of type javax.mail.Session the web.xml descriptor can be as follows:

<resource-ref>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>

Resource of Type java.net.URL
We need to redirect an HTTP request to a URL available as JNDI resource. The following source code retrieves the corresponding java.net.URL resource and redirects the client request to it.

InitialContext context = new InitialContext();
URL yahoo=(URL)context.lookup("java:comp/env/url/Yahoo.com");
response.sendRedirect(yahoo.toString());

We describe the reference to that resource in the web.xml as follows:
<resource-ref>
<res-ref-name>url/Yahoo.com</res-ref-name>
<res-type>java.net.URL</res-type>
<res-auth>Container</res-auth>
</resource-ref>

We describe the reference to that resource in the web-j2ee-engine.xml as follows:
<resource-ref>
<res-ref-name>url/Yahoo.com</res-ref-name>
<res-link>http://www.yahoo.com</res-link>;
</resource-ref>


 
satyro Bia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your reply, I solved this way.

context.xml in the server I have declared an Environment



and then I return the value in this way



I did not add anything in web.xml.
 
We don't have time to be charming! Quick, read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic