I am running a shell script which calls a java class to get some data from database and create an excel report with that data. I get the error Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook when the code hits the below line in my java class:
XSSFWorkbook workbook = new XSSFWorkbook ();
This is how I have defined the classpath:
CLASSPATH=${CLASSPATH}:<path-to-jars>/poi-2.5.1-final-20040804.jar
CLASSPATH=${CLASSPATH}:<path-to-jars>/poi-ooxml-3.11.jar
I verified that the jars have been downloaded(via gradle), so trying to understand what am I missing here. Can someone please help me with this?
Stacktrace:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.test.ExcelReportGenerator.writeExcel(ExcelReportGenerator.java:26)
at com.test.ReportRunner.createReport(ReportRunner.java:109)
at com.test.ReportRunner.main(ReportRunner.java:93)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Workbook
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 15 more
As per this Apache POI FAQ entry, mixing POI jars between different versions is not supported and will break in all sorts of ways, such as the one you've found. Don't do it!
You need to be using your POI jars all from the same release. I'd suggest the latest version, available here (currently 3.15)
You should probably also review the components and their dependencies page, to ensure you've got all the required jars for your use of Apache POI. Well, or use a dependency management tool like Maven or Gradle to handle that for you!
I have downloaded the latest Apache POI binaries v3.17 here and it has all the required jars to create xlsx file and open with out any fuss.
Required jars are shown in below screenshots (refer to selected jars) FYR.
For apache poi to work, you need compatible jars.
I used these jars
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>openxml4j</artifactId>
<version>1.0-beta</version>
</dependency>
Delete the poi jar from your maven repository and download or build the project again.
poi 2.5.1 had no such package (and consequently a class) included (you can verify by unpacking the jar files as they are essentially zip archives). See the source.
Update the poi dependency to release 3. This also has the added benefit of matching the ooxml version.
Related
I am attempting to install a custom NAR controller service bundle in my NiFi installation but get this error during startup. It acts like it can't find the RecordReaderFactory class from the nifi-record-serialization-service-api even though it is included as a dependency:
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-record-serialization-service-api</artifactId>
<version>1.9.0</version>
</dependency>
Here is the project:
https://github.com/adamfisher/nifi-zonefile-record-serialization-service
Running maven install builds the NAR successfully. It's just when I startup NiFi, it gives this error. I'm pretty sure this is a maven POM configuration issue. I just don't work with Java too much and hoping someone can shed some light on why it is not finding the dependent class it needs?
nifi-app.log:
2019-03-02 15:22:15,245 INFO [main] org.apache.nifi.web.server.JettyServer Loading WAR: D:\nifi\NIFI-1~2.0\.\work\nar\framework\nifi-framework-nar-1.9.0.nar-unpacked\NAR-INF\bundled-dependencies\nifi-web-error-1.9.0.war with context path set to /
2019-03-02 15:22:15,261 INFO [main] org.apache.nifi.web.server.JettyServer Running in HTTP mode; host headers not restricted
2019-03-02 15:22:16,386 ERROR [main] org.apache.nifi.NiFi Failure to launch NiFi due to java.lang.NoClassDefFoundError: org/apache/nifi/serialization/RecordReaderFactory
java.lang.NoClassDefFoundError: org/apache/nifi/serialization/RecordReaderFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:370)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at org.apache.nifi.nar.StandardExtensionDiscoveringManager.loadExtensions(StandardExtensionDiscoveringManager.java:152)
at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:127)
at org.apache.nifi.nar.StandardExtensionDiscoveringManager.discoverExtensions(StandardExtensionDiscoveringManager.java:113)
at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:925)
at org.apache.nifi.NiFi.<init>(NiFi.java:158)
at org.apache.nifi.NiFi.<init>(NiFi.java:72)
at org.apache.nifi.NiFi.main(NiFi.java:297)
Caused by: java.lang.ClassNotFoundException: org.apache.nifi.serialization.RecordReaderFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 23 common frames omitted
2019-03-02 15:22:16,387 INFO [Thread-1] org.apache.nifi.NiFi Initiating shutdown of Jetty web server...
2019-03-02 15:22:16,387 INFO [Thread-1] org.apache.nifi.NiFi Jetty web server shutdown completed (nicely or otherwise).
The NAR dependencies are used at runtime to create a chain of parent class loaders. So in your example you have
nifi-zonefile-record-serialization-service-nar -> (depends on)
nifi-zonefile-record-serialization-service-api-nar -> (depends on)
nifi-standard-services-api-nar
In the running application when it instantiates the instance of your record reader from your service NAR, it then needs to load the interface that implements which comes from your service API NAR, which then needs to load the RecordReader interface which comes from the standard services API NAR.
I have spent a lot of time on this. Finally, i have a working solution for me. My custom processor is using RecordReader for incoming stream. However, either compile or package failed in maven process. I had to customize pom.xml as following:
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-record-serialization-service-api</artifactId>
<version>${nifi.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-record-serialization-services-nar</artifactId>
<version>${nifi.version}</version>
<type>nar</type>
</dependency>
I ended up needing to include the API NAR file as well even though it doesn't appear to be used anywhere. It's just a generic template class called MyService.
I have the same issue as described here and I managed to solved it including the dependencies at the nar module(nifi-base-nar) pom.xml
The dependency that you need to include is the following:
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-standard-services-api-nar</artifactId>
<version>${nifi.version}</version>
<type>nar</type>
</dependency>
I'm working on studens project, which will need to read data send from AtMega via USB (using virtual serial port). To access serial port I'm using NeuronRobotics' nrjavaserial (https://github.com/NeuronRobotics/nrjavaserial), which is a fork of RXTX. To manage my dependencies I'm using maven. Here's what I get when I run CommPortIdentifier.getPortIdentifiers(); (or whichever static CommPortIdentifier function):
java.lang.UnsatisfiedLinkError: C:\Users\Grześ\AppData\Local\Temp\libNRJavaSerial_Grze?_0\libNRJavaSerial.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at gnu.io.NativeResource.loadResource(NativeResource.java:142)
at gnu.io.NativeResource.inJarLoad(NativeResource.java:40)
at gnu.io.NativeResource.loadLib(NativeResource.java:60)
at gnu.io.NativeResource.load(NativeResource.java:28)
at gnu.io.SerialManager.<init>(SerialManager.java:10)
at gnu.io.SerialManager.getInstance(SerialManager.java:16)
at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:87)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
at pl.edu.pwr.aerospace.enginebench.serial.SerialCommunicator.getAvaliablePorts(SerialCommunicator.java:34)
at pl.edu.pwr.aerospace.enginebench.cli.Main.connectCommunicator(Main.java:35)
at pl.edu.pwr.aerospace.enginebench.cli.Main.main(Main.java:21)
java.lang.UnsatisfiedLinkError: C:\Users\Grześ\AppData\Local\Temp\libNRJavaSerial_Grze?_0\libNRJavaSerial.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at gnu.io.NativeResource.loadResource(NativeResource.java:142)
at gnu.io.NativeResource.inJarLoad(NativeResource.java:40)
at gnu.io.NativeResource.loadLib(NativeResource.java:60)
at gnu.io.NativeResource.load(NativeResource.java:28)
at gnu.io.SerialManager.<init>(SerialManager.java:10)
at gnu.io.SerialManager.getInstance(SerialManager.java:16)
at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:87)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
at pl.edu.pwr.aerospace.enginebench.serial.SerialCommunicator.getAvaliablePorts(SerialCommunicator.java:34)
at pl.edu.pwr.aerospace.enginebench.cli.Main.connectCommunicator(Main.java:35)
at pl.edu.pwr.aerospace.enginebench.cli.Main.main(Main.java:21)
java.lang.ExceptionInInitializerError thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver
Here are my dependencies:
<dependencies>
<dependency>
<groupId>com.neuronrobotics</groupId>
<artifactId>nrjavaserial</artifactId>
<version>3.12.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
Strangly, this only happens during debugging, when I run program normally it works like charm. Any ideas why?
I found that people had similar problems with other libraries, however solutions for all of them was to move DLLs or update classpath, but as I'm using maven I suspect in this case the solution will be different.
I managed to fix my problem. The root cause of this problem, was my username - "Grześ", which contains non-standard character 'ś'. As you may see in the first line of exception info:
java.lang.UnsatisfiedLinkError: C:\Users\Grześ\AppData\Local\Temp\libNRJavaSerial_Grze?_0\libNRJavaSerial.dll: Can't find dependent libraries
The path contains question mark in place of this character. Changing my username in Windows properties fixed this issue
While trying to marshal the java object to xml i am getting below exception .
java.lang.ClassNotFoundException: org.apache.oro.text.regex.MalformedPatternException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at org.castor.xml.AbstractInternalContext.getRegExpEvaluator(AbstractInternalContext.java:325)
at org.exolab.castor.xml.validators.PatternValidator.initEvaluator(PatternValidator.java:262)
at org.exolab.castor.xml.validators.PatternValidator.validate(PatternValidator.java:200)
at org.exolab.castor.xml.validators.StringValidator.validate(StringValidator.java:302)
at org.exolab.castor.xml.validators.StringValidator.validate(StringValidator.java:340)
at org.exolab.castor.xml.FieldValidator.validateInstance(FieldValidator.java:324)
at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:271)
at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:1072)
at org.exolab.castor.xml.Validator.validate(Validator.java:135)
at org.exolab.castor.xml.Marshaller.validate(Marshaller.java:2594)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:826)
at in.mywebapp.util.XMLUnmarshaller.getStatusRequestParam(XMLUnmarshaller.java:266)
Not sure which jar is missing .
you are probably missing oro.jar. You can add maven dependency
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
</dependency>
or download the jar from maven repository
Please make sure oro jar file is in classpath. It is not there. So, class loading is failing
I am working under eclipse Luna:
Eclipse Java EE IDE for Web Developers.
Version: Luna Service Release 2 (4.4.2)
Build id: 20150219-0600
I have a project that has some unit tests and depends on other projects in my workspace as well as external dependencies resolved using maven.
The project builds ok, using as one of its dependencies
.m2/repository/asm/asm/3.1/asm-3.1.jar
The problem is that, when I try to run unit tests for the project (i.e. right mouse menu on the project's name and selecting "RunAs JUnit") it fails to run throwing the next exception:
May 27, 2015 2:06:10 PM com.sun.grizzly.http.servlet.ServletAdapter doService
SEVERE: service exception:
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79)
at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:700)
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at com.sun.grizzly.http.servlet.ServletAdapter.loadServlet(ServletAdapter.java:456)
at com.sun.grizzly.http.servlet.ServletAdapter.doService(ServletAdapter.java:395)
at com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:349)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at com.sun.grizzly.tcp.http11.GrizzlyAdapterChain.service(GrizzlyAdapterChain.java:183)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:745)
I've been reviewing the JUnit runtime classpath using this line as the first in my code:
logger.trace("Execution classpath [" + System.getProperty("java.class.path") + "]");
And I've discovered that somehow, these two dependencies are in the classpath:
.m2/repository/org/ow2/asm/asm-debug-all/4.1/asm-debug-all-4.1.jar:
.m2/repository/org/ow2/asm/asm/4.0/asm-4.0.jar:
How can I get rid of them?
I've read a lot about going to the "Run Configuration" and delete the problematic dependency from the "Classpath" tab, but in my case, the "Classpath" tab only shows the next dependencies:
Bootstrap Entries
JRE System Library [JavaSE-1.7]
User Entries
MyProblematicProject
Could anyone tell me how to get rid of this annoying dependency or at least sheer a bit of light upon how does eclipse builds the JUnit runtime classpath and what chances are to modify it?
Thank you,
Juan Fra
Most likely something in the project's pom is pulling in those dependencies, transitively. Open the pom file in Eclipse's pom editor and you can use the Dependency Hierarchy tab to investigate how you're getting both asm versions. From there you can opt to exclude one or both that you don't want/need.
E-Riz, thanks for your reply. Effectively the dependencies are transitively pulled from other projects. They are already located en we have the next lines in our pom:
<dependency>
<groupId>websays</groupId>
<artifactId>common</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-debug-all</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
</exclusions>
</dependency>
But, still having this pom config the execution classpath includes org.ow2.asm.asm and org.ow2.asm.asm-debug-all artifact.
Notice that I am always talking about the execution classpath, the build classpath works ok.
this is my first Questing here and i didn't found any solutions to my Problem.
Please don't take it amiss, if my text is broken English.
For my program I want to resize images inside an existing PDF-Document. This should happens automatically within a Java program.
During my search, I found the Ghost4j Library in the web, which can solve my problem - maybe!
As a first test with Ghost4j to tryout if it works, I want to load my PDF Document out of the MySQL Database and check out the pageCount.
Here ist my short code:
...
for (File file : convertableFiles) {
InputStream inputStream = new ByteArrayInputStream(file.getFile());
PDFDocument doc = new PDFDocument();
doc.load(inputStream);
System.out.println(doc.getPageCount());
}
...
The error comes at line 45 = doc.load(inputStream)
(Note: if I use new File(Path) for doc.load and set a pdfSample Document. It works. But not with inputStream)
When I execute my programm i'll get everytime this Excption:
Sep 29, 2014 4:54:53 PM ch.carauktion.dbresize.DBFileResizer convert
INFORMATION: P1 (asc): 0 / 1
Sep 29, 2014 4:54:54 PM ch.carauktion.dbresize.DBFileResizer run
SCHWERWIEGEND: P1 (asc): Exception
java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1OctetString
at com.lowagie.text.pdf.PdfEncryption.<init>(Unknown Source)
at com.lowagie.text.pdf.PdfReader.readDecryptedDocObj(Unknown Source)
at com.lowagie.text.pdf.PdfReader.readDocObj(Unknown Source)
at com.lowagie.text.pdf.PdfReader.readPdf(Unknown Source)
at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)
at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)
at org.ghost4j.document.PDFDocument.load(PDFDocument.java:45)
at ch.carauktion.dbresize.pdf.DBPdfResizer.convertFiles(DBPdfResizer.java:50)
at ch.carauktion.dbresize.DBFileResizer.convert(DBFileResizer.java:114)
at ch.carauktion.dbresize.DBFileResizer.run(DBFileResizer.java:59)
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.asn1.ASN1OctetString
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 10 more
For this Project implements Libraries, which all comes from the downloaded ghost4j package:
ghost4j-0.5.1
iText-2.1.7
jna-3.3.0
log4j-1.2.15
commons-logging-1.1.1
commons-io-1.3.1
commons-beanutils-1.8.3
Example Sites at my search for this Error:
http://sourceforge.net/p/itext/mailman/itext-questions/thread/4F422974.1070002#redlab.be/
http://itext-general.2136553.n4.nabble.com/java-lang-NoClassDefFoundError-org-bouncycastle-asn1-ASN1OctetString-td3427288.html
I understand that iText 2.1.7 isn't supported anymore and i should use Version 5.x.x, but it doesn't work here to download the newest iText Lib, when in the Ghost4j Jar apparently the Lib 2.1.7 are used.
Otherwise, maybe its my fault and I didn't understand at this moment how to implements correctly the newest Version.
PS:
I'am using Java 1.7, Eclipse Kepler, Windows 8.1
I'll be glad, someone is knowing any solutions or can help me a little bit.
Wudmaan
You are missing the Bouncycastle dependency.
I don't think a PDF library would depends on that, except if there is a need to protect the PDF, but you'll find Bouncycastle here: http://bouncycastle.org/latest_releases.html
Try with bcprov-jdk14-147.jar and/or bcprov-ext-jdk14-147.jar downloadable from Maven Central repository:
http://repo1.maven.org/maven2/org/bouncycastle/bcprov-jdk14/1.47/
http://repo1.maven.org/maven2/org/bouncycastle/bcprov-ext-jdk14/1.47/
http://repo1.maven.org/maven2/org/bouncycastle/bcmail-jdk14/1.47/
http://repo1.maven.org/maven2/org/bouncycastle/bctsp-jdk14/1.47/
If that still don't work, try with the other excluded dependencies listed here:
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
<exclusions>
<exclusion>
<artifactId>bcmail-jdk14</artifactId>
<groupId>bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>bcmail-jdk14</artifactId>
<groupId>org.bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>bcprov-jdk14</artifactId>
<groupId>bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>bcprov-jdk14</artifactId>
<groupId>org.bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>bctsp-jdk14</artifactId>
<groupId>org.bouncycastle</groupId>
</exclusion>
</exclusions>
</dependency>
Note: you should use Maven to take of those dependencies.