참고 : https://issues.jboss.org/browse/AS7-659
       http://blog.beany.co.kr/archives/3672
       http://www.mastertheboss.com/jboss-web/jbosswebserver/how-do-i-reload-dynamically-my-jsp-from-an-ear

JSP Compile 옵션 활성화


1. {JBoss Node}/configuration/standalone-ha.xml 파일을 수정
   Domain 방식일 경우 
{JBoss Node}/domains/master/configuration/domain.xml 파일을 수정.

2. 배포된 서버 profile을 찾아 아래처럼 변경
    
enable-welcome-root : 기본은 true
                                   false로 선언 시 context root 로 접근 시 welcome 페이지를 직접 web.xml 등으로 설정할 수 있다.

<?xml version='1.0' encoding='UTF-8'?> <server xmlns="urn:jboss:domain:1.5">      <profile>
 
        <subsystem xmlns="urn:jboss:domain:web:1.5" default-virtual-server="default-host" instance-id="${jboss.node.name}" native="false">
            <configuration>
                <jsp-configuration development="true" keep-generated="false" check-interval="1" modification-test-interval="1" recompile-on-fail="true" />
            </configuration>
            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
            <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
            <virtual-server name="default-host" enable-welcome-root="false">
                <alias name="localhost"/>
                <alias name="example.com"/>
            </virtual-server>
        </subsystem> 
    </profile>

</server> 


Note for JBoss AS 7 users: make sure you have set the development attribute to "true" in your jsp-configuration :

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
            <configuration>
                <jsp-configuration development="true" keep-generated="false" check-interval="1" modification-test-interval="1" recompile-on-fail="true"/>
            </configuration>
            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
            <virtual-server name="default-host" enable-welcome-root="true">
                <alias name="localhost"/>
                <alias name="example.com"/>
            </virtual-server>
</subsystem>


WildFly users, on the other hand, need to specify development mode to true in the jsp-config element:

<subsystem xmlns="urn:jboss:domain:undertow:1.1">
    <servlet-container name="default" default-buffer-cache="default" stack-trace-on-error="local-only">
    <jsp-config development="true" check-interval="1" modification-test-interval="1" recompile-on-fail="true"/>
</servlet-container><br></subsystem>


출처 : http://opennaru.tistory.com/109

JBoss EAP6 에서 server.log에서 애플리케이션에서 출력하는 로그 메세지가 보이지 않습니다. 톰캣에서는 메세지가 출력되는데 JBoss EAP6에서만 나오지 않습니다.


1. 동작환경

본 내용은 다음과 같은 환경을 전제로 작성되었습니다.

  • JBoss EAP6.X

2. 문제 

애플리케이션이나 모듈에 포함되어 있는 Log4J의 설정이 반영되지 않아 server.log 에 로그가 보이지 않는다.

3. 원인
JBoss EAP6에서는 기본적으로 자체의 로그 모듈을 사용하게 됩니다. 이 경우 배포 대상 애플리케이션에 포함된 Log4J 설정이 동작하지 않습니다.

4. 해결책 

이 문제를 해결하는 방법은 두 가지로 첫 번째는 JBoss 인스턴스 옵션으로 "org.jboss.as.logging.per-deployment=false"를 두는 방법이며, 두 번째는
"jboss-deployment-structure.xml" 를 이용하여 해당 로그 라이브러리를 Exclusion으로 선언하는 방법입니다.


4.1  org.jboss.as.logging.per-deployment=false 를 이용하는 방법

JBoss 인스턴스 시작 옵션에 시스템 프로퍼티로 시스템 프롭퍼티에 org.jboss.as.logging.per-deployment=false 를 설정합니다.
이 방법은 JBoss 에서 각 배포 대상에 대하여 JBoss 자체의 로거를 사용하지 않게 하는 것입니다.  

  • standalone 에서는 
-Dorg.jboss.as.logging.per-deployment=false


  • 도메인 모드에서는
 <server name="PMS" group="pms_server_group" auto-start="false">
            <system-properties>
                   <property name="org.jboss.as.logging.per-deployment" value="false"/>
            </system-properties>
</server>



4.2 jboss-deployment-structure.xml 에서 exclusion으로 선언하는 방법 

  • EAR의 경우 XX.ear/META-INF/jboss-deployment-structure.xml
  • WAR의 경우 XX.war/WEB-INF/jboss-deployment-structure.xml

<jboss-deployment-structure>
  <deployment>
    <exclusions>
        <module name="org.apache.log4j" />
        <module name="org.apache.commons.logging" />
    </exclusions>
  </deployment>
</jboss-deployment-structure>


- logback 설정 시 샘플

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<!--  
                        스프링 프레임워크 사용 시 org.apache.commons.logging 은 필수로 해줘야 함
-->
                        <module name="org.apache.commons.logging" />
<module name="org.slf4j" />
<module name="org.slf4j.ext" />
<module name="org.slf4j.impl" />
<module name="org.slf4j.jcl-over-slf4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>


5. References


