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>
Related
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
Getting the following while using Apache's commons-net library.
Caused by: java.lang.ClassNotFoundException: org.apache.commons.net.SocketFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
This class is loaded transitively by another one.
The environment is maven and commons-net has been loaded via the pom file.
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<classifier>ftp</classifier>
<version>2.0</version>
</dependency>
There is no SSL connection. Do I need to specify using java.security ?
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'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
Java developer here. I am using JAXB to create bind objects. When I attempt to create a JAXBContext like this:
JAXBContext.newInstance("com.mycompany.jaxb.pkg1:com.mycompany.jaxb.pkg2");
I get a NullPointerException:
Exception in thread "main" java.lang.NullPointerException
at com.sun.xml.bind.v2.model.impl.PropertyInfoImpl.calcXmlName(PropertyInfoImpl.java:287)
at com.sun.xml.bind.v2.model.impl.PropertyInfoImpl.calcXmlName(PropertyInfoImpl.java:260)
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl.getTypes(ElementPropertyInfoImpl.java:100)
at com.sun.xml.bind.v2.model.impl.RuntimeElementPropertyInfoImpl.getTypes(RuntimeElementPropertyInfoImpl.java:50)
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.size(ElementPropertyInfoImpl.java:42)
at java.util.AbstractList$Itr.hasNext(AbstractList.java:416)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:139)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:49)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:41)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:189)
at com.sun.xml.bind.v2.model.impl.RegistryInfoImpl.<init>(RegistryInfoImpl.java:63)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.addRegistry(ModelBuilder.java:232)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:201)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$3.run(JAXBContextImpl.java:357)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$3.run(JAXBContextImpl.java:351)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:350)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:216)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:132)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:286)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
at com.mycompany.jaxb.JAXBContextFactory.initIfNeeded(JAXBContextFactory.java:66)
Googling for the relevant keywords led me to several discussion threads saying that this is a known bug and I should upgrade to version 2.0.3. But here is my maven POM file:
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>
...as you can see, I am already beyond version 2.0.3. (And yes, I tried rolling back to the old version; it didn't help.)
Has anyone seen this for a reason OTHER than version 2.0.2 or older, or does anyone have pointers for how to go about tracking down the problem?
Okay, for the record: I found the solution.
As several threads had suggested, the source of this bug was using a version of JAXB which was older than 2.0.2. My error was that my maven POM file was being overridden by another POM file which was importing an older version of the library.
Thanks to skaffman, and everyone else who took a look.