Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 987787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:32:16+00:00 2026-05-16T05:32:16+00:00

I have a web app consisting of some JSPs that were previously running on

  • 0

I have a web app consisting of some JSPs that were previously running on a Linux box. I need to get this running on a Windows XP SP3 machine running Tomcat 5.5.29. Most everything is working now but this one item: The app has a capability to write a configuration file to its Windows directory (i.e. C:\Program Files\Apache\Tomcat\webapps\myapp). But when it tries to do this, the app cannot open the FileOutputStream (returns null). If I drop off the path specifier, and just let it open the file, it successfully opens it in the Tomcat directory.

The first line fails, but the second one succeeds:

//  outputFile2 = new PrintWriter(new FileOutputStream(basePathName + "programAll.txt", false));
    outputFile2 = new PrintWriter(new FileOutputStream("programAll.txt", false));

Here is the code that creates the basePathName:

    String basePathName = getBaseFilePath();  
    ...
    public String getBaseFilePath()
            {
            String curDir = System.getProperty("catalina.home");  
            curDir = curDir + "/webapps/pubmed/"; 
            curDir = "file:///" + formatPathNameForOS(curDir);
            return curDir;
            }

   public String formatPathNameForOS(String pathName)
        {
        if (codeIsOnWindows())
            {
            pathName = pathName.replace('/','\\');
            }
        else
            {
            pathName = pathName.replace('\\','/');
            }
        return pathName;
    }

Here’s the exception message:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause

java.lang.NullPointerException
    org.apache.jsp.updateMemberLists_jsp._jspService(updateMemberLists_jsp.java:1492)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

Here’s the stack trace:

Aug 6, 2010 1:20:39 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
    at org.apache.jsp.updateMemberLists_jsp._jspService(updateMemberLists_jsp.java:1492)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.globus.tomcat.coyote.valves.HTTPSValve55.invoke(HTTPSValve55.java:45)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:595)

I’ve looked at the updateMembersLists_jsp.java, and here is the section where the null pointer is occurring:

//create a file to write to the output
PrintWriter outputFile2 = null;
try
    {
    outputFile2 = new PrintWriter(new FileOutputStream(basePathName + "programAll.txt", false));
//  outputFile2 = new PrintWriter(new FileOutputStream("programAll.txt", false));
    }
    catch (FileNotFoundException e)
        {
        out.write("<p><font color='red'>Error Saving</font></p>");
        }
outputFile2.print(output);  // THIS IS LINE 1492 -- NULL POINTER
outputFile2.close();

Also: We are now running Tomcat off of the root directory instead of Program Files. I have checked the basePathName and it is being calculated correctly.

Now I figured out that Tomcat’s policy settings might need to be adjusted. I added the following lines to catalina.policy hoping it would set things right:

// The permissions granted to the pubmed webapp
grant codeBase "file:${catalina.home}/webapps/pubmed/-" {
        permission java.io.FilePermission "${catalina.home}/webapps/pubmed/-", "read, write";
        permission java.io.FilePermission "${catalina.home}/webapps/pubmed/*", "read, write";
};

This didn’t seem to have any effect. The Windows user that tomcat is running under has read/write permissions on the pubmed directory. Aside from the fact that it seems questionable for this webapp to be writing files to its own directory, what am I missing?

Sean

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:32:17+00:00Added an answer on May 16, 2026 at 5:32 am

    Try obtaining the path in the following way:

    String path = getServletContext().getRealPath("/");
    

    This will convert your path (to your webapp) to the actual path on your disk.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web-app consisting of some html forms for maintaining some tables (SQlite,
I have a web-app with a Java back-end that uses Tomcat jdbc-pool for database
I have a web app that runs fine in Visual web developer. But when
I have another web app, that uses the liferay user database. But before a
I have a web app that reads data from a SQL DB that contains
I have a web app that has a big and complex form (fields, checks,
I have a web app in production that is used for typical data entry,retrieval,
We have a web app (ASP) that has workflow in it for management to
I have a web app that currently uses the current HttpContext to store a
I have an Android app with some data (consisting in latitude and longitude) and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.