2012년 9월 3일 월요일

Kill Tomcat process at port 8080


Occasionally the Tomcat server doesn't shutdown in a clean way when using Eclipse. What happens is that port 8080 stays in use and the server can't restart. Exiting Eclipse is not sufficient in this case and a restart of Mac OSX is needed.

So, how to kill the running Tomcat and free port 8080.
Open the terminal window and execute the following commands.

  • sudo lsof -w -n -i tcp:8080
This will give you the pidnumber of the process that runs at 8080. You can then go ahead and kill it.

  • sudo kill -9 pidnumber

http://petervandamme.blogspot.kr/2011/09/kill-tomcat-process-at-port-8080.html

2012년 8월 6일 월요일

MySql Function 생성


DELIMITER $$
DROP FUNCTION IF EXISTS dbname.getCompany$$
CREATE FUNCTION dbname.getCompany($p_cid VARCHAR(20)) RETURNS varchar(20) CHARSET utf8
BEGIN
DECLARE return_value VARCHAR(20);
  SET return_value = null;
    SELECT u.mf_code INTO return_value
      FROM users u
     WHERE u.cid = p_cid;
RETURN return_value;
END $$
DELIMITER ;

2012년 8월 2일 목요일

맥 숨긴 폴더, 파일 보기
defaults write com.apple.finder AppleShowAllFiles TRUE 
killall Finder



defaults write com.apple.finder AppleShowAllFiles FALSE 
killall Finder



2012년 6월 27일 수요일

Virtual Host on MAX OSX


Virtual Host on MAX OSX
1. 아파치 활성화:
     라이언: 시스템설정 > 공유 > 웹공유 체크
     마운틴라이언: sudo apachectl start (http://v.daum.net/link/32342588)
2. Installing mod_jk for Apache 2.2 on Mac OS X 10.5 Leopard
출처 http://www.bartbusschots.ie/blog/?p=1347

2.1 tomcat connector 설치
source 파일 다운, 압축해제 후 컴파일
-----------
$ cd native
$ ./configure CFLAGS='-arch x86_64' APXSLDFLAGS='-arch x86_64' --with-apxs=/usr/sbin/apxs
$ make
(make가 안될경우 애플개발자 사이트에서  command line tool ~~ 항목 설치)
$ sudo make install


    ./configure.....에서 에러날 경우 XCode설치 후 심볼릭링크 생성해줌

$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain

(출처: http://apple.stackexchange.com/questions/58186/how-to-compile-mod-wsgi-on-mountain-lion-by-fixing-apxserror-command-failed-w)


----------
2.2. workers.properties 작성
-----------
etc/apache2/extra/workers.properties
#
# The workers that jk should create and work with
#
worker.list=worker1

#
# Defining a worker named ajp13 and of type ajp13
# Note that the name and the type do not have to match.
#
worker.ajp13.type=worker1
worker.ajp13.host=localhost
worker.ajp13.port=8009
-------------
3. httpd-vhosts.conf 설정
etc/apache2/extra/httpd-vhosts.conf

###########start
# Load mod_jk module
# Update this path to match your modules location
LoadModule jk_module libexec/apache2/mod_jk.so
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /var/log/apache2/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# Send everything for context /example to worker named ajp13

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
        ServerAdmin admin@beautyhub.co.kr
        DocumentRoot "/Users/jryeong/DEV/server/apache2/mobile"
        ServerName m.beautyhub2.co.kr
        ErrorLog "/Users/jryeong/DEV/server/logs/httpd/m.beautyhub2.co.kr.error.log"
        CustomLog "/Users/jryeong/DEV/server/logs/httpd/m.beautyhub2.co.kr.access.log" common
        <Directory "/Users/jryeong/DEV/server/apache2/mobile">
           Options None
           AllowOverride None
           Order allow,deny
           Allow from all
       </Directory>
</VirtualHost>

<VirtualHost *:80>
        ServerAdmin admin@beautyhub.co.kr
        DocumentRoot "/Users/jryeong/DEV/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/beautyhub"
        ServerName api.beautyhub2.co.kr
        ErrorLog "/Users/jryeong/DEV/server/logs/httpd/api.beautyhub2.co.kr.error.log"
        CustomLog "/Users/jryeong/DEV/server/logs/httpd/api.beautyhub2.co.kr.access.log" common
        JkMount /* worker1
        JkUnMount /*.js worker1
        JkUnMount /*.css worker1
        JkUnMount /*.swf worker1
        JkUnMount /*.png worker1
        JkUnMount /*.gif worker1
        JkUnMount /*.ico worker1
       <Directory "/Users/jryeong/DEV/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/beautyhub">
           Options None
           AllowOverride None
           Order allow,deny
           Allow from all
       </Directory>
 </VirtualHost>
##########end

4. hots 파일 설정
/etc/hosts
-----------
127.0.0.1       localhost
255.255.255.255 broadcasthost
127.0.0.1       m.beautyhub2.co.kr
127.0.0.1       api.beautyhub2.co.kr
::1             localhost
fe80::1%lo0     localhost
----------

5. m.beautyhub2.co.kr/index.html에 접속
권한 에러 나올 경우
폴더에 권한을 설정

6./etc/apache2/httpd.conf에서
httpd-vhosts.conf를 읽어들이도록 주석해제


7. 이클립스에서 테스트
    디플로이용 서버 추가시 http server 선택 후 디플로이 폴더 선택
/Users/jryeong/DEV/server/apache2




2012년 5월 7일 월요일

spring security SecurityContextHolder.getContext().getAuthentication()



VelostepUser user = (VelostepUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal();

java.util.Collection<GrantedAuthority> auth = (java.util.Collection<GrantedAuthority>)SecurityContextHolder.getContext().getAuthentication().getAuthorities();

2012년 4월 18일 수요일

2012년 4월 15일 일요일

MySql 생성 및 갱신시에 자동 갱신 타이스탬프컬럼 만들기

http://www.kbedell.com/2009/03/07/how-to-create-a-timestampdatetime-column-in-mysql-to-automatically-be-set-with-the-current-time/


e.g.) 
ALTER TABLE sms_regular_msg_default MODIFY mod_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일'