• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help me with the calling of jasper reports through java code

 
Krish Khan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone..
I am new to jasper reports i am using NEtBeans6.5.1 and dowloaded the jasper plugins 3.5.2 and have the jar file jasper report 3.6.2 from netbeans i develop a jrxml file but now when i am trying to call that file though java code i am getting error like...

SEVERE: Servlet.service() for servlet action threw exception
java.lang.ClassNotFoundException: org.springframework.core.io.Resource


my code is..

public class SampleReportAction extends Action{
private ActionForward forward;

public SampleReportAction(){
super();
System.out.println("Call of Constructor");
}
DBUtil mdbc=new DBUtil();
Connection con = null;
Statement st=null;
ResultSet rs=null;

public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception{
Statement stmt=null;
File path=new File(".");
String SrcFolder="",reportSource="",reportDest="";
try {
SrcFolder = path.getCanonicalPath();
} catch (IOException ex) {}
reportSource = SrcFolder + File.separatorChar + "report" + File.separatorChar + "templates" + File.separatorChar + "checking.jrxml";
System.out.println("After report source ----"+reportSource);
Map params=new HashMap();
String mode = request.getParameter("mode");
System.out.println("mode value :::" +mode);

if(mode.equalsIgnoreCase("print")){



try{

con=mdbc.getConnection();
System.out.println("After getting connection----");
String abc=getQuery();
params.put("Query",abc);
System.out.println(abc);

JasperReport jasperReport =JasperCompileManager.compileReport(reportSource);
System.out.println("After JasperComplie....");

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,params,con);
JasperExportManager.exportReportToPdfFile(jasperPrint, "C:/Sadhat/sample_report");


boolean isExitOnClose = false;
JasperViewer view = new JasperViewer(jasperPrint,isExitOnClose);
view.pack();
view.setTitle("FirstIReport ");
view.setSize(1020,720);
view.setLocation(0,30);
view.setVisible(true);
JasperPrintManager.printReport(jasperPrint,true);

} catch(JRException ex){
ex.printStackTrace();
}
}
return forward;
}


public String getQuery(){
String Query="";
Query="select a.team,count(b.[user_id]),count(b.account_id) from [user] a, phone b where a.team is NOT NUll and a.[user_id]=b.[user_id] group by a.team;";
return Query;

}

}


PLease help me out... I will be pleased fr the one who help me out.. thanks in Advance...

 
Maneesh Godbole
Saloon Keeper
Posts: 11165
14
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sadat,

Welcome to the Ranch.
Please read the following
http://faq.javaranch.com/java/CarefullyChooseOneForum
http://faq.javaranch.com/java/EaseUp
http://faq.javaranch.com/java/UseCodeTags

You have posted both your questions in the Meaningless Drivel forum. I am moving them to the appropriate forum. In future please do take care to post in the proper forum.
More tips on using the Ranch can be found here http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So ... *is* that class in the classpath when you run the application?
 
Campbell Ritchie
Sheriff
Pie
Posts: 50171
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a "beginning" question. Moving.
 
Krish Khan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah these are the jar files in classpath..
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*What* are the jar files in classpath? What's the command you're using to run this code? Which of the files contains that class?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic