Spring ERROR - 上下文初始化失败:org.springframework.beans.factory.BeanCreationException

时间:2016-02-25 00:46:35

标签: java spring rest maven cxf

我正在JBOSS EAP 6.1中开发和部署RESTful服务。对于此任务,我使用的是Spring和CXF框架。我认为源代码是正确的,所以问题可能出在spring配置文件中。

这是资源类

package demo.restful;

//JAX-RS Imports
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;

/*
 * CategoryService class - Add/Removes category for books 
 */

@Path("/categoryservice")
@Produces({"application/json","application/xml"})
public class CategoryService {

    private CategoryDAO categoryDAO = new CategoryDAO();

    public CategoryDAO getCategoryDAO() {
        return categoryDAO;
    }

    public void setCategoryDAO(CategoryDAO categoryDAO) {
        this.categoryDAO = categoryDAO;
    }

    @GET
    @Path("/category/{id}")
    @Produces({"application/json","application/xml"})
    public Category getCategory(@PathParam("id") String id) {

        System.out.println("getCategory called with category id: " + id);

        Category cat = (Category) getCategoryDAO().getCategory(id);
        if (cat == null) {
            ResponseBuilder builder = Response.status(Status.BAD_REQUEST);
            builder.type("application/xml");
            builder.entity("<error>Category Not Found</error>");
            throw new WebApplicationException(builder.build());
        } else {
            return cat;
        }
    }

    @POST
    @Path("/category")
    @Consumes({"application/json","application/xml"})
    public Response addCategory(Category category) {

        System.out.println("addCategory called");

        Category cat = (Category) getCategoryDAO().getCategory(
                category.getCategoryId());

        if (cat != null) {
            return Response.status(Status.BAD_REQUEST).build();
        } else {
            getCategoryDAO().addCategory(category);
            return Response.ok(category).build();
        }

    }

    @DELETE
    @Path("/category/{id}")
    @Consumes({"application/json","application/xml"})
    public Response deleteCategory(@PathParam("id") String id) {

        System.out.println("deleteCategory with category id : " + id);

        Category cat = (Category) getCategoryDAO().getCategory(id);
        if (cat == null) {
            return Response.status(Status.BAD_REQUEST).build();
        } else {
            getCategoryDAO().deleteCategory(id);
            return Response.ok().build();
        }
    }

    @PUT
    @Path("/category")
    @Consumes({"application/json","application/xml"})
    public Response updateCategory(Category category) {

        System.out.println("updateCategory with category id : "
                + category.getCategoryId());

        Category cat = (Category) getCategoryDAO().getCategory(
                category.getCategoryId());
        if (cat == null) {
            return Response.status(Status.BAD_REQUEST).build();
        } else {
            getCategoryDAO().updateCategory(category);
            return Response.ok(category).build();
        }
    }

    @POST
    @Path("/category/book")
    @Consumes({"application/json","application/xml"})
    public Response addBooks(Category category) {

        System.out.println("addBooks with category id : "
                + category.getCategoryId());

        Category cat = (Category) getCategoryDAO().getCategory(
                category.getCategoryId());
        if (cat == null) {
            return Response.status(Status.NOT_FOUND).build();
        } else {
            getCategoryDAO().addBook(category);
            return Response.ok(category).build();
        }
    }

    @GET
    @Path("/category/{id}/books")
    @Consumes("application/xml,application/json")
    public Response getBooks(@PathParam("id") String id) {

        System.out.println("getBooks called with category id : " + id);

        Category cat = (Category) getCategoryDAO().getCategory(id);

        if (cat == null) {
            return Response.status(Status.NOT_FOUND).build();
        } else {
            cat.setBooks(getCategoryDAO().getBooks(id));
            return Response.ok(cat).build();

        }
    }

}

DAO:

package demo.restful;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/*
 * DataAcess object for performing CRUD operations.
 * Dummy implementation.
 */
public class CategoryDAO {

    private static Map<String, Category> categoryMap = new HashMap<String, Category>();
    private static Map<String, Collection<Book>> bookMap = new HashMap<String, Collection<Book>>();

    static {

        Category category1 = new Category();
        category1.setCategoryId("001");
        category1.setCategoryName("Java");
        categoryMap.put(category1.getCategoryId(), category1);

        Book book1 = new Book();
        book1.setAuthor("Naveen Balani");
        book1.setBookName("Spring Series");
        book1.setBookId("001");
        book1.setBookISBNnumber("ISB001");

        Book book2 = new Book();
        book2.setAuthor("Rajeev Hathi");
        book2.setBookName("CXF Series");
        book2.setBookId("002");
        book2.setBookISBNnumber("ISB002");

        Collection<Book> booksList = new ArrayList<Book>();
        booksList.add(book1);
        booksList.add(book2);

        bookMap.put(category1.getCategoryId(), booksList);
    }

    public void addCategory(Category category) {
        categoryMap.put(category.getCategoryId(), category);

    }

    public void addBook(Category category) {
        bookMap.put(category.getCategoryId(), category.getBooks());

    }

    public Collection<Book> getBooks(String categoryId) {
        return bookMap.get(categoryId);

    }

