Grails - Jasper Plugin - Invalid byte 1 of 1-byte UTF-8 sequence error with .jasper file - grails

I am using Grails 1.3.5, SQL Server 2005, iReports 3.7.6, Jasper Plugin 1.1.3. In my GSP page I have given the jasperReprt tag as:
<g:jasperReport jasper="report1" format="PDF">
<input type="hidden" name="test_id" id="test_id"/>
<input type="hidden" name="order_no" id="order_no" />
</g:jasperReport>
For development, in Config.groovy I have specified the
jasper.dir.reports = './reports'
There are two files created in the reports folder when a new report is created and saved, i.e. report.jrxml and report.jasper.
When clicked on the PDF icon in IE or Firefox, an 500 server error is thrown and below is stack trace.
[2010-11-27 01:13:14.998] ERROR groovy.grails.web.errors.GrailsExceptionResolver Invalid byte 1 of 1-byte UTF-8 sequence.
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:684)
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:554)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1742)
at
But if I delete the report1.jasper, the error is no longer thrown when PDF icon is clicked and the PDF report is shown fine.
Is this the correct way to do it?
My second issue is with using Sub Reports. Sub report is in the same folder as the main report. But When the report is executed from the application, below error is thrown:
[2010-11-27 01:30:27.556] ERROR groovy.grails.web.errors.GrailsExceptionResolver Could not load object from location : ./reports\report1sub_report.jasper
net.sf.jasperreports.engine.JRException: Could not load object from location : ./reports\urine_routinepatient_details_sub_report.jasper
at net.sf.jasperreports.engine.util.JRLoader.loadObjectFromLocation(JRLoader.java:262)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateReport(JRFillSubreport.java:301)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:327)
It does not find the sub report. How can I fix it?
Thank you.
Jay Chandran.
Edit:
I have been searching during this whole time, but still could not find a proper solution. So I did some trial and error. I figured out that, deleting report1.jasper and just leaving jasper.jrxml in the report directory works just fine as I said earlier.
For the sub-report issue: It was giving error Could not load object from location : ./reports\report1sub_report.jasper For some strange reason, the main report name report was getting appended to the name sub_report.jasper and was looking for a file named report1sub_report.jasper
So I created a sub-folder under reports folder and named it report1 and updated report1.jrxml file
<subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "\\sub_report.jasper"]]></subreportExpression>
I had to add the extra \\ slash even though the "SUBREPORT_DIR" parameter had \\ the slashes at the end of the path as shown below.
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["F:\\Workspace\\SpringSource2.5.0\\GrailsProjec\\reports\\report1\\"]]></defaultValueExpression>
</parameter>
Notice the \\ at the end. I don't know why it was not getting appended!
Another way would have been to just change the sub-report name from sub_report.jasper
to report1sub_report.jasper!!! :)
I have tested this in production mode and it works fine. I am not sure if this is the way to do it, but all other possible solutions did not work for me.
Feedback will be very helpful.

I assume you have a version conflict here. iReport stores JRXML files and seems to compile them automatically to .jasper. The Grails Jasper plugin picks up the compile variant and gets into trouble with it. So try to disable compiled output in ireport.
The Grails Jasper plugin 1.1.3 uses internally Jasper 3.7.4, the used ireport is 3.7.6.
Regarding the sub reports: no idea.

The MalformedByteSequenceException is caused by a character encoding conflict. I'd suggest to use UTF-8 instead of Windows' Win-1252 (similar to ISO-8859-1) everywhere.
In Jasper's etc/ireport.conf file, change the default_options to:
default_options="-J-Dfile.encoding=UTF-8 -J-Xms24m -J-Xmx64m"
(Where Xms and Xmx are unrelated memory settings. If there are default settings with that config entry, you can overtake them, else, just leave them out.)
See this forum thread for alternative configurations.
As for the error with subreports, take a look at the backslash \ that's probably wrong.

EDIT : There is some information about two issues which maybe could help in
http://grails.org/plugin/jasper#faqTab
i hope i can help with one of the issues: which one related with subreports dir.
The problem is the plugin code sets SUBREPORT_DIR to the complete file path of main report, including its name. However the code honour the user provided param with the same name, so if you fill this param with whatever value except null the plugin will use it.
For example if you chain directly the jasper controller you can do:
def renderAs(data,format) {
def reportParams=params.clone()
reportParams["_format"]=reportParams["_format"]?:"${format.toUpperCase()}"
reportParams["SUBREPORT_DIR"]=CH.config.jasper.dir.reports+"/"
chain(controller:'jasper',action:'index',model:[data:[]+data],params:reportParams)
}
In your scenario an (ugly) option would be create an hidden input with name SUBREPORT_DIR and value the desired one. I would fill the paremeter in other way.
EDIT:
Another annoying problem is where do we have to put the main reports and compiled subreports:
When you run the app with run-app they work if you put them all in a folder with the same name as CH.config.jasper.dir.reports(reportDir) in the root of the grails app.
But if you want to deploy a war you have to put the main reports in a folder reportDir in the root of war file and compiled subreports in WEB-INF/classes/reportDir.
I've opted to keep all files in grailsApp/reports and copy the resources in the appropiate folders in the war grails task. In my BuildConfig.groovy i've added (reportDir is "reports"):
grails.war.resources = { stagingDir,args ->
def classpathDir="${stagingDir}/WEB-INF/classes"
copy(toDir:"${stagingDir}/reports") {
fileset(dir:"reports",includes:"**")
}
copy(toDir:"${classpathDir}/reports") {
fileset(dir:"reports",excludes:"**.jrxml")
}
}
Hope it helps.

Related

