복붙노트

[SPRING] JBoss AS 7.1.X에서 Spring 3.0.X와 함께 JAX-WS 웹 서비스 사용하기

SPRING

JBoss AS 7.1.X에서 Spring 3.0.X와 함께 JAX-WS 웹 서비스 사용하기

JBoss AS Final 7.1.1에서 Spring 3.0.6을 사용하여 JAX-WS 웹 서비스를 배포하는 데 문제가 있습니다.

이 튜토리얼에서 두 가지 첫 번째 방법을 시도했다 : http://www.javacodegeeks.com/2010/11/jaxws-with-spring-and-maven-tutorial.html

SpringBeanAutowiringSupport를 확장하고 web.xml에서 서블릿을 선언하는 첫 번째 방법을 사용할 때 응용 프로그램이 올바르게 배포되지만 웹 서비스에 삽입하는 빈은 Null입니다.

SimpleJaxWsServiceExporter에서 두 번째 방법 사용 배포하는 동안 오류가 발생합니다.

10:09:33,012 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-2) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter#0' defined in ServletContext resource [/WEB-INF/generic-applicationContext.xml]: Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: java.lang.RuntimeException: java.net.BindException: Address already in use: bind
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) [spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) [spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_18]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_18]
    at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_18]
Caused by: javax.xml.ws.WebServiceException: java.lang.RuntimeException: java.net.BindException: Address already in use: bind
    at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350)
    at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239)
    at org.jboss.wsf.stack.cxf.client.ProviderImpl$DelegateEndpointImpl.publish(ProviderImpl.java:300)
    at org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter.publishEndpoint(SimpleJaxWsServiceExporter.java:68) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.remoting.jaxws.AbstractJaxWsServiceExporter.publishEndpoints(AbstractJaxWsServiceExporter.java:154) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.remoting.jaxws.AbstractJaxWsServiceExporter.afterPropertiesSet(AbstractJaxWsServiceExporter.java:125) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    ... 20 more
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" 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" version="2.5">

    <display-name>subscription-barring-service</display-name>

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

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
</web-app>
<?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:jee="http://www.springframework.org/schema/jee"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:task="http://www.springframework.org/schema/task"
    xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">

        <context:component-scan
            base-package="org.bluewin.bwsso.services.barring" />

        <bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter"/>
</beans>
@Service("terminateSessionsEndpoint") 
@WebService(serviceName = "TerminateSessionsEndpoint", portName = "TerminateSessionsEndpoint")
public class TerminateSessionsEndpoint extends SpringBeanAutowiringSupport {

    private Logger logger = Logger.getLogger(TerminateSessionsEndpoint.class);

    @Autowired
    Service serviceImpl;

    @WebMethod(operationName = "TerminateAllSessionsForAccountId")
    @WebResult(name = "TerminateAllSessionsResponse") 
    public TerminateAllSessionsResponseVO terminateAllSessionsForAccountId(
            @WebParam(name = "TerminateAllSessionsRequest") 
            TerminateAllSessionsRequestVO requestWS) {

        //do some logic..
    }
}

어떤 단서를 어떻게 얻을 수 있습니까?

해결법

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

    1.비슷한 구성으로 JAX-WS를 배치하는 데 문제가 있습니다. Spring 문서 장의 "19.5.5 JAX-WS를 사용하여 서블릿 기반 웹 서비스 노출"에서 설명한 SpringBeanAutowiringSupport를 실제로 사용하면 예상대로 작동하지 않습니다.

    비슷한 구성으로 JAX-WS를 배치하는 데 문제가 있습니다. Spring 문서 장의 "19.5.5 JAX-WS를 사용하여 서블릿 기반 웹 서비스 노출"에서 설명한 SpringBeanAutowiringSupport를 실제로 사용하면 예상대로 작동하지 않습니다.

    http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html#remoting-web-services 문서를 참조하십시오.

    하지만 SimpleJaxWsServiceExporter를 사용하려고 여기에서 틀렸다. 스프링 문서의 "19.5.6 JAX-WS를 사용하여 독립형 웹 서비스 내보내기"

    이것은 jboss에 의해 이미 등록 된 웹 서비스와 충돌합니다.

    업데이트 된 포트 번호로 다음 구성을 시도해보십시오. 응용 프로그램 컨텍스트 :

    <bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
       <property name="baseAddress" value="http://localhost:8081/"/>
    </bean>
    

    마지막에는 노출 된 두 가지 서비스로 실행됩니다.

    http://localhost:8080/war-root/MyService?wsdl
    http://localhost:8081/MyService?wsdl
    

    현재로서는 다른 사람들이 제안한 두 가지 대안을 발견했습니다.

    두 해결 방법 모두 정상적으로 작동합니다.

  2. ==============================

    2.확실히 항구 문제입니다. 그 예외는 아주 분명합니다.

    확실히 항구 문제입니다. 그 예외는 아주 분명합니다.

    Caused by: javax.xml.ws.WebServiceException: java.lang.RuntimeException: java.net.BindException: Address already in use: bind
    

    의견에서 포트 9999, 에서 청취하는 것이 있음을 나타냅니다. 관리 기본 포트는 포트 9999입니다. 아래 standalone.xml을 보면 다음과 같은 메시지가 표시됩니다.

    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/>
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/>
        <socket-binding name="ajp" port="8009"/>
        <socket-binding name="http" port="8080"/>
        <socket-binding name="https" port="8443"/>
        <socket-binding name="osgi-http" interface="management" port="8090"/>
        <socket-binding name="remoting" port="4447"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>
    

    테스트는 다음 명령으로 독립 실행됩니다.

    $JBOSS_HOME/bin/standalone.sh -Djboss.management.native.port=19999
    
  3. from https://stackoverflow.com/questions/10445969/using-jax-ws-webservices-with-spring-3-0-x-on-jboss-as-7-1-x by cc-by-sa and MIT license