简体   繁体   English

JBoss EAP中的Rest Client的NoClassDefFoundError

[英]NoClassDefFoundError for Rest Client in Jboss EAP

I produce EAR sample App with REST client and deploy it on my notebook (JBoss EAP 6.3.0 with standalone configuration and binded any-address for public domain). 我使用REST客户端生成EAR示例应用程序,并将其部署在我的笔记本上(具有独立配置并为公共域绑定了任意地址的JBoss EAP 6.3.0)。 Following code is responsibility for producing REST response: 以下代码负责产生REST响应:

@Stateless
@Path("/users/list")
public class ListUsersREST {

    @GET
    @Produces("text/html")
    public String getUsersList() {
        return "TEST";
    }

}

It's work fine through POSTMAM. 通过POSTMAM可以正常工作。 Probably this part of my example doesn't need any help. 我的示例的这一部分可能不需要任何帮助。

And now... I work on my second app deployed on my desktop (JBoss and configuration the same). 现在...我正在部署在桌面上的第二个应用程序(JBoss和配置相同)。 I have dependecies for JAVAEE7 API with contain JAVAX.WS.RS.* API. 我对包含JAVAX.WS.RS。* API的JAVAEE7 API有依赖性。 I'm trying to connect to this REST client and get response (like through POSTMAN): 我正在尝试连接到此REST客户端并获得响应(例如通过POSTMAN):

@Stateless
@Local(EJBTest.class)
public class EJBTestBean implements EJBTest {

    @Override
    public void getRestResponse() {
        Client client = ClientBuilder.newClient();
        WebTarget target = client.target("http://192.168.0.2:8080/demo/rest/users/list");
        Response response = target.request(MediaType.TEXT_HTML).get();

        String value = response.readEntity(String.class);
        int status = response.getStatus();
        response.close();
        client.close();
        System.out.println("REST RESPONSE: " + value);
        System.out.println("REST Status: " + status);
    }

}

...and this piece of code doesn't work. ...而这段代码不起作用。 I don't know why... 我不知道为什么

I'm getting the same Exception all the time... 我一直都在遇到同样的异常...

Caused by: java.lang.NoClassDefFoundError: javax/ws/rs/client/ClientBuilder 造成原因:java.lang.NoClassDefFoundError:javax / ws / rs / client / ClientBuilder

I was searching on google and trying many solution like 我在Google上搜索,并尝试了许多解决方案,例如

  1. adding dependecies all reasteasy jar to aplication (WEB-INF/lib) 向所有可重复使用的jar添加依赖项(WEB-INF / lib)
  2. adding reasteasy jars to ${JBOSS_HOME}/standalone/lib 向$ {JBOSS_HOME} / standalone / lib添加reasteasy罐
  3. changing standalone.xml 更改standalone.xml
  4. running jboss with standalone-full.xml configuration 使用standalone-full.xml配置运行jboss

but with no effects... Please tell me what is going on. 但没有效果...请告诉我发生了什么。 What am I doing wrong? 我究竟做错了什么?

JBoss EAP 6 is Java EE 6 and you're deploying an app that requires Java EE 7. The JAX-RS client is only in Java EE 7. This should work if you tried your deployments on WildFly . JBoss EAP 6是Java EE 6,并且您正在部署需要Java EE 7的应用程序。JAX -RS客户端仅在Java EE 7中。如果您在WildFly上尝试了部署,那么它应该可以工作。

The reason you're dependencies don't seem to work is the server will us it's own JAX-RS dependencies over your own. 您的依赖项似乎无法正常工作的原因是服务器将让我们将其作为自己的JAX-RS依赖项。 You could potentially exclude the JAX-RS subsystem from your deployment which may work. 您可能会从您的部署中排除JAX-RS子系统,这可能会起作用。 You probably wouldn't be able to use JAX-RS endpoints though, only the client. 但是,可能只有客户端才能使用JAX-RS端点。

Your best bet though is to use Java EE 7 container, which WildFly 8 is. 最好的选择是使用Java EE 7容器,即WildFly 8。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JBOSS EAP6.4中的NoClassDefFoundError - NoClassDefFoundError in JBOSS EAP6.4 JBoss 5.1.0 EAP。 随机生成java.lang.NoClassDefFoundError - JBoss 5.1.0 EAP. Randomly Occuring a java.lang.NoClassDefFoundError 使用Springboot Auth和Jboss EAP 7.1时的REST映射问题 - REST Mapping problems when using Springboot Auth and Jboss EAP 7.1 Jboss EAP 7-REST API客户端的动态SSL身份验证 - Jboss EAP 7 - Dynamic SSL authentication for REST API clients 在JBOSS EAP 6.3上部署REST Web服务时出错 - Error during deploying REST Webservice on JBOSS EAP 6.3 Jboss EAP 7.1升级中的Java RestEasy Client构建器问题 - Java RestEasy Client builder issue in Jboss EAP 7.1 upgrade JMS 客户端到 Java 中 Red Hat JBoss EAP 7.3 服务器上的 ActiveMQ - JMS client to ActiveMQ at server on Red Hat JBoss EAP 7.3 in Java java.lang.NoClassDefFoundError:无法在Jboss 5.0 EAP上初始化类org.apache.poi.POIXMLDocument - java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.POIXMLDocument on Jboss 5.0 EAP java.lang.NoClassDefFoundError:无法初始化类javax.imageio.ImageIO jboss EAP 6 - java.lang.NoClassDefFoundError: Could not initialize class javax.imageio.ImageIO jboss EAP 6 Japss补丁升级到7.0。,5 | java.lang.NoClassDefFoundError:com / sun / net / ssl / internal / ssl / Provider - Jboss patch to eap 7.0.,5 | java.lang.NoClassDefFoundError: com/sun/net/ssl/internal/ssl/Provider
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM