Trying to read *.xlsx file using POI API - java

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

Related

Java - File not found exception - shared location is missing a slash

I have a single liner code "Hello World" that I am executing, however it is failing every time I try to execute it.
From the looks, the shared drive location is missing a slash "/", I am just not sure where to explicitly declare or set this up. I have combed through the project settings but to no avail.
Or if there is something else I am missing, pls help.
I am a noob in Java so apologies in advance.
Code:
public static void main(String[] args) {
System.out.println("Hello World");
}
Below is the error:
Error:Internal error: (java.io.FileNotFoundException) \sgrau999bab01.ocean.corp.xyz.com\lllaaabbb$\.IdeaIC13\system\compile-server\helloworld_edf69b40\timestamps\data (The system cannot find the path specified)
java.io.FileNotFoundException: \sgrau999bab01.ocean.corp.xyz.com\lllaaabbb$\.IdeaIC13\system\compile-server\helloworld_edf69b40\timestamps\data (The system cannot find the path specified)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
at com.intellij.util.io.PagedFileStorage.resizeFile(PagedFileStorage.java:339)
at com.intellij.util.io.PagedFileStorage.resize(PagedFileStorage.java:323)
at com.intellij.util.io.ResizeableMappedFile.<init>(ResizeableMappedFile.java:59)
at com.intellij.util.io.PersistentBTreeEnumerator.<init>(PersistentBTreeEnumerator.java:76)
at com.intellij.util.io.PersistentEnumeratorDelegate.<init>(PersistentEnumeratorDelegate.java:38)
at com.intellij.util.io.PersistentEnumeratorDelegate.<init>(PersistentEnumeratorDelegate.java:31)
at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:110)
at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:106)
at org.jetbrains.jps.incremental.storage.AbstractStateStorage.createMap(AbstractStateStorage.java:137)
at org.jetbrains.jps.incremental.storage.AbstractStateStorage.<init>(AbstractStateStorage.java:42)
at org.jetbrains.jps.incremental.storage.TimestampStorage.<init>(TimestampStorage.java:36)
at org.jetbrains.jps.incremental.storage.ProjectTimestamps.<init>(ProjectTimestamps.java:36)
at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:101)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:198)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:113)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:133)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
The output expected is a simple print of the text "Hello World"
sgrau999bab01.ocean.corp.xyz.com looks like a set of nested packages. You can access package content using '.' notation in Java but to read files we have to provide the folder path (using '/' or '\')
Can you try replacing
\sgrau999bab01.ocean.corp.xyz.com\lllaaabbb$\.IdeaIC13\system\compile-server\helloworld_edf69b40\timestamps\data
with
\sgrau999bab01\ocean\corp\xyz\com\lllaaabbb$\.IdeaIC13\system\compile-server\helloworld_edf69b40\timestamps\data
and check if it works?
I am not sure of the premise of your question and looks like you could add a few details about where is the file being read from.
P.S. I would have mentioned this as a comment but I don't have the privilege to do so. Apologies.
The problem with using backslashes as file path separators is that sometimes they lead to unintended characters. For example, the file path:
String path = "some\npath";
actually has a newline character in it. One simple way to avoid this problem is to just use forward slashes instead:
/sgrau999bab01.ocean.corp.xyz.com/lllaaabbb$/.IdeaIC13/system/compile-server/helloworld_edf69b40/timestamps/data

Why Scala on Mac fails when run in unicode directory

I am attempting to simply compile a helloworld scala file from within a directory named using unicode characters but the scala compiler fails to run. It succeeds when I change directory's out the unicode named folder.
Detail
Given a classic Helloworld.scala class such as the one below
that is located in the directory:
/Users/me/Dev/Company/𝔘𝔫𝔦𝔠𝔬𝔡𝔢/code_folder
I am unable to run scalac on the code if my current directory is in code_folder which is the root directory for the Helloworld.scala. When I change directories out of the folder with the unicode name /𝔘𝔫𝔦𝔠𝔬𝔡𝔢, the compiler works just fine on the same code. So it would seem that scalac doesnt work when attempting to compile code while in a folder with unicode characters.
Why is that? Is this a system error? An unparsed unicode error between the OS starting the scalac process?
object Main{
def main(args: Array[String]): Unit = {
println("Hello world")
}
}
I expected a compiled file. The error I get is this
Exception in thread "main" java.lang.ExceptionInInitializerError
at scala.tools.util.PathResolver$Environment$.scalaExtDirs(PathResolver.scala:77)
at scala.tools.util.PathResolver$Defaults$.scalaExtDirs(PathResolver.scala:127)
at scala.tools.nsc.settings.StandardScalaSettings.$init$(StandardScalaSettings.scala:31)
at scala.tools.nsc.settings.MutableSettings.<init>(MutableSettings.scala:28)
at scala.tools.nsc.Settings.<init>(Settings.scala:19)
at scala.tools.nsc.Driver.process(Driver.scala:53)
at scala.tools.nsc.Driver.main(Driver.scala:80)
at scala.tools.nsc.Main.main(Main.scala)
Caused by: java.lang.IllegalArgumentException: Error decoding percent encoded characters
at java.base/sun.net.www.ParseUtil.decode(ParseUtil.java:209)
at java.base/jdk.internal.loader.FileURLMapper.getPath(FileURLMapper.java:64)
at java.base/jdk.internal.loader.FileURLMapper.exists(FileURLMapper.java:73)
at java.base/jdk.internal.loader.URLClassPath$JarLoader.getJarFile(URLClassPath.java:802)
at java.base/jdk.internal.loader.URLClassPath$JarLoader.access$900(URLClassPath.java:692)
at java.base/jdk.internal.loader.URLClassPath$JarLoader$1.run(URLClassPath.java:751)
at java.base/jdk.internal.loader.URLClassPath$JarLoader$1.run(URLClassPath.java:744)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/jdk.internal.loader.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:743)
at java.base/jdk.internal.loader.URLClassPath$JarLoader.<init>(URLClassPath.java:718)
at java.base/jdk.internal.loader.URLClassPath$3.run(URLClassPath.java:486)
at java.base/jdk.internal.loader.URLClassPath$3.run(URLClassPath.java:469)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/jdk.internal.loader.URLClassPath.getLoader(URLClassPath.java:468)
at java.base/jdk.internal.loader.URLClassPath.getLoader(URLClassPath.java:437)
at java.base/jdk.internal.loader.URLClassPath.findResource(URLClassPath.java:280)
at java.base/jdk.internal.loader.BuiltinClassLoader.findResourceOnClassPath(BuiltinClassLoader.java:479)
at java.base/jdk.internal.loader.BuiltinClassLoader.findResource(BuiltinClassLoader.java:303)
at java.base/java.lang.ClassLoader.getResource(ClassLoader.java:1393)
at java.base/java.lang.ClassLoader.getSystemResource(ClassLoader.java:1658)
at java.base/java.lang.ClassLoader.getSystemResourceAsStream(ClassLoader.java:1762)
at java.base/java.lang.Class.getResourceAsStream(Class.java:2607)
at scala.util.PropertiesTrait.scalaProps(Properties.scala:39)
at scala.util.PropertiesTrait.scalaProps$(Properties.scala:37)
at scala.tools.reflect.WrappedProperties$AccessControl$.scalaProps$lzycompute(WrappedProperties.scala:49)
at scala.tools.reflect.WrappedProperties$AccessControl$.scalaProps(WrappedProperties.scala:49)
at scala.util.PropertiesTrait.scalaPropOrNone(Properties.scala:71)
at scala.util.PropertiesTrait.scalaPropOrNone$(Properties.scala:71)
at scala.tools.reflect.WrappedProperties$AccessControl$.scalaPropOrNone(WrappedProperties.scala:49)
at scala.util.PropertiesTrait.$init$(Properties.scala:83)
at scala.tools.reflect.WrappedProperties$AccessControl$.<init>(WrappedProperties.scala:49)
at scala.tools.reflect.WrappedProperties$AccessControl$.<clinit>(WrappedProperties.scala)
... 8 more
Version:
scalac -version
Scala compiler version 2.12.8 -- Copyright 2002-2018, LAMP/EPFL and Lightbend, Inc.
MacOS version 10.13.6
Not really a solution, but some piece of information:
I set up my folder this way:
/home/nicolas/Private/𝔘𝔫𝔦𝔠𝔬𝔡𝔢/
When the ClassLoader tries to load the classes of your project it makes a list of paths where to lookup classes as a list of URLClassPath
Now when the code goes on and it tries to parse these paths, it calls sun.net.www.ParseUtil.decode()
When I put a breakpoint in here, I can see that the path for our class is:
/home/nicolas/Private/%ed%a0%b5%ed%b4%98%ed%a0%b5%ed%b4%ab%ed%a0%b5%ed%b4%a6%ed%a0%b5%ed%b4%a0%ed%a0%b5%ed%b4%ac%ed%a0%b5%ed%b4%a1%ed%a0%b5%ed%b4%a2/target/scala-2.12/classes/
so it somehow translated 𝔘𝔫𝔦𝔠𝔬𝔡𝔢 into a percent encoded string : %ed%a0%b5%ed%b4%98%ed%a0%b5%ed%b4%ab%ed%a0%b5%ed%b4%a6%ed%a0%b5%ed%b4%a0%ed%a0%b5%ed%b4%ac%ed%a0%b5%ed%b4%a1%ed%a0%b5%ed%b4%a2
This in turn creates a CharsetDecoder for UTF-8:
CharsetDecoder dec = ThreadLocalCoders.decoderFor("UTF-8")
.onMalformedInput(CodingErrorAction.REPORT)
.onUnmappableCharacter(CodingErrorAction.REPORT);
and tries to decode the above url but it fails and that is why the classes can't be loaded.
Now if I go here https://www.branah.com/unicode-converter and tries to convert 𝔘𝔫𝔦𝔠𝔬𝔡𝔢 to a % encoded string, it gives me
%f0%9d%94%98%f0%9d%94%ab%f0%9d%94%a6%f0%9d%94%a0%f0%9d%94%ac%f0%9d%94%a1%f0%9d%94%a2
And if when I debug, I change the url using this encoded string value, ie
/home/nicolas/Private/%f0%9d%94%98%f0%9d%94%ab%f0%9d%94%a6%f0%9d%94%a0%f0%9d%94%ac%f0%9d%94%a1%f0%9d%94%a2/target/scala-2.12/classes/
Then it parses it properly and keeps going.
So I don't know where it gets that %ed%a0%b5%ed%b4%98%ed%a0%b5%ed%b4%ab%ed%a0%b5%ed%b4%a6%ed%a0%b5%ed%b4%a0%ed%a0%b5%ed%b4%ac%ed%a0%b5%ed%b4%a1%ed%a0%b5%ed%b4%a2
The interesting thing is that if I use the same website and try to convert back %ed%a0%b5%ed%b4%98%ed%a0%b5%ed%b4%ab%ed%a0%b5%ed%b4%a6%ed%a0%b5%ed%b4%a0%ed%a0%b5%ed%b4%ac%ed%a0%b5%ed%b4%a1%ed%a0%b5%ed%b4%a2 then I also get 𝔘𝔫𝔦𝔠𝔬𝔡𝔢
So I am a bit confused

broken pipe process using javaoctave

Hi I'm using the javaoctave package to bridge with octave from my computer to perform some calculation. However, I encountered the following error while compiling:
error: save: Unrecognized option '-'
Exception in thread "main" dk.ange.octave.exception.OctaveIOException: IOException during close
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at dk.ange.octave.exec.OctaveExec.reInstantiateException(OctaveExec.java:184)
at dk.ange.octave.exec.OctaveExec.getFromFuture(OctaveExec.java:165)
at dk.ange.octave.exec.OctaveExec.eval(OctaveExec.java:142)
at dk.ange.octave.io.OctaveIO.get(OctaveIO.java:75)
at dk.ange.octave.OctaveEngine.get(OctaveEngine.java:161)
at dk.ange.octave.OctaveEngine.get(OctaveEngine.java:176)
at learn.capability.CapabilityMeanVarianceEquation.learnCapabilities(CapabilityMeanVarianceEquation.java:214)
at learn.graph.SimulatedAnnealingLearner.learnSynergyGraph(SimulatedAnnealingLearner.java:69)
at parse.basketball.runner.GetPlayerFrequency.learnSynergyGraph(GetPlayerFrequency.java:112)
at parse.basketball.runner.GetPlayerFrequency.main(GetPlayerFrequency.java:96)
Caused by: dk.ange.octave.exception.OctaveIOException: IOException during close
at dk.ange.octave.exec.OctaveReaderCallable.call(OctaveReaderCallable.java:65)
at dk.ange.octave.exec.OctaveReaderCallable.call(OctaveReaderCallable.java:28)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
Caused by: java.io.IOException: Pipe to octave-process broken
at dk.ange.octave.exec.OctaveExecuteReader.read(OctaveExecuteReader.java:68)
at java.io.Reader.read(Reader.java:123)
at dk.ange.octave.exec.OctaveExecuteReader.close(OctaveExecuteReader.java:96)
at dk.ange.octave.exec.OctaveReaderCallable.call(OctaveReaderCallable.java:61)
... 6 more
I'm not sure how I have come across this error. However, I have closely checked my input so I think there isn't any problem with that. The program I use have successfully run before.
Hope someone can help, thanks!
This relates to a "bug" that exists in some Octave versions where the "-" option for the "save" command is not respected. This is probably fixed in later versions of Octave but until then you can modify JavaOctave like so:
In DataReadFunctor.doReads(final Reader reader), comment the following lines out:
// final String createByOctaveLine = readerReadLine(bufferedReader);
// if (createByOctaveLine == null || !createByOctaveLine.startsWith("# Created by Octave")) {
// throw new OctaveParseException("Not created by Octave?: '" + createByOctaveLine + "'");
// }
In OctaveIO.get(final String name), edit the following line:
final WriteFunctor writeFunctor = new ReaderWriteFunctor(new StringReader("save -text - " + name));
to this:
final WriteFunctor writeFunctor = new ReaderWriteFunctor(new StringReader("save -text /dev/stdout " + name));
These changes should work around the issue or at least set you in the right direction, but I wouldn't suggest this as a patch since the bug is actually in some versions of Octave (the documentation of 'save' does say that '-' is a valid option to output to terminal rather than to file)