- jboss 설정에 console 부분은 주석처리 한다.

 <subsystem xmlns="urn:jboss:domain:logging:1.5">
            <!--
            <console-handler name="CONSOLE">
                <level name="INFO"/>
                <formatter>
                    <named-formatter name="COLOR-PATTERN"/>
                </formatter>
            </console-handler>
            -->

            <periodic-rotating-file-handler name="FILE" autoflush="true">
                <formatter>
                    <named-formatter name="PATTERN"/>
                </formatter>
                <file relative-to="jboss.server.log.dir" path="server/server.log"/>
                <suffix value=".yyyy-MM-dd"/>
                <append value="true"/>
            </periodic-rotating-file-handler>
            <logger category="com.arjuna">
                <level name="WARN"/>
            </logger>
            <logger category="org.apache.tomcat.util.modeler">
                <level name="WARN"/>
            </logger>
            <logger category="org.jboss.as.config">
                <level name="DEBUG"/>
            </logger>
            <logger category="sun.rmi">
                <level name="WARN"/>
            </logger>
            <logger category="jacorb">
                <level name="WARN"/>
            </logger>
            <logger category="jacorb.config">
                <level name="ERROR"/>
            </logger>
            <logger category="org.apache.catalina.core.AprLifecycleListener">
                <level name="DEBUG"/>
            </logger>
            <logger category="org.jboss.as.controller.management-deprecated">
                <level name="OFF"/>
            </logger>
            <logger category="org.jboss.as.clustering.web.infinispan">
                <level name="TRACE"/>
            </logger>
            <root-logger>
                <level name="INFO"/>
                <handlers>
                    <!--
                    <handler name="CONSOLE"/>
                    -->
                    <handler name="FILE"/>
                </handlers>
            </root-logger>
            <formatter name="PATTERN">
                <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
            </formatter>
            <formatter name="COLOR-PATTERN">
                <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
            </formatter>
</subsystem>

 

참고 : http://linuxism.tistory.com/558

/favicon.ico HTTP/1.1" 404 에러 없애는 방법

apache 를 설치한뒤에 access.log 와 error.log 에 귀찮게도 자주 나오는 favicon.ico 에러를 안나오게 하는 방법에 대해 정리하겠습니다. 별로 안어려우니 따라해보시면 됩니다.


(1)  error.log 상에 favicon.ico 로그 안찍히게 하는 방법.

error.log 에러로그

=> [Wed Aug 24 11:10:52 2011] [error] [client 10.225.23.118] File does not exist: /jboss/jboss-as-web-7.0.0.Final/standalone/deployments/test.war/favicon.ico


* 설정파일 : httpd.conf

* 설정방법은 아래와 같다. (error.log 아래에 붙이면 된다.)

Redirect 404 /favicon.ico

<Location /favicon.ico>

   ErrorDocument 404 "No favicon"

</Location>


(2) access.log 상에 favicon.ico 로그 안찍히게 하는 방법

* access.log 에러로그  => /favicon.ico HTTP/1.1" 404


설정파일 : httpd.conf

* 설정부분은 아래와 같으며, access.log 설정부분에 충돌안나게 변경하면 된다.

SetEnvIf Request_URI "favicon.ico" do_not_log

CustomLog logs/access.log common env=!do_not_log


간단한거니 불필요한 에러는 안나게 해버리세요.. 열공하세용.


출처 - http://kletgdgo.blog.me/90121425629


===================================================================================


favicon.ico 만들기

[출처] favicon.ico 만들기|작성자 엔젤반


웹 사이트 루트 디렉터리에 favicon.ico라는 이름의 아이콘 파일을 올려두면, 사용자가 즐겨찾기(Favorites)에 추가할 때 아이콘이 자동으로 그 사이트의 로고로 바뀌도록 할 수 있다.

 

다시 이야기하여 사용자가 어떤 페이지를 즐겨찾기에 추가하면 아이콘을 자동으로 다운로드하여 바꾸어 주는 기능이다.

 

웹 사이트의 루트 디렉터리에 favicon.ico라는 이름의 아이콘 파일을 올려두기만 하면 됨.

단, 이 기능은 Internet Explorer 5 이상에서 지원한다.

 

favicon.ico 파일을 직접 지정하기

개인 홈페이지처럼 루트 디렉터리에 직접 favicon.ico 파일을 올려두기 곤란하거나 다른 이름 또는 다른 위치의 아이콘 파일을 지정하고 싶다면 다음과 같이 할 수 있다.

<LINK REL="SHORTCUT ICON" href="/path/logo.ico">

위와 같은 형식으로 LINK element를 사용할 수 있으며, 웹 페이지 Header(<head>...</head>)에 가볍게 적어줄 수 있다.

<LINK REL="SHORTCUT ICON" href="./galaxy.ico"> 
<LINK REL="SHORTCUT ICON" href="http://www.i-biznet.com/favicon.ico">

아이콘 파일은 비트맵 이미지이면서 고유의 파일 포맷을 가지고 있다. 16x16, 32x32 픽셀 등으로 크기를 선택할 수 있으며, 256 색상 이상을 사용할 수 있지만, 16 색상만 사용하는 것이 기본이다. favicon.ico 파일은 가능한 16x16 픽셀, 16 색상의 아이콘 파일로 만드는 것이 좋다.

문제는 아이콘 파일을 직접 만드는 것인데, 아이콘 만들기 도구의 선택부터 생각만큼 쉽지 않다. Favicon.com에서는 Java로 구현한 아이콘 만들기 프로그램을 온라인에서 직접 실행할 수 있도록 하여 이러한 고민을 어느 정도 해결해주고 있다.

Favicon Icon Generator는 16x16 픽셀의 아이콘을 16 색상으로 제작할 수 있는 간단한 도구이다. 색상 선택, 칠하기/지우기, Zoom In/Out 등 꼭 필요한 기능 정도만 제공하고 있지만, 아이콘 파일을 만드는데 크게 부족함이 없다.


