I'm trying to write an Apache CXF JAX-WS client.
The dependencies in my pom.xml are
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-common-utilities</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-tools-common</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
where:
<cxf.version>2.4.0</cxf.version>
Unfortunately, when uses Maven uses the code generator (org.apache.cxf:cxf-codegen-plugin:${cxf.version}), it barfs:
[DEBUG] Calling wsdl2java with args: [-d, C:\projects\src\b2b_pmd\trunk\b2b_pmd\pmd-service\promotionalDocument\target\generated\src\main\java, -client, -verbose, file:/C:/projects/src/b2b_pmd/trunk/b2b_pmd/pmd-service/promotionalDocument/src/main/wsdl/test.wsdl]
Loading FrontEnd jaxws ...
Loading DataBinding jaxb ...
wsdl2java -d C:\projects\src\b2b_pmd\trunk\b2b_pmd\pmd-service\promotionalDocument\target\generated\src\main\java -client -verbose file:/C:/projects/src/b2b_pmd/trunk/b2b_pmd/pmd-service/promotionalDocument/src/main/wsdl/test.wsdl
wsdl2java - Apache CXF 2.4.0
[DEBUG]
java.lang.AbstractMethodError: org.apache.xerces.dom.ElementNSImpl.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;
at org.apache.cxf.staxutils.StaxUtils.addLocation(StaxUtils.java:1085)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:973)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:949)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:876)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:226)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186)
at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:78)
at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:69)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:84)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:61)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:171)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:138)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:290)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
at org.apache.cxf.maven_plugin.WSDL2JavaMojo.callWsdl2Java(WSDL2JavaMojo.java:586)
at org.apache.cxf.maven_plugin.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:412)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeForkedExecutions(DefaultLifecycleExecutor.java:685)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:560)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
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:585)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Is there something I'm missing?
You have an ancient version of xerces in your classpath someplace as well. Do a mvn dependency:tree and see if there are any xerces related jars that need to be removed.
i also had similiar problem but adding below to pom fix my issue as well..
groupId: xerces ,artifactId : xercesImpl, version>2.9.1
Related
java.lang.ClassNotFoundException: okhttp3.CipherSuite
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.web3j.protocol.http.HttpService.(HttpService.java:46)
at com.relay.eth.ERC20TokenUtil.(ERC20TokenUtil.java:36)
at com.relay.controller.open.APIController.getETHTokensBalance(APIController.java:398)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
Using web3j java library in a spring boot application,start the springboot project to access this,
Web3j web3j = Web3j.build(new HttpService("https://mainnet.infura.io/v3/{token}"))
And show error msg.
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.0</version>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>4.6.3</version>
<exclusions>
<exclusion>
<artifactId>okhttp</artifactId>
<groupId>com.squareup.okhttp3</groupId>
</exclusion>
</exclusions>
</dependency>
You should also add some crypto provider as a dependency to your project, just like it is stated in web3j docs:
It has five runtime dependencies:
...
Bouncy Castle (Spongy Castle on Android) for crypto
...
i changed the pom dependency version
```<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>3.6.0</version>
</dependency>
```
delete the okhttp3 dependency
and its wokrs
We are having an issue making a SOAP client call on tomcat 8 in a RedHat linux environment running openjdk version "1.8.0_201", while the same call works fine with a similar config on a Windows machine (tomcat 8, Oracle java 8) and AIX (Oracle java 8, tomcat 7).
Here is the stacktrace:
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2401)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:859)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1185)
at org.apache.cxf.ws.addressing.impl.AddressingFeatureApplier.initializeProvider(AddressingFeatureApplier.java:36)
at org.apache.cxf.ws.addressing.WSAddressingFeature.initializeProvider(WSAddressingFeature.java:46)
at org.apache.cxf.feature.AbstractFeature.initialize(AbstractFeature.java:49)
at org.apache.cxf.frontend.ClientFactoryBean.applyFeatures(ClientFactoryBean.java:112)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:100)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:157)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:476)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:343)
at javax.xml.ws.Service.getPort(Service.java:160)
Using
cxf version 2.7.18
pom.xml snippet
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.0.16</version>
</dependency>
An IncompatibleClassChangeError happens because some code was compiled against one version of an API, but at runtime an incompatible version of the API is being loaded.
(In this case, the "Implementing class" incompatibility means that a class has been declared as implements Something, but at runtime the Something turns out to be a class rather than an interface. This API change is not allowed.)
The problem is that the stacktrace you have included doesn't tell us what class the incompatibility occurs in, and what it is incompatible with. The only real clue is that CXF appears to be loading an "provider"
So what is the solution?
There is no silver bullet. You will need to do some digging to find out what the actual problem is:
Check the logs where you got the stacktrace from for other log messages that may tell you what was being loaded.
Check the versions of the various CXF JAR files on the runtime platform.
Check that you don't have different versions of the JARs in the webapp itself and in Tomcat's shared library directories.
Modify Tomcat logging configs to set up logging level for the org.apache.catalina.loader package to DEBUG. This will log the JAR file that each class is loaded from.
I was obtaining java.lang.IncompatibleClassChangeError due to importing different versions of the library and the plug-in used to generate the WSDL stubs
These dependencies made my application crash on booting
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.4.3</version>
</dependency>
Modifying the version of the plug-in used (in dependencies and in the plug-in declaration), the application boots without error and the web service is correctly deployed and can process requests.
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.3.0</version>
</dependency>
Just added PowerMock to my projects pom files so I can start mocking some static methods. I've verified all the versions are up to date, this includes Juint, Javassit, and mockito. The one line that is causing this problem is this:
#RunWith(PowerMockRunner.class)
When that line is commented out, my code runs fine through Junit, with it Junit has a heart attack, but a maven build works perfectly. Now I can get used to working with maven builds, but I would love the ability to debug my tests through Junit.
I have tried the following: cleaning eclipse, using maven installs/cleans/builds from both Terminal and Eclipse's UI, furiously pressing F5 while rocking myself in a dark corner for 2 hours. Any assistance on this problem would be greatly appreciated.
Below is the failure trace when I try to run as a junit test.
java.lang.NoSuchMethodError: javassist.CtMethod.hasAnnotation(Ljava/lang/Class;)Z
at org.powermock.core.transformers.impl.TestClassTransformer.removeTestAnnotationsForTestMethodsThatRunOnOtherClassLoader(TestClassTransformer.java:185)
at org.powermock.core.transformers.impl.TestClassTransformer.transform(TestClassTransformer.java:198)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:251)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:180)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:145)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:40)
at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:244)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.<init>(JUnit4TestSuiteChunkerImpl.java:61)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.<init>(AbstractCommonPowerMockRunner.java:32)
at org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock</artifactId>
<version>1.6.2</version>
<scope>test</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.4.GA</version>
<scope>test</scope>
</dependency>
The information you provided is not enough to find out what could be the problem. I would recommend you to run
mvn dependency:tree
It will list you all the dependencies, that you have in your project.Try to find simillar dependencies with different versions.
Another possible solution: Do you have the correct Javassist version (3.18.2) in the classpath?
So I'm using Raptor (I believe that's an in house version of Eclipse) which forces certain dependency version installs (even without a pom). Even though I only had the right versions in my pom files, Raptor was installing incompatible versions before hand, which took precedence. (at least thats what I believe was happening)
I had to do some forceful version control in my parent pom using dependency managers, and I seemed to have cleared up the issue. Though a few more problems followed with the libraries not having the correct methods. I ended up resolving those issues by finding versions of the dependencies (allowed by companies repository manager) that worked together (a lot of tinkering and seeing which versions would play nice). Because of the repository manager I was unable to download just the latest version of each dependency I needed.
If you are experiencing this problem make sure your versions are compatible, if you can get the newest version of the dependencies do that. If not, grab a beer, and start with the latest versions offered by your repository manager and start trying to find versions that work with each other.
I found the fix. I had to add
<dependency>
<groupId>com.ebay.raptor.core</groupId>
<artifactId>RaptorKernel</artifactId>
<exclusions>
<exclusion>
<artifactId>javassist</artifactId>
<groupId>javassist</groupId>
</exclusion>
</exclusions>
</dependency>
RaptorKernel could be replaced by any artifact which is bringing in the javassist different(other than 3.18.2) dependency.
I set up a Websocket Server that is supposed to run a servlet wich is created by a websocket servlet factory.
However, whenever I try to reach the websocket via my favourite browser I get
HTTP ERROR: 500
Problem accessing /test/sound. Reason:
javax.servlet.ServletException: java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.server.WebSocketServerFactory
The server console gives similar errors. Heres the complete console error message:
[13:21:26 WARN]: 2015-08-27 13:21:26.912:WARN:/test:qtp20972561-41: unavailable
java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.server.WebSocketSe
rverFactory
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)
at org.eclipse.jetty.websocket.servlet.WebSocketServletFactory$Loader.lo
ad(WebSocketServletFactory.java:63)
at org.eclipse.jetty.websocket.servlet.WebSocketServletFactory$Loader.cr
eate(WebSocketServletFactory.java:42)
at org.eclipse.jetty.websocket.servlet.WebSocketServlet.init(WebSocketSe
rvlet.java:128)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.jav
a:612)
at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java
:468)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:778
)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:587)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.jav
a:248)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java
:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPoo
l.java:620)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:540)
at java.lang.Thread.run(Unknown Source)
[13:21:26 WARN]: 2015-08-27 13:21:26.913:WARN:oejs.ServletHandler:qtp20972561-41
:
javax.servlet.ServletException: java.lang.ClassNotFoundException: org.eclipse.je
tty.websocket.server.WebSocketServerFactory
at org.eclipse.jetty.websocket.servlet.WebSocketServlet.init(WebSocketSe
rvlet.java:138)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.jav
a:612)
at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java
:468)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:778
)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:587)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.jav
a:248)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java
:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPoo
l.java:620)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:540)
at java.lang.Thread.run(Unknown Source)
Caused by:
java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.server.WebSocketSe
rverFactory
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)
at org.eclipse.jetty.websocket.servlet.WebSocketServletFactory$Loader.lo
ad(WebSocketServletFactory.java:63)
at org.eclipse.jetty.websocket.servlet.WebSocketServletFactory$Loader.cr
eate(WebSocketServletFactory.java:42)
at org.eclipse.jetty.websocket.servlet.WebSocketServlet.init(WebSocketSe
rvlet.java:128)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.jav
a:612)
at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java
:468)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:778
)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:587)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.jav
a:248)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java
:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPoo
l.java:620)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:540)
at java.lang.Thread.run(Unknown Source)
my best bet is, that I forgot something in my pom.xml since the WebSocketServletFactory class is missing, but I am not sure.
Here are the repositories and dependencies I have in the pom.xml
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>googlecode</id>
<name>jWebSocket Repository</name>
<url>http://jwebsocket.googlecode.com/svn/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.2.5.v20141112</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.2.5.v20141112</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>9.2.5.v20141112</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
</dependencies>
How can I resolve this error? If any more source is required please request it.
I finally answered my question by myself. The issue could be resolved by adding the classpaths to the missing jars in the META-INF/manifest.mf file.
Maybe I should've mentioned that I tried to run a jetty-server on a minecraft server via a bukkit plugin. Works fine now. Appearently this is the proper way to add external libaries to a bukkit plugin.
Thanks to everyone who anwered/commented.
Note: this answer assumes you are using jetty-distribution and normal
webapps (WAR) files.
No Jetty classes should be in your war file's WEB-INF/lib or
WEB-INF/classes, hence the <scope>provided</scope> setup.
With jetty-distribution 9.x be sure you have --module=websocket setup in your ${jetty.base}/start.ini
If you are writing for the jetty native websocket api, use this ...
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-api</artifactId>
<version>9.3.2.v20150730</version>
<scope>provided</scope>
</dependency>
If you are wanting servlet support for the jetty native websocket api use this ...
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-servlet</artifactId>
<version>9.3.2.v20150730</version>
<scope>provided</scope>
</dependency>
If you are wanting client support for the jetty native websocket api use this ...
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<version>9.3.2.v20150730</version>
<scope>provided</scope>
</dependency>
If you are writing against the javax.websocket.server server API, use the following (Note: this includes the javax.websocket client API as-well) ...
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
If you are writing against the javax.websocket client only API, use the following ...
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-client-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
The suggestions below are only valid for embedded-jetty use of WebSocket and javax.websocket (JSR-356) support.
If you are wanting javax.websocket.server (aka JSR-356 server) support use this ...
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>9.3.2.v20150730</version>
<scope>provided</scope>
</dependency>
If you are wanting javax.websocket (aja JSR-356 client) support use this ...
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-client-impl</artifactId>
<version>9.3.2.v20150730</version>
<scope>provided</scope>
</dependency>
And other references to websocket artifacts in your pom are useless and pointless, don't use em.
When I do a Http POST to a Datanucleus Rest resource in my local Appengine developement server, the server throws this error:
Caused by: java.lang.ClassNotFoundException: org.datanucleus.NucleusContext
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:423)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:176)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 37 more
From what it seems, using Datnuclues Rest API on appengine is not permitted by the platform?
EDIT:
Datanucleus in the pom:
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-appengine</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>3.0.0-release</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jpa</artifactId>
<version>3.0.0-release</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.0</version>
</dependency>
<!-- Required by Datanucleus REST API -->
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rest</artifactId>
<version>2.0.0-release</version>
</dependency>
<dependency>
<groupId>net.sf.flexjson</groupId>
<artifactId>flexjson</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-json</artifactId>
<version>2.0.0-release</version>
</dependency>
Here are the DN-related jars in the WEB-INF/lib folder:
datanucleus-rest-2.0.0-release.jar
datanucleus-json-2.0.0-release.jar
datanucleus-core-3.0.0-release.jar
datanucleus-appengine-2.0.0.jar
datanucleus-api-jpa-3.0.0-release.jar
EDIT:
Fixed the initial problem by using v3.0 DN dependencies.
However, now when I try to access the REST resource from the DN servlet it throws this error:
Error : An error occurred trying to instantiate an instance of the API adapter "org.datanucleus.api.jdo.JDOAdapter" (perhaps you dont have the requisite datanucleus-api-XXX jar in the CLASSPATH?) : {1}
org.datanucleus.exceptions.NucleusUserException: Error : An error occurred trying to instantiate an instance of the API adapter "org.datanucleus.api.jdo.JDOAdapter" (perhaps you dont have the requisite datanucleus-api-XXX jar in the CLASSPATH?) : {1}
So you use some version of datanucleus-api-rest (presumably 3.x) and you don't have the requisite version of datanucleus-core (also 3.x) present. That is normally what a ClassNotFoundException means