我有很多的東西問題,我想應該是很容易的JBoss應用程序內調用外部JAX-RS服務: 從我J2E Web應用程序(無狀態會話bean),我想打電話給外部JAX-RS服務(mailgun)。 我嘗試整合澤西島,但有重疊導入問題(和NoSuchMethodExceptions等)。所以我沒有進一步追求這個,而是嘗試了RestEasy,因爲我知道這是Jboss的標準JAX-RS庫。麻煩從
但是,我也遇到了問題。
能否請你點我調用這些服務的正確路徑?我使用任何圖書館非常開放,因此,如果有這樣的「集結在」的方式,我很高興地放手我在這裏的依賴地獄......我目前的問題
詳情:
一旦我調用該行從我StatelessSessionBean:
Client client = ClientBuilder.newClient();
Response res = client.target("https://api.mailgun.net/v2/samples.mailgun.org" + "/messages").request(MediaType.APPLICATION_FORM_URLENCODED_TYPE).get();
已經是第一生產線生產的例外:
JBAS014134: EJB Invocation failed on component EmailService for method public void de.wohnungsheld.weimea.service.EmailService.hasso(): javax.ejb.EJBException: Unexpected Error
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:163) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
...
Caused by: java.lang.NoClassDefFoundError: javax/ws/rs/client/ClientBuilder
我打了很多與我的Maven依賴。 當前版本的參考(其中包括)
jboss-jaxrs-api_1.1_spec
和
org.jboss.resteasy, version 3.0.8.Final
我認爲org.jboss.resteasy別的東西在這裏發生碰撞......
完全依賴部分看起來像這:
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the EJB API, we use provided scope as the API is included in
JBoss AS 7 -->
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<!-- JSR-303 (Bean Validation) Implementation -->
<!-- Provides portable constraints such as @Email -->
<!-- Hibernate Validator is shipped in JBoss AS 7 -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Import the JSF API, we use provided scope as the API is included in
JBoss AS 7 -->
<dependency>
<groupId>org.jboss.spec.javax.faces</groupId>
<artifactId>jboss-jsf-api_2.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<!-- Now we declare any tools needed -->
<!-- Annotation processor to generate the JPA 2.0 metamodel classes for
typesafe criteria queries -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<scope>provided</scope>
</dependency>
<!-- Annotation processor that raising compilation errors whenever constraint
annotations are incorrectly used. -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<scope>provided</scope>
</dependency>
<!-- Needed for running tests (you may also use TestNG) -->
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- Optional, but highly recommended -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate4</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.openestate.is24</groupId>
<artifactId>ALL</artifactId>
<version>0.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.picketlink</groupId>
<artifactId>picketlink</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.0.0.CR1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.8.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
依賴管理看起來像這樣:
<dependencyManagement>
<dependencies>
<groupId>org.jboss.bom</groupId>
<artifactId>jboss-javaee-6.0-with-tools</artifactId>
<version>${version.jboss.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.bom</groupId>
<artifactId>jboss-javaee-6.0-with-hibernate</artifactId>
<version>${version.jboss.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.picketlink</groupId>
<artifactId>picketlink-javaee-6.0</artifactId>
<version>${version.picketlink.javaee.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
我正在運行JBoss AS 7.1。
非常感謝提前!
PS:我從我的應用程序,它工作正常暴露出了很多的JAX-RS服務。