0

I am developing a module that it exports data from a XML file to a PDF file, so I used an XSLT as broker to achieve it.

My code works correctly in a standalone application but it does not in a the web application.

I have to say that my applications server is Websphere Liberty Profile 8.5 with JRE6 and FOP-1.1 jar library.

I hope that you could help with it, thank you in advance.

Source:

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;

import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;

@WebServlet("/FopTester")
public class FopTester extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public FopTester() {
        super();
    }

    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        try {
            ByteOutputStream out = new ByteOutputStream();
            FopFactory fopFactory = FopFactory.newInstance();
            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent,
                    out);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

it fails at:

 Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent,out);

Error:

[err] java.lang.NullPointerException
[err]   at com.ibm.ws.classloading.internal.ContainerClassLoader$EntryUniversalResource.getResourceURL(ContainerClassLoader.java:207)
[err]   at [internal classes]

1 Answers1

1

This NullPointerException is a known issue (PI13291) in Liberty when getResource is called with a name containing a space. I recommend opening a PMR with IBM and requesting an iFix.

Brett Kail
  • 33,593
  • 2
  • 85
  • 90