http://favicon.com/ 페이지에 들어가면 맨 윗줄에 Favicon Maker가 있다.

링크를 누르면

http://favigen.com/ 페이지로 이동하는데

이곳에서

1) Upload Source Image: 원본소스 이미지 파일을 올리고
2) Choose Favicon Size: 파비콘 사이즈를 선택하고
3) Create Favicon 버튼을 누르면 파비콘이 생성된다.
파일이 생성된 후에 Download your favicon 버튼을 누르면 파일을 다운받을 수 있다.
이것을 홈페이지 index.html이 있는 위치에 넣으면 된다.


Http Response 에 아래 값을 넣어주면 됨

Key : X-Frame-Options
Value : SAMEORIGIN

X-Frame-Options 옵션 값

 DENY

 해당 페이지는 frame을 표시할 수 없다. 

 SAMEORIGIN 

 해당 페이지와 동일한 orgin에 해당하는 frame만 표시할 수 있다.

 ALLOW-FROM uri 

 해당 페이지는 지정된 orgin에 해당하는 frame만 표시할 수 있다.


X-Frame-Options 는 그 명칭에서도 알 수 있듯이 확장 해더이기때문에 모든 브라우저가 해당 옵션에 대해 동작하는것은 아니다.
크롬 4.1 , IE 8 , 오페라 10.5 , 사파리 4.0 , 파이어폭스 3.6.9 이상에서는 DENY , SAMEORIGIN 이 적용되며, ALLOW-FROM 은 각 브라우저 마다 지원 현황이 다르다.


* Apache 설정
환경파일 중 해당태그 (<Directory>, <Location>, <Files>, <VirtualHost>) 안에 아래 코드 추가

Header always append X-Frame-Options SAMEORIGIN 


* Java Application

response.addHeader("X-Frame-Options", "SAMEORIGIN"); 


* Application Filter

- web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app id="WebApp_ID" version="2.4"
    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/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>OWASP ClickjackFilter</display-name>
    <filter>
        <filter-name>ClickjackFilterDeny</filter-name>
        <filter-class>org.owasp.filters.ClickjackFilter</filter-class>
        <init-param>
            <param-name>mode</param-name>
            <param-value>DENY</param-value>
        </init-param>
    </filter>
    
    <filter>
        <filter-name>ClickjackFilterSameOrigin</filter-name>
        <filter-class>org.owasp.filters.ClickjackFilter</filter-class>
        <init-param>
            <param-name>mode</param-name>
            <param-value>SAMEORIGIN</param-value>
        </init-param>
    </filter>
    
    <!--  use the Deny version to prevent anyone, including yourself, from framing the page -->
    <filter-mapping> 
        <filter-name>ClickjackFilterDeny</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <!-- use the SameOrigin version to allow your application to frame, but nobody else
    <filter-mapping> 
        <filter-name>ClickjackFilterSameOrigin</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    -->
    
</web-app>

 
- source

package org.owasp.filters;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

public class ClickjackFilter implements Filter 
{

    private String mode = "DENY";
    	
    /**
     * Add X-FRAME-OPTIONS response header to tell IE8 (and any other browsers who
     * decide to implement) not to display this content in a frame. For details, please
     * refer to http://blogs.msdn.com/sdl/archive/2009/02/05/clickjacking-defense-in-ie8.aspx.
     */
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletResponse res = (HttpServletResponse)response;
        res.addHeader("X-FRAME-OPTIONS", mode );			
        chain.doFilter(request, response);
    }
    
    public void destroy() {
    }
    
    public void init(FilterConfig filterConfig) {
        String configMode = filterConfig.getInitParameter("mode");
        if ( configMode != null ) {
            mode = configMode;
        }
    }
    
}


* javascript

<script>

if(top != window) {
  top.location = window.location
}
</script>


참고 : http://www.techstacks.com/howto/disable-http-methods-in-tomcat.html

참고 : http://tyboss.tistory.com/entry/Tomcat-Authorization-Authentication-webxml


Tomat 환경파일 또는 Application의 web.xml에 아래 코드 추가 후 Restart

