Chris,

Put jndi.properties into tomcat main classpath.
For instance into tomcat-jakarta/classes or modify
tomcat start script.


"Kimpton,C (Chris)" wrote:
> 
> Hi,
> 
> I am trying to use jboss, which loads a jndi.properties file off the class
> path to get some application configuration data.
> 
> This is a cut down version of what the code does;
> 
> public class Servlet1 extends javax.servlet.http.HttpServlet
> {
>     protected void doGet(javax.servlet.http.HttpServletRequest A,
> javax.servlet.http.HttpServletResponse B)
>     {
>         try {
> 
> System.getProperties().load(Thread.currentThread().getContextClassLoader().g
> etResourceAsStream("jndi.properties"));
>             B.getWriter().println("SOME STUFF...");
>             B.getWriter().println("<hr>");
> 
> B.getWriter().println("<br>java.naming.provider.url="+System.getProperty("ja
> va.naming.provider.url"));
> 
> B.getWriter().println("<br>java.naming.factory.initial="+System.getProperty(
> "java.naming.factory.initial"));
>         } catch (Exception e){
>             e.printStackTrace();
>         }
>     }
> }
> 
> When I run this servlet, I get the following error;
> 
> java.lang.NullPointerException
>         at java.io.Reader.<init>(Reader.java:64)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:89)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:78)
>         at java.util.Properties.load(Properties.java:189)
>         at Servlet1.doGet(Servlet1.java:9)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
>         at org.apache.tomcat.core.Handler.service(Handler.java:286)
>         at
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
>         at
> org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
> 7)
>         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
>         at
> org.apache.tomcat.service.http.HttpConnectionHandler.processConnection
> HttpConnectionHandler.java:210)
>         at
> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
>         at
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
> :498)
>         at java.lang.Thread.run(Thread.java:484)
> [root@londevrbiw01 bin]# ls
> [root@londevrbiw01 bin]# find ../webapps/ -name
> jndi.properties
> ../webapps/rbi-crm-1.0-alpha/WEB-INF/lib/jndi.properties
> 
> I've tried moving the file into WEB-INF/classes and also into the tomcat lib
> directory - all with the same error.
> 
> I have also tried changing the classloader line as follows;
> 
> 
> System.getProperties().load(this.getClass().getClassLoader().getResourceAsSt
> ream("jndi.properties"));
> 
> But I also get the same problem.
> 
> If I put the code into a main and run it from the command line, it works
> fine - and find the jndi.properties - which points to a problem (or misue by
> me) of the tomcat classloader.
> 
> Has anyone seen this problem?  Got a workaround for it?
> 
> Thanks,
> Chris
> 
> 
>================================================================================================
> This electronic message (email) and any attachments to it are subject to copyright 
>and are sent for the personal attention of the addressee. Although you may be the 
>named recipient, it may become apparent that this email and its contents are not 
>intended for you and an addressing error has been made. This email may include 
>information that is legally privileged and exempt from disclosure. If you have 
>received this email in error, please advise us immediately and delete this email and 
>any attachments from your computer system.Rabobank International is the trading name 
>of Coöperatieve Centrale Raiffeisen-Boerenleenbank B.A. which is incorporated in the 
>Netherlands. Registered with the Registrar of Companies for England & Wales No. 
>BR002630 and regulated by the SFA for the conduct of investment business in the UK.
> 
> The presence of this footnote also confirms that this email has been automatically 
>checked by Rabobank International for the presence of computer viruses prior to it 
>being sent, however, no guarantee is given or implied that this email is virus free 
>upon delivery.
> 
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> List Help?:          [EMAIL PROTECTED]

-- 
__________________________________________________
Alexander Kogan  PTC   www.ptc.com
[EMAIL PROTECTED]    140 Kendrick St. Needham MA 02494


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to