I'm trying to run the sample project with this library and I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/lang3/StringUtils
at com.github.devnied.emvnfccard.enums.EmvCardScheme.<init>(EmvCardScheme.java:97)
at com.github.devnied.emvnfccard.enums.EmvCardScheme.<clinit>(EmvCardScheme.java:32)
at com.github.devnied.emvnfccard.parser.EmvParser.readWithAID(EmvParser.java:277)
at com.github.devnied.emvnfccard.parser.EmvParser.readEmvCard(EmvParser.java:120)
at com.github.devnied.emvpcsccard.Main.main(Main.java:64)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
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)
... 5 more
I've added commons-lang-2.6.jar & commons-lang3-3.1-sources.jar in libs and classpath
Main class:
public static void main(final String[] args) throws CardException {
Main pcsc = new Main();
CardTerminal ct = pcsc.selectCardTerminal();
Card c = null;
if (ct != null) {
c = pcsc.establishConnection(ct);
CardChannel channel = c.getBasicChannel();
PcscProvider provider = new PcscProvider(channel);
EmvParser parser = new EmvParser(provider, false);
parser.readEmvCard();
c.disconnect(false);
}
}
I have referred to the following links:
java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader
Struts 2 framework demo
http://apache-commons.680414.n4.nabble.com/lang-java-lang-NoClassDefFoundError-org-apache-commons-lang-StringUtils-Exception-td3735881.html
I have added commons-lang-2.6.jar & commons-lang3-3.1-sources.jar...
Here's your problem: commons-lang-2.6.jar doesn't contain the org.apache.commons.lang3 package, since that's part of version 3, and commons-lang3-3.1-sources.jar contains the source code, not the byte code.
You need to include commons-lang3-3.1.jar instead.
If you're using Maven, put this inside your pom.xml file:
Maven Central Repository for Commons Lang:
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
Maven Central Repository for Apache Commons Lang:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12</version>
</dependency>
Don't forget: Update Maven Project
Apache Commons Lang ™ Dependency Information
Last Published: 2 March 2021 | Version: 3.12
Apache Maven
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12</version>
</dependency>
Apache Buildr
'org.apache.commons:commons-lang3:jar:3.12'
Apache Ivy
<dependency org="org.apache.commons" name="commons-lang3" rev="3.12">
<artifact name="commons-lang3" type="jar" />
</dependency>
Groovy Grape
#Grapes(
#Grab(group='org.apache.commons', module='commons-lang3', version='3.12')
)
Gradle/Grails
compile 'org.apache.commons:commons-lang3:3.12'
Scala SBT
libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.12"
Leiningen
[org.apache.commons/commons-lang3 "3.12"]
Reference:
https://commons.apache.org/proper/commons-lang/dependency-info.html
Yo adding the below and update maven project worked like a charm:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
Adding below worked for me:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
When everything else is correct, rarely jar file gets corrupted. Ensure you don't see error something like below while compiling
[ERROR] error reading
C:\Users\Mohan\.m2\repository\org\apache\commons\commons-lang3\3.7\commons-lang3-3.7.jar;
ZipFile invalid LOC header (bad signature)
I was having this issue in IJ version 2016 after updating it to 2018.3.4 and clicking "Generate sources and update folders for all projects" at Maven options tab the issue went away
Related
I need to convert a docx to a PDF and I am going with Apache POI. This is my POM:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>org.apache.poi.xwpf.converter.pdf</artifactId>
<version>1.0.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
For some reason, I am getting an exception during when the conversion is running:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/poi/POIXMLDocumentPart at
org.apache.poi.xwpf.converter.core.styles.XWPFStylesDocument.getFontsDocument(XWPFStylesDocument.java:1477)
at
org.apache.poi.xwpf.converter.core.styles.XWPFStylesDocument.(XWPFStylesDocument.java:190)
at
org.apache.poi.xwpf.converter.core.styles.XWPFStylesDocument.(XWPFStylesDocument.java:184)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.createStylesDocument(XWPFDocumentVisitor.java:166)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.(XWPFDocumentVisitor.java:159)
at
org.apache.poi.xwpf.converter.pdf.internal.PdfMapper.(PdfMapper.java:149)
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:55)
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:38)
at
org.apache.poi.xwpf.converter.core.AbstractXWPFConverter.convert(AbstractXWPFConverter.java:45)
at temp.main.Teste(main.java:30) at temp.main.main(main.java:18)
Caused by: java.lang.ClassNotFoundException:
org.apache.poi.POIXMLDocumentPart 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) ... 11 more
I googled trying to find what is the dependency I missing, at least I think that's the case, but I can't find information about POIXMLDocumentPart that is able to fix my issue.
This is the method i am using to convert the docx:
public static void Teste(File file, String destino) {
try {
InputStream doc = new FileInputStream(file);
XWPFDocument document = new XWPFDocument(doc);
PdfOptions options = PdfOptions.create();
OutputStream out = new FileOutputStream(new File(destino));
PdfConverter.getInstance().convert(document, out, options);
new File(destino);
} catch(Exception e) {
}
}
XDocReport is compiled against POI 3.17.
POI 4.0.0 has some changes and XDocReport will not work with POI 4.0.0.
POIXMLDocumentPart moved to the package org.apache.poi.ooxml.
See https://github.com/opensagres/xdocreport/pull/324
Update (March 2019): Looks XDocReport 2.0.2 has been updated to use POI 4.0.1.
I had got similar issue, but I have got "two step" script.
1. Create docx from docx template document (replace placeholders with values)
2. Generate PDF from created docx
Problem which I faced is collisions between some libraries which are using by both methods. When I have upgraded poi-ooxml library version -> PDF generator throwed no class found java.lang.NoClassDefFoundError: org/apache/poi/POIXMLDocumentPart and if versions were older, than docx generator failed.
For me golden proportions which worked correctly together was:
'org.apache.poi', name: 'poi-ooxml', version: '3.10.1'
'fr.opensagres.xdocreport', name: 'fr.opensagres.xdocreport.converter.docx.xwpf', version: '1.0.5'
'fr.opensagres.xdocreport', name: 'fr.opensagres.xdocreport.core', version: '1.0.6'
'fr.opensagres.xdocreport', name: 'org.apache.poi.xwpf.converter.xhtml', version: '1.0.6'
Hope it will help someone. I spent on that problem couple hours.
compile group: 'fr.opensagres.xdocreport', name: 'fr.opensagres.poi.xwpf.converter.pdf', version: '2.0.2'
compile group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '4.1.2'
These two dependencies are enough to execute above example.
I have the following code:
public static final String _DRIVER_PATH = "c:\\Users\\Public\\Downloads\\chromedriver.exe";
.....
System.setProperty("webdriver.chrome.driver", Constants._DRIVER_PATH);
ChromeOptions options = new ChromeOptions();
My dependencies are:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>
Then I get on the last line:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Lists
at org.openqa.selenium.chrome.ChromeOptions.<init>(ChromeOptions.java:74)
at com.FlashMain.main(FlashMain.java:39)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Lists
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)
... 2 more
I run on Windows 10, ChromeDriver.exe version 2.29 and Chrome - 58.0.3029.110
You advise is appreciated.
It seems that you're using both selenium and other library that brings google common library with version that is not compatible with latest selenium.
Build dependency tree using:
mvn dependency:tree
Exclude old version by managing exclusions and add new one directly or simply try to update library that refers to old version of google common.
I encountered this recently using Selenium with Spring Boot, and the webdrivermanager maven plugin. The problem was that I used the latest webdrivermanager version, but relied on the selenium-java version provided by Spring Boot, which was a few versions back. If you find yourself in a similar scenario, the solution is quite easy, override the spring boot version for your Selenium dependency and make sure you are using consistent and appropriate versions!
Use Selenium version 2.x , Selenium 3.0 chromium implementation is different
I'm getting the following errors :
Caused by: javax.persistence.PersistenceException: Failed to load provider from META-INF/services
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:115)
at javax.persistence.Persistence$PersistenceUtilImpl.isLoaded(Persistence.java:278)
at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:62)
at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:94)
at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47)
at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:757)
... 96 more
Caused by: java.lang.ClassNotFoundException: me.prettyprint.hom.CassandraPersistenceProvider
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1858)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1709)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.apache.geronimo.osgi.locator.ProviderLocator.loadClass(ProviderLocator.java:195)
at org.apache.geronimo.osgi.locator.ProviderLocator.locateServiceClasses(ProviderLocator.java:524)
at org.apache.geronimo.osgi.locator.ProviderLocator.getServices(ProviderLocator.java:315)
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:108)
... 101 more
I have imported a pom dependeny in my project, the new pom dependeny inturn has some cassandra related dependeny shown below :
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-mapping</artifactId>
<version>3.0.0</version>
</dependency>
The cassandra project works good in stand alone. Can someone help me with this
Your project is complaining ClassNotFoundException:me.prettyprint.hom.CassandraPersistenceProvider which belongs to Cassandra hector client.
I am guessing your project was using hector core which is no longer active hector client github page. You have to migrate all dependencies to datastax's cassandra drivers and remove all hector-client related dependencies. check it here
I'm getting the following error when trying to compile my project:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/util/URIUtil
at org.apache.commons.vfs2.provider.URLFileName.getPathQueryEncoded(URLFileName.java:91)
at org.apache.commons.vfs2.provider.URLFileName.getURIEncoded(URLFileName.java:161)
at org.apache.commons.vfs2.provider.url.UrlFileObject.createURL(UrlFileObject.java:74)
at org.apache.commons.vfs2.provider.url.UrlFileObject.doAttach(UrlFileObject.java:63)
at org.apache.commons.vfs2.provider.AbstractFileObject.attach(AbstractFileObject.java:1505)
at org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:489)
.... (More project-scope traces)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.util.URIUtil
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
I have the following maven dependencies in my project, among others:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2</artifactId>
<version>2.0</version>
</dependency>
I absolutely must depend on a HttpClient version 4.3.4 or greater because of other dependencies and various bugs we ran into with previous versions. After a bit of research, I discovered the class in question (URLUtil) was removed from HttpClient after HttpClient 3.1.
Is there any way to resolve this? Or another library I could use instead of vfs2? I'm attempting to write files over sftp using both user/pass and key authentication schemes.
As it turns out, the artifacts are different between the 3.x and 4.x releases of HttpClient. All I had to do was include:
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
Silly me, thinking that they'd override each-other.
I am getting this weird exception on this line:
HttpSolrServer server = new HttpSolrServer("http://localhost:8080/solr/");
Stack trace:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpRequestInterceptor
at com.polgar.dipl.index.SolrIndex.init(SolrIndex.java:36)
at com.polgar.dipl.index.SolrIndex.getInstance(SolrIndex.java:30)
at com.polgar.dipl.main.ArticleIndexer.main(ArticleIndexer.java:44)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpRequestInterceptor
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)
... 3 more
Getting the same problem. We both must be playing with Solr 3.6
I had to download the HttpClient jars from the HttpComponents project. They didn't seem to be included with Solr 3.6
http://hc.apache.org/downloads.cgi
3.6 Has a new version of the client that uses the new HttpComponents (4.0) stuff, not the old HttpClient (3.1) stuff. The old 3.1 jar is there, but not the new one.
Once I copied the jars over, it worked.
I copied the following (not all may be needed).
httpclient-4.1.3.jar
httpclient-cache-4.1.3.jar
httpcore-4.1.4.jar
httpmime-4.1.3.jar
works for me, now.
If you are using Maven to include SOLRJ, you'll also want the following phrases in your POM:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.1</version>
</dependency>
Looks like you are missing the HttpClient Jar file in your runtime classpath.
I was also facing this issue. To resolve this, I have done following:
Checked the versions available of http components in your "~.m2\repository\org\apache\httpcomponents" directory
Based on that add following entries in your pom.xml file and rebuild your project by running mvn clean install and mvn eclipse:eclipse command one by one.
(If you are behind the proxy, make sure you have provided essential configuration in your settings.xml file)
This should resolve the problem, It did for me. :)
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.3</version>
</dependency>