// Sample Security Constraint
<security-constraint>
  <web-resource-collection>
      <web-resource-name>restricted methods</web-resource-name>
      <url-pattern>/*</url-pattern>
      <http-method>PUT</http-method>
      <http-method>POST</http-method>
      <http-method>DELETE</http-method>
      <http-method>OPTIONS</http-method>
      <http-method>TRACE</http-method>
  </web-resource-collection>
  <auth-constraint />
</security-constraint> 


http-method 에 선언한 method 는 접근이 제한된다.

HTTP Method 목록 : http://ko.wikipedia.org/wiki/HTTP

(OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT)


Apache 환경파일 중 해당 태그(<Directory>, <Location>, <Files>, <VirtualHost>) 안에 아래 설정정보 추가 후 Apache Restart

# rewrite 모듈 로드가 안 된 경우 주석 해제
# LoadModule rewrite_module modules/mod_rewrite.so
<IfModule mod_rewrite.c>
    RewriteEngine On

    # GET, POST를 제외하고 모두 405 페이지로 이동
    RewriteCond %{REQUEST_METHOD} !^(GET|POST)
    RewriteRule .* - [R=405,L] 
</IfModule>


HTTP Method 목록 : http://ko.wikipedia.org/wiki/HTTP

(OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT)



(참고)
* SSL 암호 스위트 지원 제한

SSLCipherSuite HIGH:MEDIUM:!MD5!EXP:!NULL:!LOW:!ADH

출처 : http://opennaru.tistory.com/44


레드햇 JBoss EAP (Enterprise Application Platform) 6 제품 관련 비교 설명

 


JBoss의 의미는 무엇인가요?
JBoss 는 1999년에 Mark Fleury가  EJB컨테이너를 오픈소스로 개발하기 위해 EJBOSS(Enterprise Java Beans Open Source Software)라는 이름으로 시작한 프로젝트였지만 SUN과의 상표권 문제 때문에 앞의 E를 빼고 현재의 JBoss라는 이름이 되었습니다.


JBoss EAP6는 무엇인가요? 
JBoss EAP 6는 개방형 표준을 기반으로 개발된  오픈소스 미들웨어 플랫폼으로 Java EE 6 인증을 받은 웹 애플리케이션 서버 제품입니다. 엔터프라이즈 환경에서 미들웨어가 갖추어야 하는 대용량 트랜잭션(Transaction), 고가용성을 위한 클러스터링, 메시징, 분산 캐싱, 고성능 보장 등의 기술들을 제공합니다.

JBoss EAP 6 버전은 오픈소스 커뮤니티 프로젝트의 결과물을 이용하여 제품화 됩니다. 다음 URL에서 JBoss EAP 6가 커뮤니티의 어떤 버전을 사용하고 있는지 확인할 수 있다. 다음의 URL ( https://access.redhat.com/site/articles/112673 ) 에서 JBoss EAP 버전 별 구성 컴포넌트에 대한 상세 내용을 확인할 수 있습니다. 


JBoss AS 제품을 사용 중인데 레드햇이 직접 기술 지원해 주시나요?
! 아니오. 레드햇은 JBoss EAP 제품에 대해서 만 기술 지원이 가능합니다. 무료로 사용하고 계신 JBoss AS ( 최신의 Wildfly) 제품에 대해서는 기술 지원을 받으실 수 없습니다.  기술 지원 문제로 JBoss AS 제품에서 JBoss EAP 제품으로 전환을 고려 하신 다면 오픈나루 ( service@opennaru.com ) 나 레드햇 ( customerservice-kr@redhat.com ) 에 문의해 주세요.


JBoss EAP6와 JBoss AS7  제품의 차이점은 무엇인가요?
JBoss EAP6 은 유상 제품으로 JBoss AS7 이라는 오픈소스 커뮤니티 제품을 
Red Hat 에서 추가 테스트와 검증 등을 통하여 안정성, 성능 그리고 보안 수준을 높인 기업용 오픈소스 애플리케이션 서버입니다.
즉 JBoss EAP6 와 JBoss AS7은 소스 코드 수준에서 거의 동일한 제품으로 벤더에 의한 유료 기술 지원을 받을 것인지 아니면 무료로 사용자 스스로 제품 문제들을 해결할 것 인지가 가장 큰 차이점입니다.  ( ※ JBoss.org 에서 다운로드 할 수 있는 JBoss AS 나 Wildfly 등의 제품은 레드햇에서 기술 지원되지 않으니 주의해 주십시오. )

JBoss AS7 제품은 커뮤니티에서 주로 기능 개발을 목적으로 하는 제품으로 기능 개발 중에 발생된 버그는 수정되어 릴리즈에 포함될 수 있지만, 버그 수정이나 지원 환경에 대한 검증을 목적으로 한 유지 보수와 보안 업데이트는 없습니다. 즉 주요 기능을 포함한 메이저 버전 업그레이드는 있지만 보안이나 버그 패치 등의 유지보수 차원의 릴리즈는 없기 때문에 커뮤니티 버전에서 버그 수정이 필요하다면 직접 코드 수정, 포팅 그리고 빌드해야 합니다.

JBoss EAP6 제품은 상용 서비스 제품으로 기능 개발 중심의 커뮤니티 버전과는 달리 고객이 요청한 버그 수정 또는 보안 업데이트 등의 안정성과 품질 그리고 기술 지원 환경에 대한 호환성 테스트를 거쳐 출시하는 엔터프라이즈 제품입니다. 

 
JBoss 커뮤니티 제품
JBoss 엔터프라이즈 제품
사이트
AS7(jboss.org)/Wildfly8 (wildfly.org)
redhat.com/jboss.com
라이선스 비용
없음
없음
기술지원
사용자 스스로 기술 지원
벤더 기술 지원
소스 코드 접근
완전한 접근 가능
완전한 접근 가능
대상
누구나
레드햇 서브스크립션 고객
개발
오픈 소스 프로젝트 커뮤니티
오픈 소스 프로젝트 커뮤니티 및 JBoss EAP 제품화 팀
개선 및 향상
커뮤니티의 요구에 따른 임시 또는 실험적인 소프트웨어 변경
주요 릴리스, 소규모 릴리스, 패치 및 마이그레이션 도구를 포함한 구조화된 릴리스 과정
매뉴얼
프로젝트 컴포넌트에 따라 다양
전문적인 소프트웨어 설명서
품질
기능 검증을 위한 테스팅 위주
매우 다양한 테스트 등이 통합된 우수한 품질
  JBoss 커뮤니티 제품과 엔터프라이즈 제품의 차이점


JBoss 와 Wildfly 의 차이점은 무엇인가요?
! JBoss AS 라는 의미가 JBoss Application Server 의 약자이며 많은 경우 JBoss 로 표기하여 Red Hat 의 상용 오픈소스 제품인 JBoss EAP 와 혼돈을 야기 했습니다. 이러한 혼란을 해소하기 위하여 JBoss AS8 버전부터는 기존의 ‘JBoss’라는 이름을 ‘Wildfly’ 라는 이름으로 변경하기로 결정했으며, 현재는 jboss.org 가 아닌 wildfly.org 커뮤니티에서 ‘wildfly8’이라는 이름으로 오픈소스 프로젝트를 진행하고 있습니다.


JBoss EAP6 제품은 레드햇 리눅스만 지원하나요?
아 니오, JBoss EAP6 는 Pure Java 로 개발된 애플리케이션 서버 제품으로 대부분의 Java 런타임을 지원하고 있으며, 레드햇 리눅스 이외에도 마이크로소스트 윈도우즈 서버와 유닉스 서버를 지원합니다. JBoss EAP6 버전에서 지원 환경은 아래의 URL에서 확인해 주세요. 

 


References




출처 : http://hmjkor.tistory.com/408

참고 : https://tomcat.apache.org/tomcat-8.0-doc/jndi-datasource-examples-howto.html

apache tomcat 5.5 이후 버전에서의 Context 생성 방법입니다.


server.xml 파일을 열게 되면 xml Tag가 Service라는 태그의 속성명 name을 찾습니다.

일반적으로는  <Service name="Catalina"> 이렇게 되어 있습니다.


먼저 context를 만들기 위한 폴더를 생성합니다.

service 태그의 name값인 Catalina 폴더를 만들고 다시 그 안에 localhost 라는 폴더를 만듭니다.

최종적으로는 위에 내용대로라면 톰캣경로/conf/Catalina/localhost가 되겠네요


그럼 이제 이하위에 파일을 생성하시면 되는데 파일은 xml 형식입니다.

root Context는 ROOT.xml을 만드시면 되고 기타 context는 컨텍스트명.xml파일로 만드시면 됩니다.


파일이 생성이 되었으면 이제 관련 설정을 파일에 추가하면 됩니다.

test라는 컨텍스트를 만들게 되면 아래와 같은 형식이 되겠습니다.


server.xml

<?xml version='1.0' encoding='utf-8'?>
<Context path="/test"
         docBase="/home/test/web"
         debug="0"
         reloadable="true"
         crossContext="true">

<Valve className="org.apache.catalina.valves.AccessLogValve"
            directory="/home/test/logs/access"
            prefix="access."
            suffix=".log"
            pattern="common"
            fileDateFormat="yyyy-MM-dd"
            resolveHosts="false"/>
    <Resource name="jdbc/my" auth="Container"
                        type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"
                        url="jdbc:mysql://[ip]:[port]/[db명]?zeroDateTimeBehavior=convertToNull"
                        username="[username]" password="[password]"
                        loginTimeout="10" maxActive="50"
                        maxIdle="10" maxWait="-1" />
</Context> 


<Resource name="jdbc/oracle" auth="Container" type="javax.sql.DataSource"
    driverClassName="oracle.jdbc.OracleDriver"
    url="jdbc:oracle:thin:@DB_IP:DB_PORT:DB_SID"
    username="아이디" password="비밀번호" maxTotal="20" maxIdle="10" />




Note that the resource name (here, jdbc/EmployeeDB) must match the value specified in the web application deployment descriptor.

This example assumes that you are using the HypersonicSQL database JDBC driver. Customize the driverClassName and driverName parameters to match your actual database's JDBC driver and connection URL.

The configuration properties for Tomcat's standard data source resource factory (org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory) are as follows:

  • driverClassName - Fully qualified Java class name of the JDBC driver to be used.
  • username - Database username to be passed to our JDBC driver.
  • password - Database password to be passed to our JDBC driver.
  • url - Connection URL to be passed to our JDBC driver. (For backwards compatibility, the property driverName is also recognized.)
  • initialSize - The initial number of connections that will be created in the pool during pool initialization. Default: 0
  • maxTotal - The maximum number of connections that can be allocated from this pool at the same time. Default: 8
  • minIdle - The minimum number of connections that will sit idle in this pool at the same time. Default: 0
  • maxIdle - The maximum number of connections that can sit idle in this pool at the same time. Default: 8
  • maxWaitMillis - The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception. Default: -1 (infinite)

Some additional properties handle connection validation:

  • validationQuery - SQL query that can be used by the pool to validate connections before they are returned to the application. If specified, this query MUST be an SQL SELECT statement that returns at least one row.
  • validationQueryTimeout - Timeout in seconds for the validation query to return. Default: -1 (infinite)
  • testOnBorrow - true or false: whether a connection should be validated using the validation query each time it is borrowed from the pool. Default: true
  • testOnReturn - true or false: whether a connection should be validated using the validation query each time it is returned to the pool. Default: false

The optional evictor thread is responsible for shrinking the pool by removing any connections which are idle for a long time. The evictor does not respect minIdle. Note that you do not need to activate the evictor thread if you only want the pool to shrink according to the configured maxIdle property.

The evictor is disabled by default and can be configured using the following properties:

  • timeBetweenEvictionRunsMillis - The number of milliseconds between consecutive runs of the evictor. Default: -1 (disabled)
  • numTestsPerEvictionRun - The number of connections that will be checked for idleness by the evictor during each run of the evictor. Default: 3
  • minEvictableIdleTimeMillis - The idle time in milliseconds after which a connection can be removed from the pool by the evictor. Default: 30*60*1000 (30 minutes)
  • testWhileIdle - true or false: whether a connection should be validated by the evictor thread using the validation query while sitting idle in the pool. Default: false

Another optional feature is the removal of abandoned connections. A connection is called abandoned if the application does not return it to the pool for a long time. The pool can close such connections automatically and remove them from the pool. This is a workaround for applications leaking connections.

The abandoning feature is disabled by default and can be configured using the following properties:

  • removeAbandoned - true or false: whether to remove abandoned connections from the pool. Default: false
  • removeAbandonedTimeout - The number of seconds after which a borrowed connection is assumed to be abandoned. Default: 300
  • logAbandoned - true or false: whether to log stack traces for application code which abandoned a statement or connection. This adds serious overhead. Default: false

Finally there are various properties that allow further fine tuning of the pool behaviour:

  • defaultAutoCommit - true or false: default auto-commit state of the connections created by this pool. Default: true
  • defaultReadOnly - true or false: default read-only state of the connections created by this pool. Default: false
  • defaultTransactionIsolation - This sets the default transaction isolation level. Can be one of NONEREAD_COMMITTEDREAD_UNCOMMITTEDREPEATABLE_READSERIALIZABLE. Default: no default set
  • poolPreparedStatements - true or false: whether to pool PreparedStatements and CallableStatements. Default: false
  • maxOpenPreparedStatements - The maximum number of open statements that can be allocated from the statement pool at the same time. Default: -1 (unlimited)
  • defaultCatalog - The name of the default catalog. Default: not set
  • connectionInitSqls - A list of SQL statements run once after a Connection is created. Separate multiple statements by semicolons (;). Default: no statement
  • connectionProperties - A list of driver specific properties passed to the driver for creating connections. Each property is given as name=value, multiple properties are separated by semicolons (;). Default: no properties
  • accessToUnderlyingConnectionAllowed - true or false: whether accessing the underlying connections is allowed. Default: false

For more details, please refer to the commons-dbcp documentation.




만약 다른 도메인이나 서브 도메인이 생성되어야 한다면

server.xml에 신규 HOST를 추가한다.

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
    기존 도메인 내용이 있음
</Host>
<!-- 신규로 추가되는 서브 도메인 -->
<Host name="test.anaconda.pe.kr" appBase="webapps" unpackWARs="true" autoDeploy="true">
</Host>



그리고 /conf/Catalina/폴더 아래에 test.anaconda.pe.kr라는 폴더를 만든다.

/conf/Catalina/test.anaconda.pe.kr와 같은 폴더를 가진다.

그리고 그 아래에 ROOT.xml파일을 만들고 context 정보를 넣어주면 된다.



# setDomain.sh

#!/bin/bash

SYSTEM_ID=`echo ${PWD##*/} | sed s/domain//g`
DOMAIN_NAME=webDomain
DOMAIN_HOME=/was/domains/${DOMAIN_NAME}
LOG_DIR=/log/weblogic/${SYSTEM_ID}/${SERVER_NAME}

