2011-07-31 7 views
2

JBOSS 7で動作しないと、私はその理由を把握することはできません。私はハンドラクラスの先頭に注釈@Controllerを使用しましたが、それ以上は機能しません。代わりにxmlを使用するように変更したとき、正常に動作します。誰もが何かヒントを与える?春2.5.6 @Controllerは一種の奇妙な何かがあります私は最近7をJBossへのJBoss 4.2.3からの私のコードを移行

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>asweb</display-name> 

    <filter> 
     <filter-name>springCharacterEncodingFilter</filter-name> 
     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 
     <init-param> 
     <param-name>encoding</param-name> 
     <param-value>UTF-8</param-value> 
     </init-param> 
    </filter> 

    <filter> 
     <filter-name>openEntityManagerInViewFilter</filter-name> 
     <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class> 
    </filter> 

    <filter-mapping> 
     <filter-name>springCharacterEncodingFilter</filter-name> 
     <url-pattern>*.do</url-pattern> 
    </filter-mapping> 

    <filter-mapping> 
     <filter-name>openEntityManagerInViewFilter</filter-name> 
     <url-pattern>*.do</url-pattern> 
    </filter-mapping> 

    <filter-mapping> 
     <filter-name>openEntityManagerInViewFilter</filter-name> 
     <url-pattern>/ws/*</url-pattern> 
    </filter-mapping> 

    <filter> 
     <filter-name>sitemesh</filter-name> 
     <filter-class> 
      com.opensymphony.module.sitemesh.filter.PageFilter 
     </filter-class> 
    </filter> 

    <filter-mapping> 
     <filter-name>sitemesh</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 

<servlet> 
     <servlet-name>simple</servlet-name> 
     <servlet-class>org.sonatype.mavenbook.web.SimpleServlet</servlet-class> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>simple</servlet-name> 
     <url-pattern>/simple.do</url-pattern> 
    </servlet-mapping> 
    <servlet> 
     <servlet-name>aswebmvc</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet 
     </servlet-class> 
     <load-on-startup>3</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>aswebmvc</servlet-name> 
     <url-pattern>*.do</url-pattern> 
    </servlet-mapping> 

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

    <context-param> 
     <param-name>log4jConfigLocation</param-name> 
     <param-value>/WEB-INF/classes/log4j.properties</param-value> 
    </context-param> 

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

    <jsp-config> 
     <taglib> 
      <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri> 
      <taglib-location>/WEB-INF/tld/c.tld</taglib-location> 
     </taglib> 
     <taglib> 
      <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri> 
      <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location> 
     </taglib> 
    </jsp-config> 

    <welcome-file-list> 
     <welcome-file>index.jsp</welcome-file> 
    </welcome-file-list> 

</web-app> 

aswebmvc-servlet.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:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-2.5.xsd"> 

    <context:component-scan base-package="com.xxx.appstore.web.controller" /> 
    <context:component-scan base-package="com.xxx.appstore.web.controller.admin" /> 

    <bean id="webController" class="com.xxx.appstore.web.controller.WebController"/> 

    <bean id="localeChangeInterceptor" 
     class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> 
     <property name="paramName" value="local" /> 
    </bean> 
    <bean id="handlerMapping" 
     class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> 
     <property name="interceptors"> 
      <ref bean="localeChangeInterceptor" /> 
     </property> 
    </bean> 
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> 
     <property name="synchronizeOnSession" value="true"/> 
    </bean> 

    <bean id="viewResolver" 
     class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="order" value="1" /> 
     <property name="prefix" value="/WEB-INF/jsp/" /> 
     <property name="suffix" value=".jsp" /> 
    </bean> 
</beans> 

私のコントローラクラス

package com.xxx.appstore.web.controller; 

import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
import org.apache.commons.logging.Log; 
import org.apache.commons.logging.LogFactory; 
import org.springframework.stereotype.Controller; 
import org.springframework.ui.ModelMap; 
import org.springframework.web.bind.annotation.RequestMapping; 


@Controller 
public class WebController 
{ 

    private static Log logger = LogFactory.getLog(WebController.class); 

    @RequestMapping("home.do") 
    public String home2(HttpServletRequest request, ModelMap model) { 
     return ""; 
    } 
    @RequestMapping("/home.do") 
    public String home(HttpServletRequest request, ModelMap model) { 

     return "web/home"; 
    } 

} 

私はほとんどの注釈のために私のために働くの設定ファイルを、更新しました。

答えて

2

うん - あなたは、JBoss 7で春のMVCを使用したい場合は、3に新機能の1つをスプリングMVCをアップグレードしたいと思うには、CDIのためのより良いサポートです。アップグレードをしたら、ejbをサーブレットに直接マッピングする必要があります。 http://docs.redhat.com/docs/en-US/JBoss_Web_Framework_Kit/1.2/html/Spring_Developer_Guide/ch07s05s02.html#ejb-reference

あなたは、このようなサーブレットへのEJBのを注入することができます:このユーザガイドの中で示されているように

<jee:local-slsb id="ejbReference" jndi-name="ejb/exampleEjb" 
     business-interface="example.ExampleEjb/> 

:あなたは、EJBを配線するためにどこか春のconfigsにこのような何かを追加したいと思う

@EJB(mappedName="java:global/earfile/jarfile/exampleEjb!com.app.ExampleEjb") 
private ExampleEjb ejb; 

あなたはログ内のEJBの正確なJNDI参照を見つけることができますが、これはJBossのCDIサポートをsprinc MVCの配線方法、本質的です。

5

Spring 2アノテーションは、新しいバージョンのJBossといくつかの非互換性があります。 Spring 2アプリケーションのアノテーションはJBoss 5では認識されていませんでした。Springを動作させるには、Springをv3にアップグレードする必要がありました。 Here's a Spring JIRA on it。修正バージョンはv3.0 RC1にあります。

JBoss 7で同じ問題が発生しているかどうかはわかりませんが、これは可能です。

+0

ねえ、あなたは春2または春2.5.6を使用しましたか?事は@Controllerは私の別のプロジェクトのJBoss 7と春2.5.6で仕事をしているが、私はちょうど違いを把握することはできません。 – post2626

+0

ちょっとアーロン、私はあなたが投稿した春と春のソースコードをたどることについての研究をした後、ついにそれを稼働させました。どうもありがとう。 – post2626

関連する問題