PDF Forms: form.close null pointer exception

Hi All,

I am using pdf tool kit for java. I have a pdf form with few controls like name, gender etc which is same as online.pdf found in the resources folder.When I use stand alone java program it works fine. However if I am using it from the server I get the exception at form.close(); Can you please help me in resolving this.

Thanks

Suneel

Hi Suneel,

I have tested this issue at my end but couldn’t notice any problem. Can you please share a sample input file and the code snippet with us? We’ll test the issue at our end using your scenario and update you accordingly.

We’re sorry for the inconvenience.
Regards,

static String path = "C:\\Documents and Settings\\rmalla\\workspace100\\TestPdf\\src\\resources\\";

public void processData(HttpServletRequest req, HttpServletResponse res,

ServletContext servctxt) throws ServerException, IOException,

Exception {

try {

Form form = new Form(path + "Online.pdf", path + "Online_output.pdf");

form.setField("fullName", "Prem");

form.close();

System.out.println("Finished");

}

catch (Exception e) {

QGlobals.debugger.error("AnnualSurveys", "processData", e);

throw new QuantrosException(e);

}

}

I am using the online.pdf provided with the downloads. I have also attached the file and provided the sample code in my previous message

Hi Suneel,

I have used the same file for testing purpose at my end. However, I have used the latest version of Aspose.Pdf.Kit for Java. Can you please download the latest version and try at your end?

If you still find the same issue then please do let us know.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

I am uisng java 1.4 in weblogic 8.1 Do you think the problem is with the java vesrion?

Can you please share the sample code you have tested

Hi Suneel,

I’m using the same code and file you shared earlier. I have also tested using the sample code distributed along with the component. I tried to test it on Java version 1.4 as well ,but couldn’t notice any problem. Can you please share which version of Aspose.Pdf.Kit for Java are you using? If you’re not using the latest version Aspose.Pdf.Kit for Java 2.8.0 then please download it from this link and try with that.

If you still find the issue then please do let us know.
Regards,

Yeah I still get this error while I run it in the weblogic 8.1

public void processData(HttpServletRequest req, HttpServletResponse res,

ServletContext servctxt) throws ServerException, IOException,

Exception {

try {

String path = req.getRealPath("/qsupport/jsp/hcoprofile");

Form form = new Form(path + "/Online.pdf", path + "/output2.pdf");

form.setField("fullName", "TEST");

form.close();

}

catch(Exception e ) {

QGlobals.debugger.error("PdfTest", "processData", e);

throw new QuantrosException(e);

}

}

This is the error I get:

PdfTest:processData java.lang.NullPointerException
at com.aspose.pdf.kit.Form.close(Unknown Source)
at com.quantros.qsupport.hcoprofile.PdfTest.processData(Unknown Source)
at com.quantros.qsupport.controller.QSupportController.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7051)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
[2010.04.26 03:57:30] QSupportController:service error.
[2010.04.26 03:57:30] QSupportController:service com.infoobjectsinc.util.QuantrosException
at com.quantros.qsupport.hcoprofile.PdfTest.processData(Unknown Source)
at com.quantros.qsupport.controller.QSupportController.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7051)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)

Hi Suneel,

We’re investigating this issue at our end. Please spare us some time before we could find a resolution for this issue.

We’re sorry for the inconvenience and appreciate your patience.
Regards,

Please let me know if you have any info about this problem. Based on this we need to decide if we can proceed with this tool or not.

Hi Suneel,

I’m afraid, we couldn’t reproduce this issue at our end. However, it looks like the possible cause of this issue could be the path. Can you please try changing the path to the folder where you’re keeping your files? Also, assign appropriate permissions to the folders so the files can be saved.

If it still doesn’t resolve your issue then please share whether you’re running your application on Windows or Linux OS.

We’re sorry for the inconvenience and appreciate your patience.
Regards,

I am unable to resolve this problem. I am running the code from windows XP Pro, Weblogic 8.1 and java 1.4. I have seen other posts too where this problem is still pending . Look into messages 210748

import java.io.IOException;

import com.aspose.pdf.kit.Form;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class PdfForm extends HttpServlet {

private static final long serialVersionUID = 807941967787932751L;

protected void doGet(HttpServletRequest request,

HttpServletResponse response) throws ServletException, IOException {

doPost(request, response);

}

protected void doPost(HttpServletRequest request,

HttpServletResponse response) throws ServletException, IOException {

try {

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

System.out.println(path);

Form form;

form = new Form(path + "\\Online.pdf", path + "\\Online_output.pdf");

form.setField("fullName", "suneel");

form.close();

System.out.println("Finished");

}

catch (Exception e) {

e.printStackTrace();

}

}

Hi Suneel,

Please spare us some time so we could test the issue at our end. You’ll be updated with the results accordingly.

We’re sorry for the inconvenience.
Regards,

Hi Suneel,

I have reproduced this problem at my end and logged it as PDFKITJAVA-16714 in our issue tracking system. Our team will look into this issue and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,

The issues you have found earlier (filed as 16714) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.