java - ClassNotFoundException with ResteasyClientBuilder (JBOSS) -


similar questions have been posted here , here former proposes solutions nosuchmethoderror , latter doesn't mention resteasyclientbuilder, precisely causes error whenever try call get method client.

i'm using wildfly, maven, resteasy/jboss. can run wildfly server using standalone in command prompt, , use maven deploy war file wildfly server, , use get methods in browser/postman receive results. if try call exact same get method within client code, error below. caused resteasyclientbuilder.

what wrong? have minimal dependencies , plugins in pom , server code works, client not. pom uses versions "3.0.19.final" because that's jar version resteasy-jaxrs-3.0.19.final.jar in c:\users\me\documents\wildfly\wildfly-10.1.0.final\modules\system\layers\base\org\jboss\resteasy\resteasy-jaxrs\main

error:

exception in thread "main" java.lang.noclassdeffounderror: org/jboss/resteasy/client/jaxrs/resteasyclientbuilder     @ com.sample.clientdemo.main(clientdemo.java:21)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:498)     @ com.intellij.rt.execution.application.appmain.main(appmain.java:140) caused by: java.lang.classnotfoundexception: org.jboss.resteasy.client.jaxrs.resteasyclientbuilder     @ java.net.urlclassloader.findclass(urlclassloader.java:381)     @ java.lang.classloader.loadclass(classloader.java:424)     @ sun.misc.launcher$appclassloader.loadclass(launcher.java:331)     @ java.lang.classloader.loadclass(classloader.java:357)     ... 6 more 

pom.xml

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">     <modelversion>4.0.0</modelversion>      <groupid>com.sample</groupid>     <artifactid>rest-demo</artifactid>     <version>1.0.snapshot</version>     <packaging>war</packaging>     <name>rest-demo</name>      <properties>         <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>         <project.build.sourceencoding>utf-8</project.build.sourceencoding>     </properties>     <dependencies>         <dependency>             <groupid>org.jboss.resteasy</groupid>             <artifactid>resteasy-client</artifactid>             <version>3.0.19.final</version>             <scope>provided</scope>         </dependency>         <dependency>             <groupid>org.jboss.resteasy</groupid>             <artifactid>resteasy-jaxrs</artifactid>             <version>3.0.19.final</version>             <scope>provided</scope>         </dependency>      </dependencies>      <build>         <plugins>             <plugin>                 <groupid>org.apache.maven.plugins</groupid>                 <artifactid>maven-compiler-plugin</artifactid>                 <version>3.1</version>                 <configuration>                     <source>1.8</source>                     <target>1.8</target>                     <compilerarguments>                         <endorseddirs>${endorsed.dir}</endorseddirs>                     </compilerarguments>                 </configuration>             </plugin>             <plugin>                 <groupid>org.apache.maven.plugins</groupid>                 <artifactid>maven-war-plugin</artifactid>                 <version>2.3</version>                 <configuration>                     <failonmissingwebxml>false</failonmissingwebxml>                 </configuration>             </plugin>              <plugin>                 <groupid>org.wildfly.plugins</groupid>                 <artifactid>wildfly-maven-plugin</artifactid>                 <version>1.1.0.alpha11</version>                 <configuration>                     <name>rest-demo.war</name>                 </configuration>             </plugin>          </plugins>     </build>  </project> 

server code (helloworld.java)

import javax.ws.rs.*;  @path("tutorial") public class helloworld {     @get     @path("helloname/{name}")     public string hello(@pathparam("name") final string name) {         return "hello " +name;     }  } 

client code (clientdemo.java)

import org.jboss.resteasy.client.jaxrs.resteasyclient; import org.jboss.resteasy.client.jaxrs.resteasyclientbuilder; import org.jboss.resteasy.client.jaxrs.resteasywebtarget;  import javax.ws.rs.core.response; public class clientdemo {      public static void main(string[] args) {         resteasyclient client = new resteasyclientbuilder().build();  // <-- error occurs here         resteasywebtarget target = client.target("http://localhost:8080/rest-demo/rest/tutorial/helloname/john");         response response = target.request().get();         string value = response.readentity(string.class);         response.close();     } } 

edit configurations in intellij

the error remains after explicilty referencing client jar. wrong?

enter image description here

you need divided maven project on 2 parts. 1 client demo. war. in war's pom add dependency on org.jboss.resteasy:jaxrs-api , make provided. in client pom add dependency on org.jboss.resteasy:resteasy-client without provided (maven exec plugin don't include provided dependency in classpath) put reasteasy demo projects on github (server, client). test additional funciton , need more dependency in case. client can work through mvn exec:exec


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -