how to solve Exception in Ical4j? - java

I am using ical4j for parsing outlook calendar file.When i parse the file it gives the exception as follows
Error at line 60:Illegal character in opaque part at index 4: CID:<FFFF__=0ABBFDFEDFCB93A98f9e8a9#medicraft.com.au>
How to solve this problem without changing the calendar file.

If you enable the NOTES_COMPATIBILITY CompatibilityHint this exception should go away. You can do this either programmatically:
CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_NOTES_COMPATIBILITY, true);
or via the following line in the ical.properties added to the classpath:
ical4j.compatibility.notes=true
See the ical4j wiki for further details:
http://wiki.modularity.net.au/ical4j/index.php?title=Compatibility

Related

Using toUpperCase with Correct Locale

I'm trying to fix errors which are reported by forbiddenapis. I had that line:
paramMap.put(Config.TITLEBOOST.toUpperCase(), titleBoost);
So, its been reported as error as usual. I've tried that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.getDefault()), titleBoost);
and that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.ROOT), titleBoost);
also that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.ENGLISH), titleBoost);
However none of them fixed the error:
[forbiddenapis] Forbidden method invocation:
java.lang.String#toUpperCase() [Uses default locale]
What I miss?
Double-check that the bytecode you are analyzing is actually your most recent build output, and that you're looking at the same line forbiddenapis is :) . This looks to me like your source/bytecode/analysis are falling out of sync — the relevant rule shouldn't flag an error on String.toUpperCase(Locale).
Disclaimer: I haven't used forbiddenapis myself --- I wrote this answer based on the repo and on a blog post I found.

Exception in thread "main" java.lang.RuntimeException: Not yet implemented

I am fetching some problem when I trying to print Arabic letter by using DirectPrint bean. This is a pjc. English fonts are printed fine, but when I want to print Arabic there is showing a exception below:
Exception in thread "main" java.lang.RuntimeException: Not yet implemented
at org.pdfbox.pdmodel.font.PDType0Font.drawString(PDType0Font.java:75)
at org.pdfbox.pdfviewer.PageDrawer.showCharacter(PageDrawer.java:160)
at org.pdfbox.util.PDFStreamEngine.showString(PDFStreamEngine.java:409)
at org.pdfbox.util.operator.ShowTextGlyph.process(ShowTextGlyph.java:80)
at org.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:452)
at org.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:215)
at org.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:174)
at org.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:104)
at org.pdfbox.pdmodel.PDPage.print(PDPage.java:741)
at sun.print.RasterPrinterJob.printPage(RasterPrinterJob.java:1936)
at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1431)
at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1247)
at dsd.printing.DirectPrint.main(DirectPrint.java:842)
Please help to solve this issue.
Seems like the Arabic characters are not implemented to be converted by the pdfbox library you're using.
What version of PDFBox you are using? What I see from here:
Exception in thread "main" java.lang.RuntimeException: Not yet implemented
at org.pdfbox.pdmodel.font.PDType0Font.drawString(PDType0Font.java:75)
That it says PDType0Font class and drawString method straightly throws 'Not yet implemented' exception but i.e. if I check one of the latest version (i.e. 1.8.10) I can see the method implemented: here
If I would be I would try to change the version of pdfbox library and try again.
EDIT: Thanks to Tilman, latest version info from his comment: 2.0 has been released friday, it should be available for maven: mvnrepository.com/artifact/org.apache.pdfbox/pdfbox

Using Voce speech recognition in Java

I've been trying to get speech recognition to work on a Java application, I've tried Sphinx but it's too complex for what I need, so I found Voce.
I'm trying to get the recognition demo to work.
The problem is I can't initialize the SpeechInterface, here's the code I've been using:
voce.SpeechInterface.init("C:/Users/G/Documents/NetBeansProjects/VoceTest/lib",
false,
true,
"C:/Users/G/Documents/NetBeansProjects/VoceTest/lib/gram",
"digits");
I have a grammar file named digits.gram in the gram folder inside the lib folder.
As a result I get:
[Voce ERROR] Cannot configure speech recognizer:
Property Exception component:'jsgfGrammar' property:'grammarLocation' - value (C:/Users/G/Documents/NetBeansProjects/VoceTest/lib/gram) is not a valid Resource
at edu.cmu.sphinx.util.props.ValidatingPropertySheet.setRaw(ValidatingPropertySheet.java:137)
at edu.cmu.sphinx.util.props.ConfigurationManager.setProperty(ConfigurationManager.java:250)
at voce.SpeechRecognizer.<init>(SpeechRecognizer.java:85)
at voce.SpeechInterface.init(SpeechInterface.java:79)
at vocetest.VoceTest.main(VoceTest.java:18)
I read the docs but I can't figure out what I'm doing wrong
"file:/C:/Users/G/Documents/NetBeansProjects/VoceTest/lib/gram","digits");"
The above line should work without errors.

defining keys in play framework application conf file

I'm trying to add new keys in application.conf file in play framework 2.1. I have added the following keys:
gen.db.host=localhost
gen.db.port=27017
gen.db.name=test
When i start my application, it is throwing the following error:
Configuration error: Configuration error[application.conf: 46: port has type NUMBER rather than OBJECT]
......
......
......
Caused by: com.typesafe.config.ConfigException$WrongType: application.conf: 46: port has type NUMBER rather than OBJECT
I don't understand this issue. How can i resolve it? Also, is it a good practice to define new keys in application.conf file?
Thanks.
Put the port between double quotes:
gen.db.port="27017"
You have to use a colon
gen.dn.port:"26017"
Here's a link to the current documentation
http://www.playframework.com/documentation/2.0.x/Configuration
You are propably using wrong method to extract the data from config. I assume you use it like:
current.configuration.getConfig("gen.db.port")
But this method returns play.api.Configuration and expects an object to be under the path "gen.db.port" (as it is mentioned in the error). Since under the "gen.db.port" path you have a number, you should change the method to:
current.configuration.getNumber("gen.db.port")

Disable logging in Java Xerces ("[Fatal Error] :1:1: Content is not allowed in prolog.")

My application expects that it will sometimes try to parse invalid XML documents. I currently catch the "SAXParseException: Content is not allowed in prolog." exception, which works fine. However, Xerces still feels the need to print it's own message to the console:
[Fatal Error] :1:1: Content is not allowed in prolog.
Is there any way to disable this?
I just recently came across the same need. Setting the ErrorHandler to null suppresses the Fatal Error print line.
parser.setErrorHandler(null);
I believe it is printing to System.out or System.err by default. There is an ErrorHandler interface you can set on the Parser if you're interacting with the Xerces classes directly.
Otherwise, you can try setting the property org.apache.xerces.impl.Constants.ERROR_REPORTER_PROPERTY on the SAXParser with an instance of XMLErrorReporter
The equivalent when using org.w3c.dom.ls.LSParser is
parser.getDomConfig().setParameter("error-handler", null);
I had this problem today and it turned out to be a standard configuration parameter that I found only after reading your answers here. Thanks.

Categories

Resources