• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help me with the calling of jasper reports through java code

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So ... *is* that class in the classpath when you run the application?
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a "beginning" question. Moving.
 
Krish Khan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah these are the jar files in classpath..
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic