복붙노트

[SPRING] Spring App을 Websphere에 배치 할 수 없다.

SPRING

Spring App을 Websphere에 배치 할 수 없다.

개발 도중 바람둥이 응용 프로그램을 개발했습니다. 우리가 앞으로 나아갈 때, 나의 고객은 websphere에 배치되기를 원합니다. 나는 websphere 8.5에서 그렇게하려고 시도하고있다. 그러나 어떤 이유로 나는 문제가있는 것처럼 보인다. Tomcat은 쉽습니다. 나는 전쟁에 뛰어 들고 모든 것이 제대로 작동합니다. Websphere는 다른 이야기입니다. 내 응용 프로그램에 충돌하려고하면 다음과 같은 오류가 계속 발생합니다.

Error 404: SRVE0190E: File not found: {0}

나는 몇 가지 조사를 해왔고 아래의 한 줄을 제외하고는 로그에서 이상한 점을 발견하지 못했습니다. 관리 콘솔에는 응용 프로그램이 문제없이 실행되고 있다고 표시됩니다.

SRVE0292I: Servlet Message - [app#app.war]:.No Spring WebApplicationInitializer types detected on classpath

내 응용 프로그램은 전통적인 XML 대신 Java Config 파일을 사용하여 구성되었으며이 부분은 문제의 일부라고 생각하십니까?

적용 할 필요가있는 서버 설정이 있다는 블로그 게시물을 발견했습니다. 나는 성공하지 못한 사람들을 시도했다.

com.ibm.ws.webcontainer.mapFiltersToAsterisk=true
com.ibm.ws.webcontainer.removetrailingservletpathslash=true
com.ibm.ws.webcontainer.invokeFiltersCompatibility=true

나는 손실에 빠졌습니다. 누구에게 아이디어가 있습니까?

몇 가지 추가 작업으로 인해 web.xml 및 WebappInitializer를 게시합니다.

@Order(2)
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class<?>[] {ApplicationConfig.class, DataSourceConfig.class, JpaConfig.class, SecurityConfig.class, MailConfig.class};
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class<?>[] {WebMvcConfig.class};
    }

    @Override
    protected Filter[] getServletFilters() {
        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
        characterEncodingFilter.setEncoding("UTF-8");
        characterEncodingFilter.setForceEncoding(true);
        return new Filter[] {characterEncodingFilter};
    }

    @Override
    protected void customizeRegistration(ServletRegistration.Dynamic registration) {
        registration.setInitParameter("defaultHtmlEscape", "true");
        registration.setInitParameter("spring.profiles.active", "default");
    }
}

веб.хмл :

    <?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        version="3.0" metadata-complete="false">
        <!-- Map all errors to Spring MVC handler method. See CustomErrorController.generalError() -->
        <error-page>
            <location>/generalError</location>
        </error-page>
        <session-config>
          <session-timeout>15</session-timeout>
       </session-config>
       <display-name>eua</display-name>
    </web-app>

해결법

  1. ==============================

    1.나는 내 해결책에 대해 대단히 행복하지는 않지만 당분간은 효과가있다. websphere의 web.xml-less 초기화 지원은 약간의 하위 표준입니다. 그들의 기술자들로부터의 응답조차도 도움이되지 못했다. 결국 스프링 초기화를 web.xml로 이동해야했습니다. 설정 파일을 통해 JPA, 보안 및 웹 기능의 대부분을 구성 할 수 있었지만 Spring에 약간의 킥 스타트를 제공해야했습니다. 아래는 변경된 web.xml입니다. 도와 주신 모든 분들께 감사드립니다.

    나는 내 해결책에 대해 대단히 행복하지는 않지만 당분간은 효과가있다. websphere의 web.xml-less 초기화 지원은 약간의 하위 표준입니다. 그들의 기술자들로부터의 응답조차도 도움이되지 못했다. 결국 스프링 초기화를 web.xml로 이동해야했습니다. 설정 파일을 통해 JPA, 보안 및 웹 기능의 대부분을 구성 할 수 있었지만 Spring에 약간의 킥 스타트를 제공해야했습니다. 아래는 변경된 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_3_0.xsd"
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
             id="WebApp_ID" version="3.0">
        <!-- Map all errors to Spring MVC handler method. See CustomErrorController.generalError() -->
        <error-page>
            <location>/generalError</location>
        </error-page>
        <session-config>
          <session-timeout>15</session-timeout>
       </session-config>
       <display-name>app</display-name>
       <context-param>
          <param-name>contextClass</param-name>
          <param-value>
              org.springframework.web.context.support.AnnotationConfigWebApplicationContext
          </param-value>
       </context-param>
    
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>org.proj.config.ApplicationConfig 
                        org.proj.config.DefaultDataSourceConfig
                        org.proj.config.JpaConfig
                        org.proj.config.SecurityConfig
                        org.proj.config.MailConfig
                        org.proj.config.WebMvcConfig
           </param-value>
        </context-param>
    
        <!-- Bootstrap the root application context as usual using ContextLoaderListener -->
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    
       <servlet>
            <servlet-name>spring</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>        
            <init-param>
              <param-name>contextClass</param-name>
              <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
             </init-param>
              <!-- Again, config locations must consist of one or more comma- or space-delimited
                   and fully-qualified @Configuration classes -->
              <init-param>
                  <param-name>contextConfigLocation</param-name>
                  <param-value>org.proj.config.ApplicationConfig 
                               org.proj.config.DefaultDataSourceConfig
                               org.proj.config.JpaConfig
                               org.proj.config.SecurityConfig
                               org.proj.config.MailConfig
                               org.proj.config.WebMvcConfig  
                   </param-value>
              </init-param>
              <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>spring</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
        <filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
    
        <filter-mapping>
          <filter-name>springSecurityFilterChain</filter-name>
          <url-pattern>/*</url-pattern>
          <dispatcher>ERROR</dispatcher>
          <dispatcher>REQUEST</dispatcher>
        </filter-mapping>
    </web-app>
    
  2. ==============================

    2.WebAppInitializer 클래스에서 @Configuration 주석을 사용하십시오.

    WebAppInitializer 클래스에서 @Configuration 주석을 사용하십시오.

    @Configuration 
    public class WebAppInitializer implements WebApplicationInitializer {
    
        @Override
        public void onStartup(ServletContext container) {
            // Create the 'root' Spring application context
            AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
            rootContext.register(HibernateConfiguration.class);
    
            // Manage the lifecycle of the root application context
            container.addListener(new ContextLoaderListener(rootContext));
    
            // Create the dispatcher servlet's Spring application context
            AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext();
            dispatcherServlet.register(SpringWebConfig.class);
    
            // Register and map the dispatcher servlet
            ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherServlet));
            dispatcher.setLoadOnStartup(1);
            dispatcher.addMapping("/");
    
        }
    
     }
    
  3. ==============================

    3.나는 비슷한 문제가 있었다. Websphere에는 검사 할 수있는 클래스 수에 대한 일부 기본 한계가 있습니다. 그리고이 SpringBoot 메인 클래스는 아마 그 범위 내에 있지 않았을 것입니다. 제 경우에는이 JVM 등록 정보를 -Dclassinfocachesize = 10000 (응용 프로그램 서버> server1> 프로세스 정의> Java 가상 컴퓨터> 일반 JVM 인수>)로 설정하고 WAS를 다시 시작하면 문제가 해결되었습니다

    나는 비슷한 문제가 있었다. Websphere에는 검사 할 수있는 클래스 수에 대한 일부 기본 한계가 있습니다. 그리고이 SpringBoot 메인 클래스는 아마 그 범위 내에 있지 않았을 것입니다. 제 경우에는이 JVM 등록 정보를 -Dclassinfocachesize = 10000 (응용 프로그램 서버> server1> 프로세스 정의> Java 가상 컴퓨터> 일반 JVM 인수>)로 설정하고 WAS를 다시 시작하면 문제가 해결되었습니다

  4. ==============================

    4.나에게 IBM WAS ND 8.5.0의 작업 솔루션은 직접 인터페이스 WebApplicationInitializer를 구현하는 것이었다.

    나에게 IBM WAS ND 8.5.0의 작업 솔루션은 직접 인터페이스 WebApplicationInitializer를 구현하는 것이었다.

    봄 부팅 74.4

  5. ==============================

    5.@Configuration 주석을 추가하고 WebApplicationInitializer를 직접 구현하면이 문제를 해결할 수 있습니다. (Websphere 8.5.0.2에 대해 테스트 됨)

    @Configuration 주석을 추가하고 WebApplicationInitializer를 직접 구현하면이 문제를 해결할 수 있습니다. (Websphere 8.5.0.2에 대해 테스트 됨)

  6. ==============================

    6.나는 똑같은 문제에 직면했다. 내 Spring MVC (Spring 4.3) Rest 애플리케이션이 Jboss에서 작동했지만 Websphere 8.5.5에서 배포를 시도했을 때 동일한 오류가 발생했습니다. SRVE0292I : Servlet Message - [app # app.war] : 아니요 Spring WebApplicationInitializer 유형이 감지되었습니다. classpath. 이 게시물과 다른 게시물에서 제안 된 모든 옵션을 시도했지만 아무 것도 해결되지 않았습니다. 마침내 나는 그 문제를 발견했다. Spring MVC Rest 애플리케이션을 만들 때 프로젝트를 만들기 위해 maven archetype을 사용했고 빈 web.xml로 Spring MVC 애플리케이션을 만들었다. Spring 4, java 기반 초기화를 사용하려고 할 때, webcheck와 같은 webcheche를 생성하고 web.xml에 dispatcherServlet을 구성하지 않았습니다. Jboss는 빈 web.xml을 무시하고 java initializer 클래스를 찾고 응용 프로그램을 가져올 정도로 지능적이었습니다. 동일한 애플리케이션이 WebSphere 8.5.5에 배치 된 곳에서 WebSphere는 빈 web.xml을 발견하고 web.xml에서 DispatcherServlet 정보를 찾고 java 초기화 프로그램 클래스를 찾지 않습니다. web.xml을 제거하고 애플리케이션을 재배포하면 WebSphere에 애플리케이션이 올라와있다.

    나는 똑같은 문제에 직면했다. 내 Spring MVC (Spring 4.3) Rest 애플리케이션이 Jboss에서 작동했지만 Websphere 8.5.5에서 배포를 시도했을 때 동일한 오류가 발생했습니다. SRVE0292I : Servlet Message - [app # app.war] : 아니요 Spring WebApplicationInitializer 유형이 감지되었습니다. classpath. 이 게시물과 다른 게시물에서 제안 된 모든 옵션을 시도했지만 아무 것도 해결되지 않았습니다. 마침내 나는 그 문제를 발견했다. Spring MVC Rest 애플리케이션을 만들 때 프로젝트를 만들기 위해 maven archetype을 사용했고 빈 web.xml로 Spring MVC 애플리케이션을 만들었다. Spring 4, java 기반 초기화를 사용하려고 할 때, webcheck와 같은 webcheche를 생성하고 web.xml에 dispatcherServlet을 구성하지 않았습니다. Jboss는 빈 web.xml을 무시하고 java initializer 클래스를 찾고 응용 프로그램을 가져올 정도로 지능적이었습니다. 동일한 애플리케이션이 WebSphere 8.5.5에 배치 된 곳에서 WebSphere는 빈 web.xml을 발견하고 web.xml에서 DispatcherServlet 정보를 찾고 java 초기화 프로그램 클래스를 찾지 않습니다. web.xml을 제거하고 애플리케이션을 재배포하면 WebSphere에 애플리케이션이 올라와있다.

  7. ==============================

    7.이 문제점은 WebSphere ND 용 APAR PM85177에서 수정되었습니다. 수정 사항은 WAS8.0.0.8 및 이후 버전에 통합되어 있습니다.

    이 문제점은 WebSphere ND 용 APAR PM85177에서 수정되었습니다. 수정 사항은 WAS8.0.0.8 및 이후 버전에 통합되어 있습니다.

  8. from https://stackoverflow.com/questions/21714642/cannot-deploy-spring-app-to-websphere by cc-by-sa and MIT license