ADMIN_URL="t3://host명:12100"
DEFAULT_LOG_PFX="${LOG_DIR}/stdout.log."
export ADMIN_URL DEFAULT_LOG_PFX


# WAS Options
USER_MEM_ARGS="${USER_MEM_ARGS} -D${SERVER_NAME}"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dweblogic.system.BootIdentityFile=${DOMAIN_HOME}/boot.properties"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dweblogic.MuxerClass=weblogic.socket.PosixSocketMuxer"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dweblogic.SelfTuningThreadPoolSizeMin=50"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dweblogic.PrintStackTraceInProduction=true"
USER_MEM_ARGS="${USER_MEM_ARGS} -Doracle.jdbc.fanEnabled=false"

# GC Options
USER_MEM_ARGS="${USER_MEM_ARGS} -XX:+UseG1GC"
USER_MEM_ARGS="${USER_MEM_ARGS} -XX:+PrintGCDetails"
USER_MEM_ARGS="${USER_MEM_ARGS} -XX:+PrintGCTimeStamps"
USER_MEM_ARGS="${USER_MEM_ARGS} -verbose:gc"
USER_MEM_ARGS="${USER_MEM_ARGS} -Xloggc:${LOG_DIR}/gc/${SERVER_NAME}_GC.log.`date '+20%y%m%d_%H%M%S'`"

# Dump Options
USER_MEM_ARGS="${USER_MEM_ARGS} -XX:+HeapDumpOnOutOfMemoryError"
USER_MEM_ARGS="${USER_MEM_ARGS} -XX:HeapDumpPath=${DOMAIN_HOME}"

# ETC Options
USER_MEM_ARGS="${USER_MEM_ARGS} -Djava.net.preferIPv4Stack=true"
USER_MEM_ARGS="${USER_MEM_ARGS} -Djava.security.egd=file:///dev/urandom"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dfile.encoding=UTF-8"

exprot USER_MEM_ARGS



# startWeb01_i01.sh

#!/bin/bash
SERVER_NAME=`echo $0 | sed 's/.sh//g' | sed 's/.\///g' | sed 's/start//g'`

. ./setDomain.sh

USER_MEM_ARGS="-D${SERVER_NAME} -Xms1g -Xmx1g -XX:+HeapDumpOnOutOfMemoryError ${USER_MEM_ARGS}"

JAVA_OPTIONS="${JAVA_OPTIONS} -Dfile.encoding=UTF-8"

export USER_MEM_ARGS JAVA_OPTIONS

nohup ./bin/startManagedWebLogic.sh ${SERVER_NAME} ${ADMIN_URL} 2>&1 | ./LOGS.pl ${DEFAULT_LOG_PFX} &

