I know this has been discussed a lot, but somehow none of the previously asked questions is applicable to my case.
When loading my application I get the following stacktrace:
Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2663)
at java.lang.Class.getConstructor0(Class.java:3067)
at java.lang.Class.newInstance(Class.java:408)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:923)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:967)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2701)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2521)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2435)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2403)
at de.festo.rs.windows.FXApplStarter$1.run(FXApplStarter.java:29)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$55/29905907.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$54/20965065.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$46/6575340.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataAccessException
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)
... 24 more
In most of the threads I read concerning similar errors people were indeed missing the spring-tx jar which I definately don´t.
It is declared in my maven dependencies along with the other spring jars neededd like this:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
When investigating my deployed output the jars are there as well.
Nevertheless the mentioned error is thrown. I am really desperate with this.
Please note, that the application is not a WebApp but kind of a standalone application loaded from another program.
Funny thing is that my colleague can´t reproduce the error. For that reason I guess it´s some kind of race condition between my JavaFX loader loading the result of the spring-jdbc query into its datamodel. I don´t have any proof for this, it´s just kind of a gut instinct.
Any help or tipp would be really appreciated.
If further information is needed please let me know.
Class : org.springframework.dao.DataAccessException is defined in Spring-DAO. Check if have below dependency.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-dao</artifactId>
<version>2.0.8</version>
</dependency>
to fix this issue i have just moved the application.java under the base package like i have created groupid demo.test.activemq and created the same package name in src folder and then restarted. it works for me.
Another posibility is, that you hide some dependencies through a scope like test:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<scope>test</scope>
</dependency>
Just remove the scope (or set the default: compile)
Related
I am trying to set up Hibernate in my project to enable ORM-based storage in my database.
Right now I am simply trying to load a configuration in Hibernate to open a session. I figured that this would be an easy test to see if everything worked, after which I could start on the more daunting tasks of actually mapping my classes.
But I didn't realise that just getting to load Hibernate would already be a process that I'd get stuck on for over a day.
Yesterday I couldn't get past an issue with loading the .cfg.xml files. I would continously run into this error:
[15:40:41 ERROR]: [org.bukkit.craftbukkit.v1_19_R1.CraftServer] Unable to perform unmarshalling at line number 0 and column 0 in RESOURCE test.cfg.xml. Message: null initializing LiberCore v0.3 (Is it up to date?)
org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 0 and column 0 in RESOURCE test.cfg.xml. Message: null
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:134) ~[?:?]
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:66) ~[?:?]
at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57) ~[?:?]
at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:254) ~[?:?]
at org.hibernate.cfg.Configuration.configure(Configuration.java:260) ~[?:?]
at net.libercraft.data.database.HibernateManager.<init>(HibernateManager.java:29) ~[?:?]
at net.libercraft.data.DataManager.initializeDatabase(DataManager.java:17) ~[?:?]
at net.libercraft.main.Main.onLoad(Main.java:34) ~[?:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.loadPlugins(CraftServer.java:460) ~[purpur-1.19.2.jar:git-Purpur-1765]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:314) ~[purpur-1.19.2.jar:git-Purpur-1765]
at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:1142) ~[purpur-1.19.2.jar:git-Purpur-1765]
at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:310) ~[purpur-1.19.2.jar:git-Purpur-1765]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:278) ~[?:?]
at javax.xml.bind.ContextFinder.find(ContextFinder.java:421) ~[?:?]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721) ~[?:?]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662) ~[?:?]
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:123) ~[?:?]
... 12 more
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:445) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:587) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122) ~[?:?]
at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155) ~[?:?]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:276) ~[?:?]
at javax.xml.bind.ContextFinder.find(ContextFinder.java:421) ~[?:?]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721) ~[?:?]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662) ~[?:?]
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:123) ~[?:?]
... 12 more
Googling + reading other posts first just pointed me to a bunch of libraries to add because JAXB was no longer included with java by default. So I tried adding the following (different posts pointed to different libraries which made it pretty confusing..):
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>6.0.4.Final</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.25.0-GA</version>
</dependency>
This didn't change much as I just kept getting the same error.
After a bit of googling, I found something that explained about a jaxb.properties file that I could use to change the package pointing to com.sun.xml.internal.bind.v2.ContextFactory to a package that should be included. This worked for some time, at which point I just got errors that it couldn't find my cfg.xml files. When I tried placing those at a different location in my .jar, I went back to the error above however.
I also read about using a hibernate.properties file instead of using xml. However, I want to include different config files in my jar and select one based on the environment that my application is running in. For that reason I don't want to try just a simple hibernate.properties file, since that won't really allow me to customize it.
Today I decided to take a different route. Instead of providing the configuration via the xml file, I would just enter the configuration programmatically. This has solved the previous error of not being able to process the xml files.
But now I am getting new errors that I am unable to solve.
[09:22:53 ERROR]: [org.bukkit.craftbukkit.v1_19_R1.CraftServer] com/fasterxml/classmate/TypeResolver initializing LiberCore v0.3 (Is it up to date?)
java.lang.NoClassDefFoundError: com/fasterxml/classmate/TypeResolver
at org.hibernate.boot.internal.ClassmateContext.<init>(ClassmateContext.java:16) ~[?:?]
at org.hibernate.boot.internal.BootstrapContextImpl.<init>(BootstrapContextImpl.java:81) ~[?:?]
at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:124) ~[?:?]
at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:158) ~[?:?]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:673) ~[?:?]
at net.libercraft.data.database.HibernateManager.<init>(HibernateManager.java:50) ~[?:?]
at net.libercraft.data.DataManager.initializeDatabase(DataManager.java:17) ~[?:?]
at net.libercraft.main.Main.onLoad(Main.java:34) ~[?:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.loadPlugins(CraftServer.java:460) ~[purpur-1.19.2.jar:git-Purpur-1765]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:314) ~[purpur-1.19.2.jar:git-Purpur-1765]
at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:1142) ~[purpur-1.19.2.jar:git-Purpur-1765]
at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:310) ~[purpur-1.19.2.jar:git-Purpur-1765]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassNotFoundException: com.fasterxml.classmate.TypeResolver
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:153) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:105) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
... 13 more
After googling I found a few posts that give some solutions:
How to resolve java.lang.NoClassDefFoundError: com/fasterxml/classmate/TypeResolver while running spring boot app
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.JavaType not found
but these are not much help to me.
I tried adding the hibernate-validator library (multiple versions) but it didn't solve the error. I wouldn't know how I could swap the com.fasterxml.jackson with org.codehaus.jackson packages or even if there are org.codehaus.jackson being used in my project.
I feel like I'm doing something essentially wrong. Because in between these errors that I just can't solve, I am getting a lot more ClassNotFoundException etc. that require me to just import more maven libraries to fix them. Isn't that something that Maven should take care of by itself? Like, shouldn't it automatically load any dependant libraries for the libraries that I add to my pom.xml? Why is it requiring me to add all of those manually before my software will work.
None of the tutorial videos on youtube talk about that process, they simply tell you to add the single maven dependancy for hibernate itself. No extra libraries required. So it seems odd to me that I'm being led in that direction by these errors.
It is quite essential for me to implement an ORM solution to my project, and I'm bummed out it's going this way for me. I heard Hibernate was the best solution for this, but maybe there's different solutions for me to try out?
For some context: I'm working on a plugin for the game minecraft and the database will be used to store data about players and other game features.
Bear in mind that if you are on a recent platform 'javax' libraries may have moved to the package 'jakarta'. Try searching in your IDE/classpath what the actual implementations are! I have been successful with this.
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.0</version>
</dependency>
I am facing the following issue while running my automation. This is what I am getting on the console.
io.cucumber.core.exception.CucumberException: java.lang.NoClassDefFoundError: io/cucumber/messages/internal/com/google/protobuf/GeneratedMessageV3
at io.cucumber.core.plugin.PluginFactory.newInstance(PluginFactory.java:120)
at io.cucumber.core.plugin.PluginFactory.instantiate(PluginFactory.java:99)
at io.cucumber.core.plugin.PluginFactory.create(PluginFactory.java:63)
at io.cucumber.core.plugin.Plugins.createPlugins(Plugins.java:32)
at io.cucumber.core.plugin.Plugins.<init>(Plugins.java:25)
at io.cucumber.testng.TestNGCucumberRunner.<init>(TestNGCucumberRunner.java:108)
at io.cucumber.testng.AbstractTestNGCucumberTests.setUpClass(AbstractTestNGCucumberTests.java:27)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.testng.TestRunner.privateRun(TestRunner.java:794)
at org.testng.TestRunner.run(TestRunner.java:596)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
Caused by: java.lang.NoClassDefFoundError: io/cucumber/messages/internal/com/google/protobuf/GeneratedMessageV3
at com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter.(ExtentCucumberAdapter.java:91)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at io.cucumber.core.plugin.PluginFactory.newInstance(PluginFactory.java:116)
... 31 more
Caused by: java.lang.ClassNotFoundException: io.cucumber.messages.internal.com.google.protobuf.GeneratedMessageV3
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 37 more
Hi I had the same problem when cucumber 7 came out, and just today I was able to solve it, basically what I did was to update the versions of some other frameworks that might be affected by the cucumber version as well (on my pom.xml file). These are the frameworks that I use in the stable version:
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.0.8</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>klov-reporter</artifactId>
<version>5.0.8</version>
</dependency>
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extent-pdf-report</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extentreports-cucumber7-adapter</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber7-jvm</artifactId>
<version>2.17.2</version>
</dependency>
I hope this helps to solve your problem, best regards!
Ahh, this is a tricky one. From the 'PluginFactory' stacktrace, I guess its caused by this:
You have a class which contains step bindings ("Given I login" for example).
To create that class you require specflow to Inject some class into the constructor (dependancy injection). If THAT class is in another project, but the StepAssembly (see specflow.json or app.config) or project reference is not correct this can happen.
See code example (C# unfortunatly, but the point should be clear)
[Binding]
public class Test{
public Test(ThisClassNotInAssembly getMe){
getMe.SomeFunction();
}
}
Other option is that a step requires a transform (from string to MyNotDependancy class). Where again, the class is in another project and at runtime the dependancy fails.
To find out which class was loaded (and which was not, respectively), run Java in verbose mode but limited to classloading like so:
java -verbose:class ...
From that output you should be able to decide which exact class was missing. If again you are looking at GeneratedMessageV3, try to look at the source code of that class. It may be that some static initializer is throwing an exception that simply told the JVM that this class could not be loaded successfully.
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>
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.