Module build failed (from ./node_modules/#ngtools/webpack/src/index.js):

I have created an application on angular 7 and ionic 4.
I tried to edit app.routing.ts file, setting path and component. From then on I am getting this error below:
ERROR in ./src/app/department/department.module.ts
[ng] Module build failed (from ./node_modules/#ngtools/webpack/src/index.js):
[ng] Error: ENOENT: no such file or directory, open 'C:\Users\x\department\department.module.ts'
[ng] at Object.openSync (fs.js:436:3)
[ng] at Object.readFileSync (fs.js:341:35)
[ng] at Storage.provideSync (C:\Users\x\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:98:13)
Make sure department component exist, check the templateUrl that corresponds to the file name you are referencing. You may have also modified the path unknowingly during modification of app.routing.ts file.
C:\Users\x\department\department.module.ts
This error occurs when your component can't be found with your app.module settings.
Follow these steps to solve your problem:
Check if the module.ts file exists.
Check the relative path.
The path is case sensitive (maybe the .ts file is Department).
Both answer are useful from #trustidkid and #vinay sharma. If there is someone has been facing the same problem;
1-Go to to the file that the error has occurred in. (To go directly to the file, click the error line shortly [CTRL+Click] (CMD+Click on MacOS):
ERROR in ./src/app/department/department.module.ts
Then check the path address if it is exactly true pointing the file. Most of these problems are having similar solutions. Just be sure about the path address of the file you want to point and the address mentioned in the other file which the error occurred.
This problem happens when you delete a component but forgot to delete its import from module.ts.
For example: TestComponent is deleted so you have to also delete:
import { TestComponent } from './test.component'
If you have a folder mapping on a windows machine like me, do not try to build it from a mapped folder, go to the original folder and build it from there.
Mapped Folder has a small icon like this:
In my case I had prime ng version that did not support a particular module, I simply commented it out and it worked.

windows installer error when specifying "setupIcon"

I've already packaged the app correctly and am now going through the whole electron-winstaller processs, following the Christian Engvall tutorial exactly.
In createInstaller.js I have the standard
return Promise.resolve({
appDirectory: path.join(outPath, '/MyApp-win32-x64/'),
authors: 'Me',
noMsi: true,
outputDirectory: path.join(outPath, 'windows-installer'),
exe: 'MyApp.exe',
setupExe: 'Setup.exe',
setupIcon: path.join(rootPath, '/path/to/appicon.ico')
});
If I remove the setupIcon parameter, it builds the installer just fine. However if I keep it there, I get an 'Unable to load file' error from the console. I've verified that the path to the .ico file is in fact correct, and is a valid .ico file.
What could possibly be happening?
To fix the Setup Icon error when creating an installer with electron-wininstaller you can use Resource Hacker.
It is for editing the exe file and you can change the ressource file and icons.
For more information you there is a tutorial here.

Resource compilation error (Bad character in source input)

I have added text file with following content to the project:
1 24 "MyApplication.manifest"
In the same folder there is also MyApplication.manifest file which is XML - this one:
C++ Builder / Delphi 2010 application manifest template
After I attempt to build resource from RC I get error - Bad character in source input(1)
Any ideas why?
RT_MANIFEST value is 24, but I am unsure what 1 is supposed to be.
I managed to find the answer myself so no answer necessary. The problem was, as usual very obscure.
Turned out that the resource script file (.RC) I was using had an UTF-8 byte order mark in the file (0xEF,0xBB,0xBF) which was invisible to the text editor but resource compiler complained about it. After removing the BOM resource compiled correctly.
I don't think many people fall into this trap but at least if anyone else sees this error in resource compiler, you should examine if there is an UTF-8 BOM in your file by viewing HEX-dump of RC file because brcc32.exe resource compiler seems to have issues with that.

Offending Command error while Printing EPS

I am printing an EPS File generated with following credentials.
%-12345X#PJL JOB
#PJL ENTER LANGUAGE = POSTSCRIPT
%!PS-Adobe-3.0
%%Title: InvoiceDetail_combine
%%Creator: PScript5.dll Version 5.2.2
%%CreationDate: 10/7/2011 4:46:59
%%For: Administrator
%%BoundingBox: (atend)
%%Pages: (atend)
%%Orientation: Portrait
%%PageOrder: Special
%%DocumentNeededResources: (atend)
%%DocumentSuppliedResources: (atend)
%%DocumentData: Clean7Bit
%%TargetDevice: (HP Color LaserJet 4500) (2014.200) 0
%%LanguageLevel: 2
%%EndComments
While doing Selection Printing on Ricoh Afficio 2090 or any other drivers/printers get the following error printed on the sheets
ERROR: undefined
OFFENDING COMMAND: F4S47
Stack:
.
Kindly Review and suggest a turn around for the same as i am already stuck in this hell. I have tried to convert/extract in PS but all in vain. I am using gsview to Print and view these files.
This is the problem:
%%PageOrder: Special
A ps document with "Special" page order can NOT be re-ordered. You cannot do a selection or range with this file because it is broken for this use. You must reprocess the file using Distiller or ghostscript (ps2ps or ps2pdf) in order to print selected or re-ordered pages from the document.
You can avoid this by generating your postscript files with a real Postscriptâ„¢ driver (one not created by Microsoft).
The GSView Documentation has more about this.
Previously:
This line ...
%%TargetDevice: (HP Color LaserJet 4500) (2014.200) 0
... tells us that the file was generated with HP printers as a target. So this really is not an EPS file. Because it's not Encapsulatable. To generate output on a printer the file has to execute the showpage operator, which is a no-no for EPS files.
So uncheck the EPS box (it's a big fat lie, anyway), and select (install) a Generic Postscript driver. If you need to send it to multiple makes of printer, the file needs to make as few assumptions about the printer as possible.
The first thing is that this is not a valid EPS file, as it has PJL attached at the front. Many PostScript printers will strip this off, but by no means all.
This probably is not the source of the problem.
There is no way to 'review' the problem as you have not supplied the complete PostScript program. Without that there is no way to tell what is actually wrong, the error message tells you that the interpreter encountered 'F4547' while trying to parse a token, and that this has not been defined as a routine.
Most likely the file is corrupt, either damaged in some way, or possibly it is a biinary file and has been transmitted by some process which does has done some kind of conversion (CR/LF is common). The offending command looks like its ASCIIHex encoded, so that may be a red herring.
If you want additional help, you are going to have to make the whole program available somewhere.

PartCover browser not opening code files

We're generating PartCover reports via the command line tool along with our CruiseControl.Net unit tests. This generates an xml file that displays the results nicely on the cruisecontrol dashboard. The xslt transforms that are included only show you the percentage of coverage in an individual class. We want to know exactly what lines are not being covered. The problem ist when we open the report in the PartCover browser and double click a method it doesn't show us our cs files. I know the PartCover browser is capable of showing you the files because of the following.
Here's a screenshot of PartCover browser with the lines of code showing: http://kjkpub.s3.amazonaws.com/blog/img/partcover-browse.png.
The information looks like it should be available to the browser because the report contains this:
<Method name="get_DeviceType" sig="Cathexis.IDBlue.DeviceType ()" bodysize="19" flags="0" iflags="0">
<pt visit="2" pos="0" len="1" fid="82" sl="35" sc="13" el="35" ec="14" />
<pt visit="2" pos="1" len="4" fid="82" sl="36" sc="17" el="36" ec="39" />
<pt visit="2" pos="5" len="2" fid="82" sl="37" sc="13" el="37" ec="14" />
</Method>
and this:
<File id="66" url="D:\sandbox\idblue\idblue\trunk\software\code\driver\dotnet\Common\AsyncEventQueue.cs" />
All I want to be able to do is view what lines of code are not being covered in my test cases without having to figure out what the xml above is trying to tell me.
Thanks to anyone in advance who replies.
I figured out why the cs files were not displaying. The paths were incorrect in the xml file because our test project was being built on a different machine than the one partcover was on. (partcover must generate the .cs file paths from pdb files maybe?) Once I search and replaced the file switching the base directory of our subversion location to the one on the other machine all was well.

Resources