Jump to content
We've recently updated our Privacy Statement, available here ×

jaspernewuser

Members
  • Posts

    11
  • Joined

  • Last visited

jaspernewuser's Achievements

Apprentice

Apprentice (3/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. Hi, I am trying to generate a jasper report for which I am using xml as data source . I am using JRXmlDataSource for this purpose. The problem here is that my xml has tags which uses namespace and because of this I am getting the error. below is the sample code String outFileName = "C:/addressbook11.pdf"; String xmlFileName = "C:/mydatasource.xml"; String recordPath = "/osm:Envelope/osm:OSMObjectConfiguration"; JasperDesign jasperDesign = JRXmlLoader.load("C:/OSM.jrxml"); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); JRXmlDataSource jrxmlds = new JRXmlDataSource(xmlFileName,recordPath); HashMap hm = new HashMap(); JasperPrint print = JasperFillManager.fillReport(jasperReport,hm,jrxmlds); JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,outFileName); exporter.setParameter(JRExporterParameter.JASPER_PRINT,print); exporter.exportReport(); the XML which I am using <?xml version="1.0" encoding="UTF-8"?> <osm:Envelope xmlns:osm="http://www.my.com/com/osm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.myserver.com/com/osm ../CommonDataModel.xsd" subsystem="OSMR_123" variant="5678"> <osm:OSMObjectConfiguration name="valve_abc" uuid="ec3a0500-4c21-11dd-ae16-0800200c9a66" objectType="valve" validFrom="2006-01-01T00:00:00" validTo=""> <osm:AttributeGroup validFrom="2006-01-01T00:00:00" validTo="2008-02-01T00:00:00"> <osm:Attribute name="Name" type="string" value="Valve" /> <osm:Attribute name="Location" type="string" value="Reckrod" /> <osm:Attribute name="SAP" type="string" value="SAP_123" /> <osm:Attribute name="NetzknotenID" type="int" value="423463546" /> </osm:AttributeGroup> <osm:PropertyGroup name="SCADA"> <osm:Property name="T1" type="boolean" value="1"/> <osm:Property name="ThresholdMin" type="int" value="10" /> </osm:PropertyGroup> <osm:PropertyGroup name="Simulation"> <osm:Property name="GaskonstX" type="int" value="10" /> </osm:PropertyGroup> <osm:PropertyGroup name="Forecast"> <osm:Property name="KonstA" type="double" value="9.81" /> </osm:PropertyGroup> </osm:OSMObjectConfiguration> </osm:Envelope> and below is the error am getting Exception in thread "main" at net.sf.jasperreports.engine.util.xml.XalanXPathExecuter.selectNodeList( at net.sf.jasperreports.engine.data.JRXmlDataSource.moveFirst( at net.sf.jasperreports.engine.data.JRXmlDataSource.<init>( at net.sf.jasperreports.engine.data.JRXmlDataSource.<init>( at test.XmlDataSourceTest.main( Caused by: at org.apache.xpath.compiler.XPathParser.error( at org.apache.xpath.compiler.Lexer.mapNSTokens( at org.apache.xpath.compiler.Lexer.tokenize( at org.apache.xpath.compiler.Lexer.tokenize( at org.apache.xpath.compiler.XPathParser.initXPath( at org.apache.xpath.XPath.<init>( at org.apache.xpath.CachedXPathAPI.eval( at org.apache.xpath.CachedXPathAPI.selectNodeList( at org.apache.xpath.CachedXPathAPI.selectNodeList( at net.sf.jasperreports.engine.util.xml.XalanXPathExecuter.selectNodeList( ... 4 more net.sf.jasperreports.engine.JRException: XPath selection failed. Expression: /osm:Envelope/osm:OSMObjectConfigurationXalanXPathExecuter.java:62)JRXmlDataSource.java:263)JRXmlDataSource.java:178)JRXmlDataSource.java:222)XmlDataSourceTest.java:41)javax.xml.transform.TransformerException: Prefix must resolve to a namespace: cdmXPathParser.java:602)Lexer.java:638)Lexer.java:265)Lexer.java:96)XPathParser.java:108)XPath.java:162)CachedXPathAPI.java:276)CachedXPathAPI.java:209)CachedXPathAPI.java:189)XalanXPathExecuter.java:60)
  2. Hi, I am trying to generate a jasper report for which I am using xml data as source of data for my report. I am using JRXmlDataSource for this purpose. Then problem here is that my xml has tags which uses namespace and because of this I am getting the error. below is the sample code String outFileName = "C:/addressbook11.pdf"; String xmlFileName = "C:/mydatasource.xml"; String recordPath = "/osm:Envelope/osm:OSMObjectConfiguration"; JasperDesign jasperDesign = JRXmlLoader.load("C:/OSM.jrxml"); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); JRXmlDataSource jrxmlds = new JRXmlDataSource(xmlFileName,recordPath); HashMap hm = new HashMap(); JasperPrint print = JasperFillManager.fillReport(jasperReport,hm,jrxmlds); JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,outFileName); exporter.setParameter(JRExporterParameter.JASPER_PRINT,print); exporter.exportReport(); <?xml version="1.0" encoding="UTF-8"?> <osm:Envelope xmlns:osm="http://www.my.com/com/osm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.myserver.com/com/osm ../CommonDataModel.xsd" subsystem="OSMR_123" variant="5678"> <osm:OSMObjectConfiguration name="valve_abc" uuid="ec3a0500-4c21-11dd-ae16-0800200c9a66" objectType="valve" validFrom="2006-01-01T00:00:00" validTo=""> <osm:AttributeGroup validFrom="2006-01-01T00:00:00" validTo="2008-02-01T00:00:00"> <osm:Attribute name="Name" type="string" value="Valve" /> <osm:Attribute name="Location" type="string" value="Reckrod" /> <osm:Attribute name="SAP" type="string" value="SAP_123" /> <osm:Attribute name="NetzknotenID" type="int" value="423463546" /> </osm:AttributeGroup> <osm:PropertyGroup name="SCADA"> <osm:Property name="T1" type="boolean" value="1"/> <osm:Property name="ThresholdMin" type="int" value="10" /> </osm:PropertyGroup> <osm:PropertyGroup name="Simulation"> <osm:Property name="GaskonstX" type="int" value="10" /> </osm:PropertyGroup> <osm:PropertyGroup name="Forecast"> <osm:Property name="KonstA" type="double" value="9.81" /> </osm:PropertyGroup> </osm:OSMObjectConfiguration> </osm:Envelope> and below is the error am getting Exception in thread "main" at net.sf.jasperreports.engine.util.xml.XalanXPathExecuter.selectNodeList( at net.sf.jasperreports.engine.data.JRXmlDataSource.moveFirst( at net.sf.jasperreports.engine.data.JRXmlDataSource.<init>( at net.sf.jasperreports.engine.data.JRXmlDataSource.<init>( at test.XmlDataSourceTest.main( Caused by: at org.apache.xpath.compiler.XPathParser.error( at org.apache.xpath.compiler.Lexer.mapNSTokens( at org.apache.xpath.compiler.Lexer.tokenize( at org.apache.xpath.compiler.Lexer.tokenize( at org.apache.xpath.compiler.XPathParser.initXPath( at org.apache.xpath.XPath.<init>( at org.apache.xpath.CachedXPathAPI.eval( at org.apache.xpath.CachedXPathAPI.selectNodeList( at org.apache.xpath.CachedXPathAPI.selectNodeList( at net.sf.jasperreports.engine.util.xml.XalanXPathExecuter.selectNodeList( ... 4 more net.sf.jasperreports.engine.JRException: XPath selection failed. Expression: /osm:Envelope/osm:OSMObjectConfigurationXalanXPathExecuter.java:62)JRXmlDataSource.java:263)JRXmlDataSource.java:178)JRXmlDataSource.java:222)XmlDataSourceTest.java:41)javax.xml.transform.TransformerException: Prefix must resolve to a namespace: cdmXPathParser.java:602)Lexer.java:638)Lexer.java:265)Lexer.java:96)XPathParser.java:108)XPath.java:162)CachedXPathAPI.java:276)CachedXPathAPI.java:209)CachedXPathAPI.java:189)XalanXPathExecuter.java:60)any idea why its not able to resolve namespace Thanks in advance
  3. ok I got it what went wrong. Instead of defining a variable mypic in jrxml i should define a parameter mypic in jrxml. so my imageexpression tag now look like this <imageExpression class="java.io.InputStream"><![CDATA[$P{mypic}]]></imageExpression> since previously I i defined a variable so CDATA content was <![CDATA[$V{mypic}]]> which jasper engine was not replacing with the inputstream I was passing through hashmap to Thanks JasperFillManager.fillReport.
  4. Hi, I am trying to add an image into my pdf report. The image I am going to get is as stream or byte. I tried this but no success. can any one help me Here is the code am using and jrxml (this jrxml is used just to display image no data is required) . I defined a variable named mypic of type java.io.InputStream in the jrxml and used this variable in image expression tag. --------------------------------------- jrxml ----------------------------------------------------------------- <jasperReport name="TestImage" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <variable name="mypic" class="java.io.InputStream" resetType="Report" calculation="Nothing"> </variable> <columnHeader> <band height="30" isSplitAllowed="true" > <image evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="183" y="12" width="105" height="11" key="image-1"/> <box></box> <graphicElement stretchType="NoStretch"/> <imageExpression class="java.io.InputStream"><![CDATA[$V{mypic}]]></imageExpression> </image> </band> </columnHeader> </jasperReport> -------------------------------------------------------------------------------------------------------------------------------- ====================== java code ========================================= String outFileName = "C:/addressbook11.pdf"; String xmlFileName = "C:/addressbook11.xml"; String recordPath = "/addresses/address"; JasperDesign jasperDesign = JRXmlLoader.load("C:/TestImage.jrxml"); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); JRXMLDataSource jrxmlds = new JRXMLDataSource(xmlFileName,recordPath); HashMap hm = new HashMap(); File f = new File("C:/dukesign.jpg"); FileInputStream fi = new FileInputStream(f); // storing fileinput stream in hash map with key mypic as the varialble // defined in jrxml is of same name hm.put("mypic", fi); // dont want to print data just want to check if image is getting dispayed in pdf file JasperPrint print = JasperFillManager.fillReport(jasperReport,hm,jrxmlds); JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,outFileName); exporter.setParameter(JRExporterParameter.JASPER_PRINT,print); exporter.exportReport(); ======================================================================= Thanks in advance
  5. Hi sherman, First thanks for your quick reply. I tried other way of printing. below is my code JasperDesign jasperDesign = JRXmlLoader.load("C:\MySQLEmployeeReport.jrxml"); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); Class.forName("com.mysql.jdbc.Driver"); Connection jdbcConnection = DriverManager.getConnection("jdbc:mysql://localhost/mydb", "mydbuser", "mydbpassword"); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, jdbcConnection); jdbcConnection.close(); JasperPrintManager.printReport(jasperPrint, false); an am getting no printer available error, even though a driver is installed for network printer and this printer is in working condition (I tested it) .. Am i missing some steps in above sample code ? Exception in thread "main" net.sf.jasperreports.engine.JRException: No printer available.JasperPrintManager.java:241)PrintServiceApp.java:38) at net.sf.jasperreports.engine.JasperPrintManager.printReport( at test.PrintServiceApp.main(
  6. Hey Nicholas, First Thanks for quick reply. I did what you said, still am getting error saying. Exception in thread "main" net.sf.jasperreports.engine.JRException: java.awt.print.PrinterException: Printer is not accepting job.JRPrintServiceExporter.java:253)PrintServiceApp.java:54)java.awt.print.PrinterException: Printer is not accepting job.RasterPrinterJob.java:1230)JRPrintServiceExporter.java:239) Here is my sample code which I am using for testing purpose. also am uploading jrxml file. JasperDesign jasperDesign = JRXmlLoader.load("C:\myexample\MySQLEmployeeReport.jrxml"); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); Class.forName("com.mysql.jdbc.Driver"); Connection jdbcConnection = DriverManager.getConnection("jdbc:mysql://myservername/mydb", "dbuser", "dbpassword"); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, jdbcConnection); jdbcConnection.close(); JRExporter exporter = new JRPrintServiceExporter(); PrinterJob pj = PrinterJob.getPrinterJob(); PrintService ps = pj.getPrintService(); PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet(); printRequestAttributeSet.add(MediaSizeName.ISO_A4); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, ps.getAttributes()); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.FALSE); // application hangs here for some time and there gives error message exporter.exportReport(); at net.sf.jasperreports.engine.export.JRPrintServiceExporter.exportReport( at test.PrintServiceApp.main( Caused by: at sun.print.RasterPrinterJob.print( at net.sf.jasperreports.engine.export.JRPrintServiceExporter.exportReport( ... 1 more
  7. Hi All, Can any one guide me, where can I find examples for printing jasper report on a network printer. Thanks in advance
  8. Hi, I am trying to pring jasper report. But not able to do am getting following errornet.sf.jasperreports.engine.JRException: java.awt.print.PrinterException: Printer is not accepting job.JRPrintServiceExporter.java:253)JasperTest.java:69)JasperTest.java:30)java.awt.print.PrinterException: Printer is not accepting job.RasterPrinterJob.java:1230)JRPrintServiceExporter.java:248 Exception in thread "main" at net.sf.jasperreports.engine.export.JRPrintServiceExporter.exportReport( at test.JasperTest.testPrinting( at test.JasperTest.main( Caused by: at sun.print.RasterPrinterJob.print( at net.sf.jasperreports.engine.export.JRPrintServiceExporter.exportReport( Bellow ) below is my code JasperDesign jasperDesign = JRXmlLoader.load("C:\MySQLEmployeeReport.jrxml"); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); Class.forName("com.mysql.jdbc.Driver"); Connection jdbcConnection = DriverManager.getConnection("jdbc:mysql://ao-in003024/ris", "risuser", "password123"); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, jdbcConnection); PrintService pp = PrintServiceLookup.lookupDefaultPrintService(); JRExporter exporter = new JRPrintServiceExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, pp.getAttributes()); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.FALSE); exporter.exportReport(); and if I am using false);I get following error net.sf.jasperreports.engine.JRException: No printer available.JasperPrintManager.java:241)JasperTest.java:48)JasperTest.java:31 )any idea why is it happening so Thanks in advance; JasperPrintManager.printReport(jasperPrint, Exception in thread "main" at net.sf.jasperreports.engine.JasperPrintManager.printReport( at test.JasperTest.testPrinting( at test.JasperTest.main(
  9. Hi All, I created a webservice java client using wsdl from url http://localhost:8080/jasperserver/services/repository?wsdl once all my java files are auto generated for above wsdl and when I try to access any of the repository service I get following error. How can I pass my authentication information from my webservice client while invoking any of the repository service. faultCode: {http://xml.apache.org/axis/}HTTP faultSubcode: faultString: (401)Full authentication is required to access this resource faultActor: faultNode: faultDetail: {}:return code: 401 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>Sun Java System Application Server 9.1_02 - Error report</title><style type="text/css"><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - Full authentication is required to access this resource</h1><hr/><p><b>type</b> Status report</p><p><b>message</b>Full authentication is required to access this resource</p><p><b>description</b>This request requires HTTP authentication (Full authentication is required to access this resource).</p><hr/><h3>Sun Java System Application Server 9.1_02</h3></body></html> {http://xml.apache.org/axis/}HttpErrorCode:401 (401)Full authentication is required to access this resource at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744) at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2784) at org.apache.axis.client.Call.invoke(Call.java:2767) at org.apache.axis.client.Call.invoke(Call.java:2443) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812) at org.jasperforge.www.jasperserver.ws.ReportSchedulerSoapBindingStub.deleteJob(ReportSchedulerSoapBindingStub.java:337) at org.jasperforge.www.jasperserver.ws.ReportSchedulerProxy.deleteJob(ReportSchedulerProxy.java:50) at test.Test.main(Test.java:29) Thanks
  10. Hi, when we try to access inbuild webservices provided by jasperserver for repository service, how do we provide login and password too. do any one have any example for the same. it would be of great help thanks in advance
  11. Hi, I have query, I need to access webservice exposed by JapserServer from my middleware application webmethods. How can I call these webservices by passing required cridentials. How should I pass these cridentials. Thanks jasperneruser
×
×
  • Create New...