티스토리 뷰

728x90
SMALL

 포스팅에서는 하나의 Standalone Server에서 동일 Context를 사용하는 방법을 가이드합니다.


하나의 Standalone Server에 3개의 application이 deploy되어있다고 생각해봅시다.

이 3개의 applicaton에 지정된 context root는 모두 달라야합니다.

하지만 모두 같아야한다면 어떻게 해야하는지 그 해결방법을 알아보겠습니다.

 

테스트 시나리오 : 동일한 Conext root를 가진 application을 deploy하였을때

A application 의 Context root : '/'

B application 의 Context root : '/'

C application 의 Context root : '/'

 

1.아래와 같이 Standalone Server에 3개의 application을 deploy합니다.


- standalone.xml

 ..

  <deployments>
        <deployment name="5VhostA" runtime-name="5VhostA.war">
            <fs-exploded path="/home/wildfly/PocApp/5VhostA"/>
        </deployment>
        <deployment name="5VhostB" runtime-name="5VhostB.war">
            <fs-exploded path="/home/wildfly/PocApp/5VhostB"/>
        </deployment>
        <deployment name="5VhostC" runtime-name="5VhostC.war">
            <fs-exploded path="/home/wildfly/PocApp/5VhostC"/>
        </deployment>
  </deployments>


 

728x90

2.저장 후 Server를 기동하면, 아래와 같이 에러가 발생합니다.


2018-08-10 14:38:17,386 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "5VhostA" (runtime-name: "5VhostA.war")
2018-08-10 14:38:17,386 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0027: Starting deployment of "5VhostC" (runtime-name: "5VhostC.war")
2018-08-10 14:38:17,386 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "5VhostB" (runtime-name: "5VhostB.war")
2018-08-10 14:38:17,454 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0006: Undertow HTTPS listener https listening on 0.0.0.0:9043
2018-08-10 14:38:17,489 INFO  [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBossWS 5.2.1.Final (Apache CXF 3.2.4.jbossorg-1)
2018-08-10 14:38:17,934 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."5VhostC.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."5VhostC.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "5VhostC.war"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:150)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1736)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1698)
        at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1556)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1364)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.undertow.deployment.default-server.default-host./.session is already registered
        at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:111)
        at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:245)
        at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:757)
        at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:260)
        at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2056)
        at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:260)
        at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2056)
        at org.jboss.msc.service.ObsoleteServiceBuilderImpl.install(ObsoleteServiceBuilderImpl.java:293)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentProcessor.processDeployment(UndertowDeploymentProcessor.java:399)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentProcessor.deploy(UndertowDeploymentProcessor.java:190)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:143)
        ... 8 more

2018-08-10 14:38:17,937 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."5VhostB.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."5VhostB.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "5VhostB.war"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:150)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1736)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1698)
        at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1556)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1364)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.undertow.deployment.default-server.default-host./.session is already registered
        at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:111)
        at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:245)
        at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:757)
        at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:260)
        at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2056)
        at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:260)
        at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2056)
        at org.jboss.msc.service.ObsoleteServiceBuilderImpl.install(ObsoleteServiceBuilderImpl.java:293)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentProcessor.processDeployment(UndertowDeploymentProcessor.java:399)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentProcessor.deploy(UndertowDeploymentProcessor.java:190)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:143)
        ... 8 more


이는 동일한 Context root를 가진 다수의 application이 존재한다는 뜻으로, application마다 Context root를 다르게 해주면 해결할 수 있습니다. 하지만 불가피하게 모든 application이 동일한 Context root를 가져야한다면 어떻게 해야할까요?

 

728x90

해결방법

 

1.하나의 IP에 3개의 가상 도메인을 지정합니다.


- ../etc/hosts

 

동일IP  aaa.kkm.com
동일IP  bbb.kkm.com
동일IP  ccc.kkm.com


 

2.undertow subsystem상에서 virtual host를 추가합니다.  


- standalone.xml

 

<subsystem xmlns="urn:jboss:domain:undertow:6.0" default-server="default-server" default-virtual-host="default-host" default-servlet-container="default" default-security-domain="other">
...

<server name="default-server">
                <ajp-listener name="ajp" socket-binding="ajp" scheme="http"/>
                <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
                <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
                <host name="default-host" alias="localhost">
                    <access-log pattern="%T %h %l %u %t %r %s %b %{Referer}i %{User-Agent}i %S %I" prefix="access"/>
                    <location name="/" handler="welcome-content"/>
                    <http-invoker security-realm="ApplicationRealm"/>
                </host>
                <host name="5VhostA" alias="aaa.kkm.com" default-web-module="5VhostA.war">
                </host>
                <host name="5VhostB" alias="bbb.kkm.com" default-web-module="5VhostB.war">
                </host>
                <host name="5VhostC" alias="ccc.kkm.com" default-web-module="5VhostC.war">
                </host>
            </server>

.....

 


- host name

- alias : 도메인네임

- default-web-module : application명 지정

 

3.상단의 <host name> 값과 application단의 jboss-web.xml 내 <virtual-host> 값을 매칭시켜줍니다.


- jboss-web.xml

 

<jboss-web>
        <virtual-host>5VhostA</virtual-host>
        <context-root>/</context-root>
</jboss-web>


 

4. Server를 재기동합니다.

 

5. 각 application 호출 



 



 

각 application이 같은 Conext root로 정상적으로 호출되는것을 알 수 있습니다.

 

고맙습니다.


728x90
LIST
댓글
댓글쓰기 폼