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]