Sometimes, when copying a big package from a distant location in /deploy, the file gets deployed before the file is acctually copied. Instead of copying it to /deploy, split the copying in two steps :
   - Copy the file to any localtion on the local filesystem that JBoss is using
   - Move the file from the temporary location to /deploy.(Move is atomic operation)

In linux, links may also be used.

때때로 /deploy 디렉토리의 원격으로부터 큰 용량의 WAR, EAR등을 카피할 때 JBoss에서 실제 카피가 모두 일어나기 전에 디플로이를 시도함으로써 문제가 발생할 수 있는 데 이 때 다음의 두 단계를 거쳐서 해결하면 됩니다.
   - JBoss가 사용하는 로컬 시스템에 파일을 먼저 복사합니다.
   - mv 명령을 이용하여 JBoss의 /deploy 디렉토리로 옮깁니다.

예> cp some_remote_location/my_big.ear /tmp
      mv /tmp/my_big.ear /home/jboss/server/default/deploy

There was a similar situation when using WebLogic Integration File Transport.
|
JBoss 의 JMS서버의 queue를 모니터링하는 JMX Code입니다. jsp파일로 되어 있으며 복사해서 사용하면 됩니다.

아래의 파일이 실행되어 모니터링되려면 $SERVER_HOME/deploy/jboss-messaging.sar/messaging-service.xml 파일의 다음의 attribute를 true로 바꿔야 합니다.
<attribute name="EnableMessageCounters">true</attribute>

그리고 메시지를 샘플링하는 주기를 적절하게 주면 됩니다.
<attribute name="MessageCounterSamplePeriod">5000</attribute>


<%@ page language="java" contentType="text/html; charset=UTF-8"   pageEncoding="UTF-8" import="javax.naming.*, java.util.*,javax.management.*,org.jboss.jms.server.destination.*,org.jboss.jmx.adaptor.rmi.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--meta http-equiv="refresh" content="5"-->
<link href="style.css" rel=stylesheet type="text/css">
<title>Insert title here</title>
</head>
 
<body leftmargin=15 topmargin=10>
<center><p>
<br>
 
<table width="600" cellpadding="7" cellspacing="0" border="1" bordercolordark="WHITE" bordercolorlight="BLACK">
<tr bgcolor=#E8EEEC>
<%
    String type = "Queue";
 
    Hashtable<String,String> env = new Hashtable<String,String>();
    String factory = "org.jboss.security.jndi.JndiLoginInitialContextFactory";
    env.put(Context.INITIAL_CONTEXT_FACTORY, factory);
    String url = "jnp://127.0.0.1:1099";
    env.put(Context.PROVIDER_URL, url);
    env.put(Context.SECURITY_CREDENTIALS, "admin");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    Context ctx = new InitialContext(env);
    RMIAdaptor server = (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor");
%>
 
<td align center>Queue Name</td>
<td align center>Total Count</td>
<td align center>Current Count</td>
<td align center>Consumer Count</td>
<td align center>Delivering Count</td>
</tr>
<tr>
<td align center>queue/A</td>
<%
    String queueName = "A";
 
    // Get the MBeanInfo for the JNDIView MBean
    String targetName = "jboss.messaging.destination:service=" + type + ",name=" + queueName;
    ObjectName objName = ObjectName.getInstance(targetName);
 
    QueueMBean queueMBean = (QueueMBean) MBeanServerInvocationHandler.newProxyInstance(server, objName, QueueMBean.class, false);
 
    int totalMessageCount = 0;
    int currentMessageCount = 0;
 
    totalMessageCount = queueMBean.getMessageCounter().getCount();
    currentMessageCount = queueMBean.getMessageCount();
%>
<td align center><%= totalMessageCount %></td>
<td align center><%= currentMessageCount %></td>
<td align center><%= queueMBean.getConsumerCount() %></td>
<td align center><%= queueMBean.getDeliveringCount() %></td>
</tr>
<tr>
<td align center>queue/B</td>
<%
    queueName = "B";
 
    // Get the MBeanInfo for the JNDIView MBean
    targetName = "jboss.messaging.destination:service=" + type + ",name=" + queueName;
    objName = ObjectName.getInstance(targetName);
 
    queueMBean = (QueueMBean) MBeanServerInvocationHandler.newProxyInstance(server, objName, QueueMBean.class, false);
 
    totalMessageCount = 0;
    currentMessageCount = 0;
 
    totalMessageCount = queueMBean.getMessageCounter().getCount();
    currentMessageCount = queueMBean.getMessageCount();
%>
<td align center><%= totalMessageCount %></td>
<td align center><%= currentMessageCount %></td>
<td align center><%= queueMBean.getConsumerCount() %></td>
<td align center><%= queueMBean.getDeliveringCount() %></td>
</tr>
</table>
|

 


이미지 출처: http://www.jboss.com/company/logos/jboss_inc_logo.jpg

JBoss.org 프로젝트


이미지 출처: http://www.redhat.com/g/logo_jbossorg.png

  • Server/Platform
    • JBoss Application Server
    • JBoss Web
    • JBoss Microcontainer
    • Mobicent
      • SIP Server
  • Integration
    • JBoss ESB
    • JBoss Messaging
    • Red Hat Messaging
    • Drools
    • JBoss jBPM
    • JBoss Transactions
    • JBoss Web Services
    • RESTEasy
    • DNA
    • JBoss IIOP
  • Tools
    • JBoss Tools
    • JBoss Profiler
    • JBoss JRunits
    • JSFUnit
    • JBoss Distributed Testing Framework
  • Web Interface
    • RichFaces
    • AJAX4JSF
    • Gravel
  • High Performace & Grid
    • JBoss Cache
    • JGroups
  • Portal
    • JBoss Portal
    • Portlets
  • Monitoring
    • Jopr
      • JBoss Operation Network
    • Embedded Jopr
      • JBoss AS Admin Console
  • Programming Model
    • JBoss Seam
    • JBoss EJB3
    • JBoss AOP
    • Hibernate
  • Security
    • JBoss Security and Identity Management
    • JBoss Federated SSO
  • Foundation
    • JBoss Serialization
    • JBoss Remoting

JBoss.com


이미지 출처: http://www.jboss.com/themes/jbosstheme/img/logo.gif

  • Platform
    • Application Platform
    • Portal Platform
    • Data Services Platform
    • SOA Platform
    • Communication Platform
  • Develop Tools
    • JBoss Developer Studio
  • Monitoring
    • JBoss Operation Network
  • Framework
    • Hibernate Framework
    • jBPM Framework
    • Rules Framework
    • Seam Framework
|

 

무료 오픈소스 소프트웨어

웹브라우저

비디오 플레이어

인터넷 메신저

이메일

RSS

DVD 동영상 추출

P2P 파일 공유

오피스

팟캐스팅

녹음

그래픽 편집

FTP

마인드맵

만득이네
|
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을 확인하면 수행된 시간에 대한 결과치를 확인할 수 있습니다.
|

놀새~'s Blog is powered by Daum & tistory