echo "tail -f ${DEFAULT_LOG_PFX}`date +%Y%m%d`"

# LOGS.pl

#!/usr/bin/perl

$TRUE=1;
$FALSE=0;
$DEBUG=$FALSE;

$DEFAULT_LOG_PFX=$ARGV[0];

$logPfx=$DEFAULT_LOG_PFX;
$ignoreConsole=$FALSE;

while($aLine = <STDIN>) {
    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
    $logFile=$logPfx.sprintf("%04d%02d%02d",($year+1900),($mon+1),$mday,$hour,$min,$sec);
    open(logH,">> $logFile");
    # Auto flash ON
    select((select(logH),$|=1)[0]);
    
    # use IO::Handle;
    
    # logH->autoflush($TRUE);
    
    print logH $aLine;
    
    if($ignoreConsole) {
        print $aLine;
    }
    
    close(logH);
}


# stopWeb01_i01.sh

#!/bin/bash

SERVER_NAME=`echo $e | sed 's/.sh//g' | sed 's/.\///g' | sed 's/stop//g'`
PROCESS_ID=`ps -ef | grep java | grep -v grep | grep 사용자계정ID | grep -w D${SERVER_NAME} | awk '{print $2}'`

ps -ef | grep java | grep -v grep | grep 사용자계정ID | grep -w D${SERVER_NAME} | awk '{print $2}' | xargs kill -9
echo "#####" ${SERVER_NAME} "==" ${PROCESS_ID} "== kill"




==========================================================================================

Weblogic 12C

* /WEB-INF/weblogic.xml 설명
URL : https://docs.oracle.com/middleware/12212/wls/WBAPP/weblogic_xml.htm


- weblogic.xml 샘플

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
    <context-root>/</context-root>
    <session-descriptor>
        <persistent-store-type>replicated_if_clustered</persistent-store-type>
        <sharing-enabled>true</sharing-enabled>
    </session-descriptor>

    <container-descriptor>
        <prefer-application-packages>
           <package-name>org.slf4j</package-name>
           <package-name>log4j</package-name>
        </prefer-application-packages>
       
        <prefer-application-resources>
            <resource-name>com.sun.faces.*</resource-name>
        </prefer-application-resources>
    </container-descriptor>

</weblogic-web-app>



* /META-INF/application.xml 설명
URL : https://docs.oracle.com/middleware/1212/wls/WLPRG/app_xml.htm




* Command Deploy

- deploy (war)

java -cp "C:\Oracle\Middleware\Oracle_Home\wlserver\server\lib\weblogic.jar" \
    weblogic.Deployer -adminurl t3://127.0.0.1:7001 \
    -username weblogic -password weblogic1 \
    -deploy C:\dev\workspaces\eclipse-jee-2018-09-win32-x86_64\pubfreq\build\libs\pubfreq.war


- deploy (folder)

java -cp "C:\Oracle\Middleware\Oracle_Home\wlserver\server\lib\weblogic.jar" \
    weblogic.Deployer -adminurl t3://127.0.0.1:7001 \
    -username weblogic -password weblogic1 \
    -deploy C:\dev\workspaces\eclipse-jee-2018-09-win32-x86_64\pubfreq\build\libs\pubfreq


- undeploy

java -cp "C:\Oracle\Middleware\Oracle_Home\wlserver\server\lib\weblogic.jar" \
    weblogic.Deployer -adminurl t3://127.0.0.1:7001 \
    -username weblogic -password weblogic1 -undeploy -name pubfreq




* 아래와 같은 오류 발생 시

<2019. 1. 8 오후 10시 04분 52초 KST> <Error> <javax.enterprise.resource.webcontainer.jsf.config> <BEA-000000> <Unknow type constant pool 18 at position 14>
<2019. 1. 8 오후 10시 04분 52초 KST> <Error> <javax.enterprise.resource.webcontainer.jsf.config> <BEA-000000> <Unknow type constant pool 0 at position 15>
<2019. 1. 8 오후 10시 04분 52초 KST> <Error> <javax.enterprise.resource.webcontainer.jsf.config> <BEA-000000> <Unknow type constant pool 0 at position 16>
<2019. 1. 8 오후 10시 04분 52초 KST> <Error> <javax.enterprise.resource.webcontainer.jsf.config> <BEA-000000> <Unknow type constant pool 0 at position 17>
<2019. 1. 8 오후 10시 04분 52초 KST> <Error> <javax.enterprise.resource.webcontainer.jsf.config> <BEA-000000> <Unknow type constant pool 81 at position 18>
<2019. 1. 8 오후 10시 04분 52초 KST> <Error> <javax.enterprise.resource.webcontainer.jsf.config> <BEA-000000> <Unknow type constant pool 15 at position 81>
<2019. 1. 8 오후 10시 04분 52초 KST> <Error> <javax.enterprise.resource.webcontainer.jsf.config> <BEA-000000> <Unknow type constant pool 97 at position 84>