    public Category getCategory(String id) {
        Category cat = null;
        //Dummy implementation to return a new copy of category to 
      //avoid getting overridden by service
        if(categoryMap.get(id) != null) {
        cat = new Category();
        cat.setCategoryId(categoryMap.get(id).getCategoryId());
        cat.setCategoryName(categoryMap.get(id).getCategoryName());
        }
        return cat;
    }

    public void deleteCategory(String id) {
        categoryMap.remove(id);
        // Remove association of books
        bookMap.remove(id);
    }

    public void updateCategory(Category category) {
        categoryMap.put(category.getCategoryId(), category);

    }

}

Bean定义(restapp.xml):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    <bean id="categoryService" class="demo.restful.CategoryService">
        <property name="categoryDAO">
            <ref bean="categoryDAO" />
        </property>
    </bean>
    <bean id="categoryDAO" class="demo.restful.CategoryDAO">
        <!--  wire dependency-->
    </bean> 
</beans>

RESTful服务的spring配置文件(beans.xml)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:jaxrs="http://cxf.apache.org/jaxrs"
  xmlns:cxf="http://cxf.apache.org/core"
  xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
  <import resource="classpath:META-INF/cxf/cxf.xml" />
  <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
  <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
 <jaxrs:server id="categoryRESTService" address="/">
    <jaxrs:features>
     <cxf:logging/>
</jaxrs:features>
<jaxrs:serviceBeans>
      <ref bean="categoryService" />
    </jaxrs:serviceBeans>
  </jaxrs:server>
</beans>

的web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
        WEB-INF/beans.xml
        classpath:demo/restful/restapp.xml
        </param-value>
    </context-param>
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <servlet>
        <servlet-name>CXFServlet</servlet-name>
        <servlet-class>
            org.apache.cxf.transport.servlet.CXFServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

的pom.xml

<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>restapp</groupId>
  <artifactId>restapp</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
<properties>
        <!-- Version of CXF. Change this to latets version for building against latest CXF distribution -->
        <cxf.version>2.2.3</cxf.version>
    </properties>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>  
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
    </plugins>
  </build>
    <dependencies>
        <dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-bundle-jaxrs</artifactId>
    <version>2.7.18</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxrs</artifactId>
    <version>${cxf.version}</version>
</dependency>
        <dependency>
            <!-- Apache JAX-WS CXF Dependency for WAR and JAX-WS Client-->
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <!-- Apache JAX-WS CXF Dependency for JAX-WS Client-->
            <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-bindings-soap</artifactId>
    <version>${cxf.version}</version>
    <scope>compile</scope>
</dependency>
        <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.2</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>2.5.5</version>
</dependency>

    </dependencies>
</project>

修改 我再次创建了所有项目并得到了一个新的堆栈跟踪:

11:02:46,113 ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 47) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'categoryRESTService': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serviceBeans' threw exception; nested exception is java.lang.IllegalArgumentException: Failure parsing MediaType string: application/xml,application/json
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1278) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) [spring-beans-2.5.5.jar:2.5.5]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_79]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) [spring-context-2.5.5.jar:2.5.5]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) [spring-context-2.5.5.jar:2.5.5]
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) [spring-web-2.5.5.jar:2.5.5]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) [spring-web-2.5.5.jar:2.5.5]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) [spring-web-2.5.5.jar:2.5.5]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
    at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
    at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_79]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serviceBeans' threw exception; nested exception is java.lang.IllegalArgumentException: Failure parsing MediaType string: application/xml,application/json
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1275) [spring-beans-2.5.5.jar:2.5.5]
    ... 27 more

11:02:46,113 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/restapp]] (ServerService Thread Pool -- 47) JBWEB000287: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'categoryRESTService': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serviceBeans' threw exception; nested exception is java.lang.IllegalArgumentException: Failure parsing MediaType string: application/xml,application/json
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1278) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) [spring-beans-2.5.5.jar:2.5.5]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_79]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) [spring-context-2.5.5.jar:2.5.5]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) [spring-context-2.5.5.jar:2.5.5]
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) [spring-web-2.5.5.jar:2.5.5]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) [spring-web-2.5.5.jar:2.5.5]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) [spring-web-2.5.5.jar:2.5.5]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
    at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
    at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_79]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serviceBeans' threw exception; nested exception is java.lang.IllegalArgumentException: Failure parsing MediaType string: application/xml,application/json
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59) [spring-beans-2.5.5.jar:2.5.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1275) [spring-beans-2.5.5.jar:2.5.5]
    ... 27 more

11:02:46,176 ERROR [org.apache.catalina.core] (ServerService Thread Pool -- 47) JBWEB001103: Error detected during context /restapp start, will stop it
11:02:46,176 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/restapp]] (ServerService Thread Pool -- 47) Closing Spring root WebApplicationContext
11:02:46,191 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 47) MSC000001: Failed to start service jboss.web.deployment.default-host./restapp: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./restapp: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Falló iniciar contexto
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_79]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Falló iniciar contexto
    at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:161)
    at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60)
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93)
    ... 6 more

项目结构:
Project Structure

1 个答案:

答案 0 :(得分:0)

注释不正确。参数必须是字符串数组,而不是字符串。

例如。

不正确:

@Consumes("application/xml, application/json")

正确:

@Consumes("application/xml", "application/json")