옆에 앉아계신 차장님의 발기아래 JBoss Installer를 groovy로 만들어 LGPL 프로젝트로 구글에 등록했습니다. 일반 자바 문법으로 작성하였으면 상당했을 코드량을 Groovy의 치환자 등을 이용하여 JBoss 4.2와 EAP(Enterprise Application Platform:상용버전)을 한 번에 여러 대의 서버에 인스톨할 수 있는 프로그램입니다.

이것을 이용하여 30대의 운영 리눅스 서버(각 서버당 4개의 인스턴스)에 JBoss를 설치하는 데 30분이 걸렸다고 하네요. 초기 프로젝트 import는 만득이(http://www.mandki.com) 개발자인 전모씨 아드님이신 준식 차장님이 담당을 했습니다. 왜 JB29냐면 "JBoss를 설치하는 B29 폭격기"라는 곳에서 착안했습니다.

FTP로 서버를 순회하며 파일을 올리고 자동으로 압축을 풀고 해당 서버의 configuration으로 변경하는 작업들을 한 번에 수행합니다.

이제 groovy를 시작한터라 너무 자바틱할 수도 있겠지만 기능만큼은 막강할 수 있겠네요.
JBoss 5.0 용은 설정이 바뀐터라 코드를 조금 수정해야 합니다.

http://code.google.com/p/jb29/

크리에이티브 커먼즈 라이센스
Creative Commons License
2009/05/27 13:17 2009/05/27 13:17

사용자 삽입 이미지
JBoss Web Service Sample을 작성해보도록 하겠습니다. JBoss Web Service는 jboss.org의 jbossws 프로젝트를 이용하여 구성되어 있으며, JBoss Application Server 내에서 jbossws에 대한 sar(service archive)로 포팅되어 있습니다.

보통의 WebService예제는 vendor specific 으로 구성되어 있지만 JBoss의 특징이라면 "무조건 표준으로 간다"(워낙에 표준 준수가 심해서 가끔은 짜증이 납니다)이므로 JBoss Web Service라지만 다른 엔진 라이브러리만 있다면 아무데서나 구동될 수 있습니다.

Eclipse를 띄우고 일반 웹 애플리케이션 프로젝트를 띄운 후 JBoss library를 프로젝트의 Build Path로 지정합니다. 이 부분에 대해서는 별도 설명을 하지 않습니다.

1. Server 측 코드를 작성합니다.

package com.jboss.webservice;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

/**
 * This is a webservice class exposing a method called greet which takes a input
 * parameter and greets the parameter with hello.
 *
 * @author Ji-Woong Choi
 */

/*
 * @WebService indicates that this is webservice interface and the name
 * indicates the webservice name.
 */
@WebService(name = "Hello", targetNamespace="
http://client.jboss.com/", serviceName="GreetService")
/*
 * @SOAPBinding indicates binding information of soap messages. Here we have
 * document-literal style of webservice and the parameter style is wrapped.
 */
//@SOAPBinding(style = SOAPBinding.Style.RPC, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
@SOAPBinding(style = SOAPBinding.Style.RPC, use = SOAPBinding.Use.LITERAL)
public class Hello {
 /**
  * This method takes a input parameter and appends "Hello" to it and returns
  * the same.
  *
  * @param name
  * @return
  */
 @WebMethod
 public String greet(@WebParam(name = "name")
 String name) {
  System.out.println("JBoss Web Service was invoked by " + name);
  return "Hello!, " + name;
 }
}

Web Service Annotation을 이용하여 필요한 메소드들을 구성합니다.

2. Web.xml 파일을 편집합니다. 본 예제에서는 servlet style을 이용하여 처리합니다.

<?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>jboss-ws</display-name>
 <servlet>
  <servlet-name>Hello</servlet-name>
  <servlet-class>com.jboss.webservice.Hello</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>Hello</servlet-name>
  <url-pattern>/Hello</url-pattern>
 </servlet-mapping>
 <session-config>
  <session-timeout>30</session-timeout>
 </session-config>

</web-app>

다른 방법으로는 EJB를 이용하여 port proxy를 remote stub을 이용하는 방법이 있지만 web이 테스트하기 보다 단순하므로 이 예제를 이용하겠습니다.

3. 서버에 디플로이 후 Web Service에 대한 deploy상태를 확인합니다.

http://localhost:8080/jbossws/ 라고 입력하면 웹서비스 리스트를 확인할 수 있습니다.

사용자 삽입 이미지

위의 화면에서 "View a list of deployed services"를 클릭하면 웹서비스들의 상태가 나타나게 됩니다.

사용자 삽입 이미지

4. WSDL의 디플로이된 상태를 확인합니다.

사용자 삽입 이미지

5. 이제 클라이언트 코드를 작성합니다. 여기서는 DII방식(Dynamic Invocation Interface) 방식을 이용하여 작성합니다.

package com.jboss.webservice.client;

import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Call;

import javax.xml.namespace.QName;

import java.net.URL;

public class HelloClientDII
{
    public static void main(String[] args)
        throws Exception
    {
        String urlstr   = "http://localhost:8080/jboss-ws/Hello?wsdl";
        String argument = "Ji-Woong";

        System.out.println("Contacting webservice at " + urlstr);

        URL url =  new URL(urlstr);

        String ns        = "http://client.jboss.com/";
        QName  qname     = new QName(ns, "GreetService");
        QName  port      = new QName(ns, "HelloPort");
        QName  operation = new QName(ns, "greet");

        ServiceFactory factory = ServiceFactory.newInstance();
        Service        service = factory.createService(url, qname);
        Call           call    = service.createCall(port, operation);

        System.out.println("hello.hello(" + argument + ")");
        System.out.println("output:" + call.invoke(new Object[] {argument}));
    }
}

위의 코드를 실행하면 서버에 System console에 적은 내용이 찍히게 되며, 클라이언트에서 응답을 받을 수 있습니다.


다시 한번 "http://localhost:8080/jbossws/services" url을 확인하면 수행된 시간에 대한 결과치를 확인할 수 있습니다.


크리에이티브 커먼즈 라이센스
Creative Commons License
2008/12/01 15:45 2008/12/01 15:45

사용자 삽입 이미지
This content is to describe how to change JBoss Application Server's port.
한꺼번에 JBoss AS의 적용 포트를 변경하는 방법을 설명합니다.
JBoss가 사용하는 포트는 이미 이전 글에서 설명되어 있습니다.

JBoss의 서비스 포트를 일률적으로 변경하고 싶은 경우 다음의 절차를 진행하십시오.
1. $SERVER_HOME/conf/jboss-service.xml 파일을 엽니다.
해당 파일의 service binding 영역을 찾아 주석을 풀도록 합니다.

<!-- ==================================================================== -->
   <!-- Service Binding                                                      -->
   <!-- ==================================================================== -->

   <!-- Automatically activated when generatting the clustering environment -->
   <!-- @TESTSUITE_CLUSTER_CONFIG@ -->

   <!--
      | Binding service manager for port/host mapping. This is a sample
      | config that demonstrates a JBoss instances with a server name 'ports-01'
      | loading its bindings from an XML file using the ServicesStoreFactory
      | implementation returned by the XMLServicesStoreFactory.
      |
      | ServerName: The unique name assigned to a JBoss server instance for
      | lookup purposes. This allows a single ServicesStore to handle mulitiple
      | JBoss servers.
      |
      | StoreURL: The URL string passed to org.jboss.services.binding.ServicesStore
      | during initialization that specifies how to connect to the bindings store.
      | StoreFactory: The org.jboss.services.binding.ServicesStoreFactory interface
      | implementation to create to obtain the ServicesStore instance.

   <mbean code="org.jboss.services.binding.ServiceBindingManager"
     name="jboss.system:service=ServiceBindingManager">
     <attribute name="ServerName">ports-01</attribute>
     <attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>
     <attribute name="StoreFactoryClassName">
       org.jboss.services.binding.XMLServicesStoreFactory
     </attribute>
   </mbean>
   -->

위의 설정파일에서는 port를 변경할 수 있는 파일이 sample-bindings.xml 에 정의되어 있다는 내용이 있습니다. 위의 파일 위치에 있는 설정 파일을 여십시오..

2. bindings.xml 파일을 열어 ServerName의 ports-01에 해당하는 태그를 찾습니다. 500라인 부근에 ports-01 속성값들이 해당 서버의 port정보를 모두 담고 있습니다. 필요한 port로 바꾸도록 합니다.

<!-- ********************************************************** -->
   <!-- *                          ports-01                      * -->
   <!-- ********************************************************** -->
   <server name="ports-01">

      <!-- EJB3 Remoting Connector ejb3.deployer/META-INF/jboss-service.xml -->

      <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3" delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
        <delegate-config>
           <attribute name="InvokerLocator">socket://${jboss.bind.address}:3973</attribute>
        </delegate-config>
         <binding port="3973"/>
      </service-config>

      <!-- ********************* jboss-service.xml ****************** -->

      <service-config name="jboss:service=Naming" delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1198</attribute>
         </delegate-config>
         <binding port="1199" host="${jboss.bind.address}"/>
      </service-config>


      <service-config name="jboss:service=WebService" delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="Port"/>
         <binding port="8183"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=jrmp" delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4544"/>
      </service-config>


      <service-config name="jboss:service=invoker,type=pooled" delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="ServerBindPort"/>
         <binding port="4545"/>
      </service-config>

이하 생략
. . . . .

위의 xml tag 중 ServerName에 해당하는 값은 각 파일간에 서로 매핑되어 있어야 함은 당연합니다.


 

크리에이티브 커먼즈 라이센스
Creative Commons License
2008/08/27 13:23 2008/08/27 13:23

사용자 삽입 이미지
JBoss 애플리케이션 서버는 기본적으로 8080을 기반으로 서버가 구동됩니다. 만약 이 port를 변경하고 싶을 경우에는 다음과 같이 설정하면 됩니다.

1. JBoss 서버가 설치된 디렉토리를 엽니다.
2. <JBOSS_HOME>/<SERER_HOME>/deploy 디렉토리를 엽니다.
3. JBoss 4.0.X의 경우에는 jbossweb-tomcat55.sar , JBoss 4.2.X의 경우에는 jboss-web.deployer디렉토리로 이동합니다.
4. server.xml파일을 찾아 편집기로 다음을 찾아 변경합니다.

 <Connector port=”8080″ address=”${jboss.bind.address}”…….

5. 서버를 재기동시키면 변경된 포트로 JBoss가 구동되게 됩니다.

사용자 삽입 이미지
JBoss 4.0.2 screen shot




     

크리에이티브 커먼즈 라이센스
Creative Commons License
2008/07/23 09:58 2008/07/23 09:58

사용자 삽입 이미지
Client Machine에서 일반적으로 jndi.properties는 가지고 있습니다.
jndi.properties 내용은 다음과 같습니다
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://xxx.xxx.xxx.xxx:1099
java.naming.factory.url.pkgs=org.jboss.naming
기본적으로 TCP 1099포트로 할당되게 됩니다. 이 포트를 이용하여 RMI기준으로 JBoss AS의 네이밍 서비스를 검색하게 됩니다.

Naming Service에 대한 환경설정은 YourConfig->conf->jboss-service.xml에 정의되어 있으며 hot-deploy 대상이 아니므로 변경사항에 대한 내용이 모니터링되지 않습니다. 즉 kernel이 부팅된 이후 한번만 읽게 되는 대상입니다.

1099 Port Attribute가 disable 될 수 있는 경우는 다음과 같습니다.
1. HTTP 클라이언트만 가지고 있는 경우
2. 모든 원격 네이밍 서비스가 HTTP 터널링을 통해 서비스되는 경우
3. 복제된 네이밍 서비스가 작동되고 있는 경우

만약 보안에 의하여 HTTP이외의 다른 프로토콜을 사용할 수 없는 경우 Naming Service에 HTTP Tunneling을 통해서 접근할 수 있습니다. 그 때의 설정은 다음과 같이 할 수 있습니다.

java.naming.factory.initial=org.jboss.naming.HttpNamingContextFactory
java.naming.provider.url=http://xxx.xxx.xxx.xxx:8080/invoker/JNDIFactory
java.naming.factory.url.pkgs=org.jboss.naming
위의 invoker는 web application context root이며 JBoss AS에 포함되어 있습니다.
사용자 삽입 이미지

해당 디렉토리의 web.xml을 보게 되면 아래의 내용이 세팅되어 있습니다.

<servlet>
        <servlet-name>JNDIFactory</servlet-name>
        <description>A servlet that exposes the JBoss JNDI Naming service stub
        through http. The return content is a serialized
        MarshalledValue containg the org.jnp.interfaces.Naming stub. This
        configuration handles requests for the standard JNDI naming service.
        </description>
        <servlet-class>org.jboss.invocation.http.servlet.NamingFactoryServlet</servlet-class>
        <init-param>
            <param-name>namingProxyMBean</param-name>
            <param-value>jboss:service=invoker,type=http,target=Naming</param-value>
        </init-param>
      <init-param>
         <param-name>proxyAttribute</param-name>
         <param-value>Proxy</param-value>
      </init-param>
      <load-on-startup>2</load-on-startup>
    </servlet>


<!-- ### Servlet Mappings -->
    <servlet-mapping>
        <servlet-name>JNDIFactory</servlet-name>
        <url-pattern>/JNDIFactory/*</url-pattern>
    </servlet-mapping>
크리에이티브 커먼즈 라이센스
Creative Commons License
2008/06/19 11:14 2008/06/19 11:14