Can't build spring framework using gradle on Windows 7 x64

Platform: Windows 7 x64
JDK version: 7.0.25 x64 or 7.0.45 x64
JDK installation path:
C:\Java\jdk725 or default c:\Program Files\Java\jdk1.7.0_25\
Spring Framework Release: 3.2.4 or 3.2.5
UAC: enabled or disabled
gradlew build (after gradlew):
:referenceHtmlMulti FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':referenceHtmlMulti'.
Failed to compile stylesheet. 59 errors detected.
Try:
Run with --info or --debug option to get more log output.
Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':referen
ceHtmlMulti'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecute(ExecuteActionsTaskExecuter.java:46)
..
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: javax.xml.transform.TransformerConfigurationException: Failed to comp
ile stylesheet. 59 errors detected.
at com.icl.saxon.PreparedStyleSheet.prepare(PreparedStyleSheet.java:136)
at com.icl.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryI
mpl.java:127)
at com.icl.saxon.TransformerFactoryImpl.newTransformer(TransformerFactor
yImpl.java:79)
..
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:61)
... 70 more
BUILD FAILED
My question is: why did my build fail?
The problem happens when :referenceHtmlMulti task is executing.
If we look in groovy class we will see that XSLT transformation is used to create docbook-reference. Despite the fact, that Saxon is used (TransformerFactoryImpl is selected) the choosen SAXParserFactory is org.apache.xerces.jaxp.SAXParserFactoryImpl (I wonder why not to use com.icl.saxon.aelfred.SAXParserFactoryImpl).
IF we look what implementation of xerces is used by gradle we will see xercesImpl-2.9.1.jar, which is old enough.
Now let's find class URI in xerces sources. It represents a Uniform Resource Identifier (URI). On line 1134 we can find
else if (!isURICharacter(testChar)) {
throw new MalformedURIException(
"Opaque part contains invalid character: " + testChar);
}
Now let's look how this function works:
private static boolean isURICharacter (char p_char) {
return (p_char <= '~' && (fgLookupTable[p_char] & MASK_URI_CHARACTER) != 0);
}
We can see that function will return true if char comparision will return true also. But that means rather close limits of chars (from code 0 - 126 (~)). But what about non US-ASCII character set?
Let's read RFC 2396 about non us-ascii characters (that can exist in your windows path, representing your local language or can be found in account name, under which gradle unpacks itself and works): other catagory - The Unicode characters that are not in the US-ASCII character set, are not control characters (according to the Character.isISOControl method), and are not space characters (according to the Character.isSpaceChar method) (Deviation from RFC 2396, which is limited to US-ASCII). The set of all legal URI characters consists of the unreserved, reserved, escaped, and other characters.
So. URI identification fails. And that is the place where build code fails.
There are 2 solutions:
To make your account name or path consist only of US-ASCII characters.
To patch URI class (for example, by rewriting function isURICharacter)

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