problem in JRLoader

hi experts

this line is not executed in my program please help me

JasperDesign jasperDesign =JRXmlLoader.load("C:/Documents and Settings/ashish/My Documents/NetBeansProjects/StrutsJasperXml/reports/userxml.xml");
package net.ensode.jasperbook.struts;
 
 
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRXmlDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.util.JRXmlUtils;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.w3c.dom.Document;
 
public class GenerateReportAction extends Action
{
 
 
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception
{
 
     ServletContext application=servlet.getServletContext();
     ServletOutputStream servletOutputStream =response.getOutputStream();
     try{
 
         InputStream reportStream = new FileInputStream("C:/Documents and Settings/ashish/My Documents/NetBeansProjects/StrutsJasperXml/reports/userxml.xml");
         Document document = JRXmlUtils.parse(new File("C:/Documents and Settings/ashish/My Documents/NetBeansProjects/StrutsJasperXml/reports/userxml.xml"));
         JasperDesign jasperDesign =JRXmlLoader.load("C:/Documents and Settings/ashish/My Documents/NetBeansProjects/StrutsJasperXml/reports/userxml.xml");
         System.out.println("ASHISH1111111111111111111111+++++++++++++++++");
         JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
         System.out.println("ASHISH2222222222222222222222+++++++++++++++++");
         JRXmlDataSource xmlDataSource = new JRXmlDataSource(document, "/airsanchay/M55_USERS_NEW");
         JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,new HashMap(),xmlDataSource);
         
 
     }catch(Exception e){
            e.printStackTrace();
        }
     finally{
 
        servletOutputStream.flush();
        servletOutputStream.close();
     }
     return mapping.getInputForward();
    }
}

Open in new window

Adwait ChitaleyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
This is a duplicate. Please delete
0
Adwait ChitaleyAuthor Commented:
means i dont understand
0
Adwait ChitaleyAuthor Commented:
??
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

objectsCommented:
>          Document document = JRXmlUtils.parse(new File("C:/Documents and Settings/ashish/My Documents/NetBeansProjects/StrutsJasperXml/reports/userxml.xml"));

get rid of that line

0
objectsCommented:
how do you know it is not being called, pretty sure it would be by the look.

Suggest you step through it with a debugger

0
Adwait ChitaleyAuthor Commented:
Again it not working and gives the following error.

java.lang.NullPointerException
        at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:264)
        at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:225)
        at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:213)
        at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:167)
        at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:151)
        at net.ensode.jasperbook.struts.GenerateReportAction.execute(GenerateReportAction.java:43)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:595)
0
Adwait ChitaleyAuthor Commented:
JasperDesign jasperDesign =JRXmlLoader.load("C:/Documents and Settings/ashish/My Documents/NetBeansProjects/StrutsJasperXml/reports/userxml.xml");
         System.out.println("ASHISH1111111111111111111111+++++++++++++++++");


System.out.println("ASHISH1111111111111111111111+++++++++++++++++");
This line is not printing on console
0
objectsCommented:
it is getting called but an exception is getting thrown, check the path is correct

try first getting it working in a standlone app first


0
objectsCommented:
I suspect your xml is invalid, make sure it contains the definition of a valid jasper report

0
CEHJCommented:
Try the following - and look for exceptions
File f = new File("C:/Documents and Settings/ashish/My Documents/NetBeansProjects/StrutsJasperXml/reports/userxml.xml");
if (!f.exists()) {
	throw new IllegalArgumentException("The following file does not exist: " + f.toString());
if (!f.canRead()) {
	throw new IllegalArgumentException("The following file is not readable: " + f.toString());
JasperDesign jasperDesign =JRXmlLoader.load(f);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.