This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Help me with the calling of jasper reports through java code

 
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...

 
Bartender
Posts: 11445
18
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So ... *is* that class in the classpath when you run the application?
 
Marshal
Posts: 66208
250
  • 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: 43011
76
  • 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?
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!