2014-09-23 52 views
0

首先,请让我aplogize我的英语不好。因为我是日本人。 我问JAX-RS项目的错误。 我导入下列网站的样本: http://www.opentone.co.jp/news/release/article04/article0403.html 但我无法执行该项目。JAX-RS的错误

我认为“启动上下文失败,因为以前的错误:关键”是最重要的。 他们如何解决?如果?

如果可能的话,上述网站请尝试导入到实际eclipse项目。 您可以从附件中下载“添付のファイル”。在页面底部附近。

结束了,谢谢。

这是web.xml中

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> 
    <display-name>Archetype Created Web Application</display-name> 

     <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
     </listener> 

     <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/spring/applicationContext.xml</param-value> 
     </context-param> 

     <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> 

这是堆栈跟踪

9 23, 2014 5:18:07 午後 org.apache.catalina.core.StandardContext listenerStart 
重大: クラス org.springframework.web.context.ContextLoaderListener のリスナインスタンスにコンテキスト初期化イベントを送信中の例外です 
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [jp.sample.jaxrs.service.HelloResource] for bean with name 'helloResource' defined in file [C:\Users\omiz12032\workspace3\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\jax-rs\WEB-INF\classes\jp\sample\jaxrs\service\HelloResource.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: jp/sample/jaxrs/service/HelloResource : Unsupported major.minor version 52.0 (unable to load class jp.sample.jaxrs.service.HelloResource) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1264) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1330) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:896) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:566) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) 
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) 
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) 
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210) 
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709) 
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) 
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:822) 
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) 
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) 
    at org.apache.catalina.core.StandardService.start(StandardService.java:525) 
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) 
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) 
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 
Caused by: java.lang.UnsupportedClassVersionError: jp/sample/jaxrs/service/HelloResource : Unsupported major.minor version 52.0 (unable to load class jp.sample.jaxrs.service.HelloResource) 
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2858) 
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) 
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:257) 
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1282) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1253) 
    ... 24 more 

9 23, 2014 5:18:07 午後 org.apache.catalina.core.StandardContext start 
重大: Error listenerStart 
9 23, 2014 5:18:07 午後 org.apache.catalina.core.StandardContext start 
重大: 以前のエラーのためにコンテキストの起動が失敗しました [/jax-rs] 
9 23, 2014 5:18:07 午後 org.apache.catalina.core.ApplicationContext log 
情報: Closing Spring root WebApplicationContext 
9 23, 2014 5:18:07 午後 org.apache.coyote.http11.Http11Protocol start 
情報: Coyote HTTP/1.1を http-8080 で起動します 
9 23, 2014 5:18:07 午後 org.apache.jk.common.ChannelSocket init 
情報: JK: ajp13 listening on /0.0.0.0:8009 
9 23, 2014 5:18:07 午後 org.apache.jk.server.JkMain start 
情報: Jk running ID=0 time=0/21 config=null 
9 23, 2014 5:18:07 午後 org.apache.catalina.startup.Catalina start 
情報: Server startup in 4681 ms 

ANF这是applicationContext.xml.Those用于注册的web服务

<?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:context="http://www.springframework.org/schema/context" 
    xmlns:jaxrs="http://cxf.apache.org/jaxrs" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
    http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> 

    <import resource="classpath:META-INF/cxf/cxf.xml" /> 

    <context:component-scan base-package="jp.sample.jaxrs" /> 

    <jaxrs:server id="jaxrsservice" address="/"> 
     <jaxrs:serviceBeans> 
      <ref bean="helloResource" /> 
     </jaxrs:serviceBeans> 
    </jaxrs:server> 

    <jaxrs:server id="itemorderresource" address="/"> 
     <jaxrs:serviceBeans> 
      <ref bean="itemOrderResource" /> 
     </jaxrs:serviceBeans> 
    </jaxrs:server> 

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> 
    <property name="driverClassName" value="com.mysql.jdbc.Driver" /> 
    <property name="url" value="jdbc:mysql://localhost/jaxrs" /> 
    <property name="username" value="jaxrs" /> 
    <property name="password" value="jaxrs" /> 
    </bean> 

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> 
    <property name="dataSource" ref="dataSource" /> 
    <property name="configLocation" value="classpath:mybatis-config.xml" /> 
    <property name="mapperLocations" value="classpath:mybatis/**/*.xml" /> 
    </bean> 

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 
    <property name="dataSource" ref="dataSource" /> 
    </bean> 
</beans> 
+0

请广告堆栈跟踪与您的例外到post和web.xml文件。 – Gas 2014-09-23 07:52:30

+0

谢谢reply.I添加到文本stacktrace和web.xml – 2014-09-23 08:30:23

回答

0

Caused by: java.lang.UnsupportedClassVersionError: jp/sample/jaxrs/service/HelloResource : Unsupported major.minor version 52.0 (unable to load class jp.sample.jaxrs.service.HelloResource)

基本上这意味着你编译你的JDK类比你的服务器更新(可能在开发环境中你有1.8,而在tomcat服务器上你有1.7)。

尝试在开发环境中将Java编译器级别切换到较低版本。

+0

谢谢reply.I可以删除errors.very谢谢。 – 2014-09-23 11:35:43