org.xml.sax.SAXNotRecognizedException when running runnable jar with java 8 - java

I am exporting my project as runnable jar and execute in java 8 environment. But I am getting
org.xml.sax.SAXNotRecognizedException: http://javax.xml.XMLConstants/feature/sec
ure-processing
at org.apache.xerces.parsers.AbstractSAXParser.setFeature(Unknown Source
)
at org.apache.xerces.jaxp.SAXParserImpl.setFeatures(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParserImpl(Unknown
Source)
I tried with xercesImpl.2.11.0 and got :
javax.xml.bind.UnmarshalException - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 63; columnNumber: 9; The string "--"
is not permitted within comments.]
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalExcept
ion(AbstractUnmarshallerImpl.java)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.cr
eateUnmarshalException(UnmarshallerImpl.java:)
Please provide a solution?

Below error comes if something is wrong in your XML or HTML:
The string "--" is not permitted within comments.
An HTML comment begins with "<!--", ends with "-->" and does not contain "--" or ">" anywhere in the comment.
Go through this URL(HTML Comments) for more details.

Related

Why java.lang.ClassFormatError: JVMCFRE114 field name is invalid occurs on AIX when Proguard is used?

I have used Proguard on the jar file to obfuscate it. It works very well on Windows and Linux but when deployed on AIX it gives following error.
2019-06-29 13:09:12:192 [ERROR] [main:ID=1]:[null:-1] java.lang.ClassFormatError: JVMCFRE114 field name is invalid; class=Messaging/broadcaster/OracleWriterMessageBroadcaster, offset=0
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:346)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:718)
at java.net.URLClassLoader.access$400(URLClassLoader.java:95)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1169)
at java.security.AccessController.doPrivileged(AccessController.java:742)
at java.net.URLClassLoader.findClass(URLClassLoader.java:601)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:792)
at java.lang.ClassLoader.loadClass(ClassLoader.java:766)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325)
at java.lang.ClassLoader.loadClass(ClassLoader.java:747)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:257)
at UniversalGprsClientService.ProcessMonitor.a(Unknown Source)
at UniversalGprsClientService.ProcessMonitor.main(Unknown Source)
This is the code snippet where the error occurs:
Class<?> c = Class.forName(sClassName);
Constructor<?> cons = c.getConstructor();
IMessageBroadcaster clsBroadcaster = (IMessageBroadcaster) cons.newInstance();
clsBroadcaster.setAppSettings(clsAppSettings);
clsBroadcaster.setProcessMonitor(clsMonitor);
return clsBroadcaster;
I guess it could be solved by just hard coding the classes but it means loosing some flexibility it offers.

javassist.CannotCompileException: [source error] no such field: $1