-  "com.sun.faces.*" 부분 추가

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">

    <container-descriptor>
        <prefer-application-resources>
                <resource-name>javax.faces.*</resource-name>
                <!-- 이 부분 추가 -->
                <resource-name>com.sun.faces.*</resource-name>
                <resource-name>com.bea.faces.*</resource-name>
            </prefer-application-resources>
    </container-descriptor>

</weblogic-web-app>




=========================================================================================================


다운로드 : http://www.oracle.com/
               http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-for-dev-1703574.html

참고 : http://antop.tistory.com/132
         http://blog.naver.com/jadin1/70117413544  (Admin 서버외의 Managed Server 구성 )

1. zip 파일 버전을 다운로드 후 압축을 해제한다.

 

2. 시스템 PATH 설정을 한다.
MW_HOME=압축해제 폴더

 

3. cmd 에서 실행

// 웹로직 설정 프로그램 실행
d:\weblogic>configure.cmd

// 웹로직 환경 적용
%MW_HOME%\wlserver\server\bin\setWLSEnv.cmd

// 도메인 생성
%MW_HOME%/wlserver/common/bin/config.cmd


4. 콘솔 한글 깨짐 수정 (UTF-8 설정)
웹로직 폴더\user_projects\domains\서버 도메인\bin\setDomainEnv.cmd 에서 UTF-8 부분 추가

set JAVA_PROPERTIES=-Dplatform.home=%WL_HOME% \
    -Dwls.home=%WLS_HOME% -Dweblogic.home=%WLS_HOME% \
    -Dwli.home=%WLI_HOME% -Dfile.encoding=UTF-8 -Dfile.client.encoding=UTF-8



* WebLogic 콘솔(관리자) URL
    http://localhost:7001/console/

* WebLogic Port 변경
    웹로직 폴더\user_projects\domains\서버 도메인\config\config.xml 에서 빨간색 부분 추가

<server>
    <name>AdminServer</name>
    <listen-port>7000</listen-port>
    <listen-address/>
  </server> 


* 도메인 삭제
1. Domain 디렉토리 삭제
    rm $WLS_HOME/user_projects/domains/$DOMAIN_NAME

2. nodemanager.domains 파일 수정
    $WLS_HOME/wlserver/common/nodemanager/nodemanager.domains 파일을 수정
    삭제한 domain의 이름으로 되어 있는 property를 삭제

3. domain-registry.xml
    $WLS_HOME/domain-registry.xml 파일을 수정
    Domain 이름이 없으니 해당되는 경로만 삭제

* 2개 이상의 도메인 실행 설정
1. 위에 WebLogic Port 변경 부분에서 포트를 도메인별로 할당한다.
2. $WLS_HOME/user_project/domains/$DOMAIN_NAME/bin/setDomainEnv.cmd에서 빨간색 부분 포트 변경

if "%DEBUG_PORT%"=="" (
    set DEBUG_PORT=8453
)

 

출처 : http://blog.nekrs.com/195


Tomcat 서버에서 로그인 페이지처럼 특정 페이지는 HTTPS를 이용하고, 나머지 페이지는 HTTP를 사용하려고 한다. 이때 HTTPS->HTTP로 이동하면서 세션은 공유되지 않는 문제가 있다. 다음은 이 문제를 해결하는 방법 중 하나이다.

RequestWrapper 클래스를 하나 만듭니다. 이 클래스는 HTTPS 요청일 경우 쿠키에 세션 정보를 조작하는 역할을 합니다.

 public class HttpsRequestWrapper extends HttpServletRequestWrapper{
 private HttpServletResponse response = null;
 public HttpsRequestWrapper (HttpServletRequest request) {
  super(request);
 }
 public void setResponse (HttpServletResponse response) {
  this.response = response;
 }
 public HttpSession getSession () {
  HttpSession session = super.getSession();
  processSessionCookie(session);
  return session;
 }
 public HttpSession getSession (boolean create) {
  HttpSession session = super.getSession(create);
  processSessionCookie(session);
  return session;
 }
 private void processSessionCookie (HttpSession session) {
  if (null == response || null == session)  return;

  Object cookieOverWritten = getAttribute("COOKIE_OVERWRITTEN_FLAG");
  if (null == cookieOverWritten && isSecure() && isRequestedSessionIdFromCookie() && session.isNew())  {
   Cookie cookie = new Cookie("JSESSIONID", session.getId());
   cookie.setMaxAge(-1);
   String contextPath = getContextPath();
   if ((contextPath != null) && (contextPath.length() > 0))   {
    cookie.setPath(contextPath);
   }   else   {
    cookie.setPath("/");
   }  
   response.addCookie(cookie);
   setAttribute("COOKIE_OVERWRITTEN_FLAG", "true");
  }
 }
}

그리고 Filter 클래스를 만듭니다. 이 필터는 기본 Request를 HttpsRequestWrapper로 변경하는 역할을 합니다. 그리고 이 필터는 다른 필터보다 우선 실행되어야 합니다.

public class HttpsFilter implements Filter{
 public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
   HttpsRequestWrapper httpsRequest = new HttpsRequestWrapper((HttpServletRequest)request);
   httpsRequest.setResponse((HttpServletResponse)response);
   chain.doFilter(httpsRequest, response);
 }




 

+ Recent posts