2016-02-09 32 views
1

我對我的pom.xml文件有麻煩。我知道,關於這個問題有很多話題,但是他們中的任何一個都能解決我的問題。AbstractMethodError:REST中的javax.ws.rs.core.UriBuilder.uri,EJB應用程序

@Path("/actors") 
public class MainController { 

    @EJB 
    private ActorDaoLocal actorDao; 

} 

@Local 
public interface ActorDaoLocal { 
    //some stuff here 
} 

@Stateless 
public class ActorDao implements ActorDaoLocal { 

    @PersistenceContext 
    private EntityManager em ; 
    //some stuff here 
} 

@ManagedBean(name = "ActorBean") 
@ApplicationScoped 
public class ActorBean { 

    @EJB 
    private ActorDaoLocal usersDao; 

} 

在我的應用程序,當我在ActorBean沒有註解如下:

@ManagedBean(name = "ActorBean") 
@ApplicationScoped 

actorDao是空的MainController

然而,當我加入這個註解和依賴它我正在獲取例外:

java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder; 
    at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119) 
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:651) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 

我的pom.xml

<dependency> 
    <groupId>log4j</groupId> 
    <artifactId>log4j</artifactId> 
    <version>1.2.17</version> 
    <type>jar</type> 
</dependency> 
<dependency> 
    <groupId>asm</groupId> 
    <artifactId>asm</artifactId> 
    <version>3.1</version> 
</dependency> 
<dependency> 
    <groupId>org.codehaus.jackson</groupId> 
    <artifactId>jackson-core-asl</artifactId> 
    <version>1.9.2</version> 
</dependency> 
<dependency> 
    <groupId>org.codehaus.jackson</groupId> 
    <artifactId>jackson-jaxrs</artifactId> 
    <version>1.9.2</version> 
</dependency> 
<dependency> 
    <groupId>org.codehaus.jackson</groupId> 
    <artifactId>jackson-mapper-asl</artifactId> 
    <version>1.9.2</version> 
</dependency> 
<dependency> 
    <groupId>org.codehaus.jackson</groupId> 
    <artifactId>jackson-xc</artifactId> 
    <version>1.9.2</version> 
</dependency> 
<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-client</artifactId> 
    <version>1.18</version> 
</dependency> 
<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-core</artifactId> 
    <version>1.18</version> 
</dependency> 
<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-json</artifactId> 
    <version>1.18</version> 
</dependency> 
<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-server</artifactId> 
    <version>1.18</version> 
</dependency> 
<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-servlet</artifactId> 
    <version>1.18</version> 
</dependency> 
<dependency> 
    <groupId>javax.ws.rs</groupId> 
    <artifactId>jsr311-api</artifactId> 
    <version>1.1.1</version> 
</dependency> 
<dependency> 
    <groupId>javax.ejb</groupId> 
    <artifactId>ejb-api</artifactId> 
    <version>3.0</version> 
</dependency> 
<dependency> 
    <groupId>org.eclipse.persistence</groupId> 
    <artifactId>eclipselink</artifactId> 
    <version>2.5.2</version> 
</dependency> 
<dependency> 
    <groupId>javax</groupId> 
    <artifactId>javaee-api</artifactId> 
    <version>7.0</version> 
    <type>jar</type> 
</dependency> 

請幫我解決這個問題,我在我的pom文件中找不到錯誤。

我在Tomcat的8

+0

我已經試過該帖子的提示 – Araneo

回答

2

你在你的類路徑中包含javax.ws.rs.core.UriBuilder兩個JAX-RS 1.1的多依賴的工作:

<dependency> 
    <groupId>javax.ws.rs</groupId> 
    <artifactId>jsr311-api</artifactId> 
    <version>1.1.1</version> 
</dependency> 

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-core</artifactId> 
    <version>1.18</version> 
</dependency> 

而且JAX-之一RS 2.0:

<dependency> 
    <groupId>javax</groupId> 
    <artifactId>javaee-api</artifactId> 
    <version>7.0</version> 
</dependency> 

由於JAX-RS 2.0是從Java EE 7,可能需要降級javaee-api至6版本,使用這樣的:

<dependency> 
    <groupId>javax</groupId> 
    <artifactId>javaee-api</artifactId> 
    <version>6.0</version> 
</dependency> 

另一種方法是升級澤西版本,像這樣的回答:AbstractMethodError using UriBuilder on JAX-RS

在運行時UriBuilder#uri(String)被調用,所以您需要驗證servlet容器中的依賴關係。

+0

謝謝,這有助於:) – Araneo