Referring to : http://jboss-javassist.github.io/javassist/tutorial/tutorial2.html
method.insertBefore("{ System.out.println($1);}");
This statement gives me following error:
Exception: javassist.CannotCompileException: [source error] no such field: $1
javassist.CannotCompileException: [source error] no such field: $1
at javassist.CtBehavior.insertBefore(CtBehavior.java:774)
at javassist.CtBehavior.insertBefore(CtBehavior.java:734)
at com.here.debugHelper.DurationTransformer.transform(DurationTransformer.java:124)
at sun.instrument.TransformerManager.transform(Unknown Source)
at sun.instrument.InstrumentationImpl.transform(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.here.debugHelper.TestInstrumentation.main(TestInstrumentation.java:10)
Caused by: compile error: no such field: $1
at javassist.compiler.TypeChecker.fieldAccess(TypeChecker.java:845)
at javassist.compiler.TypeChecker.atFieldRead(TypeChecker.java:803)
at javassist.compiler.TypeChecker.atMember(TypeChecker.java:988)
at javassist.compiler.JvstTypeChecker.atMember(JvstTypeChecker.java:66)
at javassist.compiler.ast.Member.accept(Member.java:39)
at javassist.compiler.JvstTypeChecker.atMethodArgs(JvstTypeChecker.java:221)
at javassist.compiler.TypeChecker.atMethodCallCore(TypeChecker.java:735)
at javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:695)
at javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:157)
at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)
at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:242)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:330)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:351)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
at javassist.compiler.Javac.compileStmnt(Javac.java:567)
at javassist.CtBehavior.insertBefore(CtBehavior.java:754)
... 17 more
Moreover,the same error appears when I use any parameter(passed to the parameter) or any local variable instead of '$1'. This has been covered in this question, but I don't really understand the solution there.
There is this other post with same question but no answer.
Please help. Thank you
Alright, this is how I worked around the problem. There were few mistakes that I was overlooking and some things that I learnt. I am sharing this since I could not find the content directly addressing the issue anywhere.
Referring to this answer and this article:
The insertBefore, insertAfter and other such methods cannot access any local variable but can access method parameter of the method by their names. no such field error occurs if attempt is made to access local variable.
These methods cannot access any parameter declared within them as a process of instrumentation.
ctmethod.insertBefore("{int i = 4; int j = 9;}")
ctmethod.insertBefore("i = 5;");
ctMethod.insertAfter("j = 9;");
The above code will give no such field: j(and i) error
insertBefore, insertAfter, expect a single statement, or a single block of code as done in first line of above code snippet.
This error no such field appears in case when variables are used in ctmethod.addcatch() too.
ctmethod.addLocalVariable() helps in declaring a variable that can be accessed by insertBefore(), etc. However, .addCatch() will still give no such field error if you try to use variable declared using .addLocalVariable()
I was getting no such field: $1 due to my silly mistake. I was going iterating through a number of method in a class, so the error was due to the fact that some of those methods had zero arguments. $1,$2.. and $args work well as explained in this doc.
P.S. I will add further tips as I come across them and any corrections are welcomed.

"Could not parse ontology" that was included into other ontology(owl-api)

I try to load an ontology (test.owl) that includes bfo.owl.
Versions of the used APIs:
OWL-API 3.4.3
hermit 1.3.8.4
It is possible to open the test ontology with Protégé 5.
But when I try to load test.owl with my code, I get the error message below, which I don't understand. Is there anybody out there who can help me understanding the message and finding a way to load the ontology?
org.semanticweb.owlapi.model.UnloadableImportException: Could not load imported ontology: http://purl.obolibrary.org/obo/bfo/2014-05-03/bfo.owl Cause: Problem parsing http://purl.obolibrary.org/obo/bfo/2014-05-03/bfo.owl
Could not parse ontology. Either a suitable parser could not be found, or parsing failed. See parser logs below for explanation.
The following parsers were tried:
1) RDFXMLParser
2) OWLXMLParser
3) OWLFunctionalSyntaxOWLParser
4) TurtleOntologyParser
5) OWLOBOParser
6) KRSS2OWLParser
7) ManchesterOWLSyntaxOntologyParser
Detailed logs:
--------------------------------------------------------------------------------
Parser: RDFXMLParser
org.xml.sax.SAXParseException; systemId: http://purl.obolibrary.org/obo/bfo/2014-05-03/bfo.owl; lineNumber: 1; columnNumber: 50; Leerstellen erforderlich zwischen publicId und systemId.
--------------------------------------------------------------------------------
Parser: OWLXMLParser
org.xml.sax.SAXParseException; systemId: http://purl.obolibrary.org/obo/bfo/2014-05-03/bfo.owl; lineNumber: 1; columnNumber: 50; Leerstellen erforderlich zwischen publicId und systemId
Sorry for having the second part of the error message in a different style - but as I am not allowed to have more than 2 links in a text (due to lack of reputation) and I still wanted you to be able to test the link to bfo.owl, I had to be creative.
Owlapi 3.4 is ancient and many bugs have been fixed since. Protégé 5 uses 4.2.5.
There is a HermiT release compatible with owlapi 4, search Maven Central for version 1.3.8.413 (I curated the fork, it's released under net.sourceforge.owlapi).
This is also the HermiT version bundled with Protege 5.

Trying to read *.xlsx file using POI API

I am trying to read an *.xlsx file and i receive quite a lot of errors in the console. I am a beginner at this and please note that if i try to read *.xls files i have no problems there.
This is the code that i use:
public class XlsxTest {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream(new File("autotest2.xlsx"));
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet = wb.getSheetAt(0);
FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
for (Row row : sheet) {
for (Cell cell : row) {
switch (formulaEvaluator.evaluateInCell(cell).getCellType()) {
case Cell.CELL_TYPE_NUMERIC:
System.out.println(cell.getNumericCellValue() + "\t\t");
break;
case Cell.CELL_TYPE_STRING:
System.out.println(cell.getStringCellValue() + "\t\t");
break;
}
}
System.out.println();
}
}
}
When i try to run this i receive the following errors:
Exception in thread "main" org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:465)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:173)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:278)
at XlsxTest.main(XlsxTest.java:18)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)
... 4 more
Caused by: java.lang.ExceptionInInitializerError
at org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem.fillInType(BuiltinSchemaTypeSystem.java:1025)
at org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem.<clinit>(BuiltinSchemaTypeSystem.java:223)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.xmlbeans.XmlBeans.getNoType(XmlBeans.java:856)
at org.apache.xmlbeans.XmlBeans.<clinit>(XmlBeans.java:881)
at org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:83)
... 9 more
Caused by: java.lang.RuntimeException: Installation Problem??? Couldn't load messages: Can't find bundle for base name org.apache.xmlbeans.impl.regex.message, locale en_US
at org.apache.xmlbeans.impl.regex.RegexParser.setLocale(RegexParser.java:88)
at org.apache.xmlbeans.impl.regex.RegexParser.<init>(RegexParser.java:78)
at org.apache.xmlbeans.impl.regex.ParserForXMLSchema.<init>(ParserForXMLSchema.java:28)
at org.apache.xmlbeans.impl.regex.RegularExpression.setPattern(RegularExpression.java:2996)
at org.apache.xmlbeans.impl.regex.RegularExpression.setPattern(RegularExpression.java:3009)
at org.apache.xmlbeans.impl.regex.RegularExpression.<init>(RegularExpression.java:2975)
at org.apache.xmlbeans.impl.regex.SchemaRegularExpression.<init>(SchemaRegularExpression.java:27)
at org.apache.xmlbeans.impl.regex.SchemaRegularExpression.<init>(SchemaRegularExpression.java:23)
at org.apache.xmlbeans.impl.regex.SchemaRegularExpression$1.<init>(SchemaRegularExpression.java:44)
at org.apache.xmlbeans.impl.regex.SchemaRegularExpression.buildKnownPatternMap(SchemaRegularExpression.java:43)
at org.apache.xmlbeans.impl.regex.SchemaRegularExpression.<clinit>(SchemaRegularExpression.java:38)
... 19 more
Can anyone help me with this issue? I hope that i provided the necessary information.
Thank you!
Rename jar of lib in zip or simply open org/apache/xmlbeans/impl/regex of loaded lib.
Find file message.properties (and message_xx.properties if necessary).
Put file(s) in used library by org/apache/xmlbeans/impl/regex path.
Profit!
I experienced the very similar exception when using Apache POI: a java.lang.ExceptionInInitializerError, caused by "java.lang.RuntimeException: Installation Problem??? Couldn't load messages: Can't find bundle for base name org.apache.xmlbeans.impl.regex.message" in XMLBeans.
Looked completely weird. Code worked on one machine but failed this way on another for no apparent reason.
After LOTS of debugging hours, I found out the reason was COMPLETELY unrelated to Excel, POI or XMLBeans: my project was located in the folder ending with "!". The solution was simply to rename the folder.
I guess the author had something similar happening, and indeed the linked post about Libre Office has nothing to do with this problem. Instead, the linked post should be the following: Unable to open resources in directories which end with an exclamation mark (!)
Got this error ONLY in junit test. Application runs perfectly fine. So check your case as well.
For test, following Sarck's suggestion worked. #4 is little confusing. So below is simple process.. works fine for 2.6 version of xmlbeans library.
In your project where this is failing, create a file named message.properties under src/test/resources/org/apache/xmlbeans/impl/regex folder. (src/test/resources is typical maven root resource folder). Add following content in that file
parser.parse.1=Wrong character.
parser.parse.2=Invalid reference number.
parser.next.1=A character is required after \\.
parser.next.2='?' is not expected. '(?:' or '(?=' or '(?!' or '(?<' or '(?#' or '(?>'?
parser.next.3='(?<=' or '(?<!' is expected.
parser.next.4=A comment is not terminated.
parser.factor.1=')' is expected.
parser.factor.2=Unexpected end of the pattern in a modifier group.
parser.factor.3=':' is expected.
parser.factor.4=Unexpected end of the pattern in a conditional group.
parser.factor.5=A back reference or an anchor or a lookahead or a lookbehind is expected in a conditional pattern.
parser.factor.6=There are more than three choices in a conditional group.
parser.atom.1=A character in U+0040-U+005f must follow \\c.
parser.atom.2=A '{' is required before a character category.
parser.atom.3=A property name is not closed by '}'.
parser.atom.4=Unexpected meta character.
parser.atom.5=Unknown property.
parser.cc.1=A POSIX character class must be closed by ':]'.
parser.cc.2=Unexpected end of the pattern in a character class.
parser.cc.3=Unknown name for a POSIX character class.
parser.cc.4='-' is invalid here.
parser.cc.5=']' is expected.
parser.cc.6='[' is invalid in a character class. Write '\\['.
parser.cc.7=']' is invalid in a character class. Write '\\]'.
parser.cc.8='-' is an invalid character range. Write '\\-'.
parser.ope.1='[' is expected.
parser.ope.2=')' or '-[' or '+[' or '&[' is expected.
parser.ope.3=The range end code point is less than the start code point.
parser.descape.1=Invalid Unicode hex notation.
parser.descape.2=Overflow in a hex notation.
parser.descape.3='\\x{' must be closed by '}'.
parser.descape.4=Invalid Unicode code point.
parser.descape.5=An anchor must not be here.
parser.process.1=This expression is not supported in the current option setting.
parser.quantifier.1=Invalid quantifier. A digit is expected.
parser.quantifier.2=Invalid quantifier. Invalid quantity or a '}' is missing.
parser.quantifier.3=Invalid quantifier. A digit or '}' is expected.
parser.quantifier.4=Invalid quantifier. A min quantity must be <= a max quantity.
parser.quantifier.5=Invalid quantifier. A quantity value overflow.
Duplicate this file as message_en.properties at same location.
If you are using newer version of xmlbeans jar then get content of this file from Apache source - replace version in url

Java filename with bracket

I'm always getting an error when I try to read some files from my flashdrive. All of the files contain a left parenthesis but not a right one. I have too many files to change each file seperately.
Thats my code:
String src;
src = "C:\\Users\\Marc\\Desktop\\Musik\\02 The Uncrushables (feat. ILL Bill.mp3"
File tempMP3 = new File(src);
And that the Error message I'm getting:
Exception in thread "main" org.farng.mp3.TagException: Unable to create FilenameTag
at org.farng.mp3.MP3File.<init>(Unknown Source)
at org.farng.mp3.MP3File.<init>(Unknown Source)
at org.farng.mp3.MP3File.<init>(Unknown Source)
at NewID3.main(NewID3.java:55)
Caused by: org.farng.mp3.TagException: Unmatched parenthesis in "02 The Uncrushables (feat. ILL Bill" at position : 20
at org.farng.mp3.filename.FilenameTagBuilder.parseParenthesis(Unknown Source)
at org.farng.mp3.filename.FilenameTagBuilder.createCompositeFromToken(Unknown Source)
at org.farng.mp3.filename.FilenameTagBuilder.createFilenameTagFromMP3File(Unknown Source)
... 4 more
Java Result: 1
Does anybody know how I can solve this?
Thanks for ur help in advance!
PS: If i haven't explained myself clearly enough please tell me and I'll try to do better.
It's not Java per se. It's the library you're using.
Caused by: org.farng.mp3.TagException: Unmatched parenthesis in "02 The Uncrushables (feat. ILL Bill" at position : 20
at org.farng.mp3.filename.FilenameTagBuilder.parseParenthesis(Unknown Source)
Your library is attempting to parse the filename. A simple Java File object wouldn't care at all.

Categories