java6 와 tomcat6 의 연동은 java5+tomcat5.5 와 크게 다르지 않았다.
parameter 부분을 하나의 컨텍스트 안에 모두 표현하고 하는 것 까지는 좋았으나,
tomcat home conf 디렉토리 아래로.. \Catalina\localhost 디렉토리들은 없는 것이 아닌가...
일단 해보자는 생각에... 컨텍스트 설정을 모두 마친 후 서블릿을 타고 메인 페이지를 뿌리는 것 까지는 좋았으나,
DB를 커넥트 못하고 에러 화면을 뿌린 것이다.
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at base.DBConnResource.<init>(Unknown Source)
at user.UserServ.userLogin(UserServ.java:781)
at user.UserServ.performTask(UserServ.java:49)
at base.PublicBaseServlet.performPreTask(Unknown Source)
at com.nara.jdf.servlet.JDFBaseServlet.performBasePreTask(JDFBaseServlet.java:60)
at com.nara.jdf.servlet.JDFBaseServlet.doPost(JDFBaseServlet.java:31)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:402)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:170)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)
... 26 more
이 상태에서 고민을 반복하다..
Resource name="jdbc/Mysql" auth="Container" 이 부분이 있었던 기존의 xml을 context.xml 에 아래와 같이 추가하였다.
For each file given, GNU strings prints the printable character sequences that are at least 4 characters long (or the number given with the options below) and are followed by an unprintable character. By default, it only prints the strings from the initialized and loaded sections of object files; for other types of files, it prints the strings from the whole file.
strings is mainly useful for determining the contents of non-text files.
OPTIONS
-a
--all
-
Do not scan only the initialized and loaded sections of object files; scan the whole files.
-f
--print-file-name
Print the name of the file before each string.
--help
Print a summary of the program usage on the standard output and exit.
-min-len
-nmin-len
--bytes=min-len
Print sequences of characters that are at least min-len characters long, instead of the default 4.
-o
Like -t o. Some other versions of strings have -o act like -t d instead. Since we can not be compatible with both ways, we simply chose one.
-tradix
--radix=radix
Print the offset within the file before each string. The single character argument specifies the radix of the offset---o for octal, x for hexadecimal, or d for decimal.
-eencoding
--encoding=encoding
Select the character encoding of the strings that are to be found. Possible values for encoding are: s = single-7-bit-byte characters (ASCII, ISO 8859, etc., default), S = single-8-bit-byte characters, b = 16-bit bigendian, l = 16-bit littleendian, B = 32-bit bigendian, L = 32-bit littleendian. Useful for finding wide character strings.
--target=bfdname
Specify an object code format other than your system's default format.
-v
--version
Print the program version number on the standard output and exit.
1. 개요 cron(크론)은 원하는 시간에 명령(프로그램)을 시키기 위한 데몬이다. 서버는 늘 깨어있다는 것을 이용한 최대한의 활용법이 될 수 있다.
- 내가 새벽 3시에 서버에 특정 작업을 해줘야하는데 그 때 깨어있을 수 있는가? - 또는 30분 간격으로 HDD의 사용량을 운영자에게 알리도록 해야한다면? - 매월 초에 자료를 백업 받고 싶다면?
바로 이럴 때 cron은 최고의 해결책을 제시한다. cron은 항상 지정한 시간이 되었는지 확인을 하여 해당 명령어을 실행하는 것이다.
시스템의 최적화의 기법은 일정 시간 단위로 최대한의 성능을 발휘하도록 도와주는 것이다. 즉, 주기적으로 운영 중에 만들어진 필요하지 않는 임시 파일을 정리하거나, 운영체제 운영에 필요한 데이터를 갱신하는 등의 작업을 통해 리눅스가 최적의 상태를 유지할 수 있게 할 수 있다.
2. cron 설정 1) crontab 파일 위치 및 조회 작업 설정 파일을 crontab 파일이라고 부르며, 이 파일의 위치는 OS별로 차이가 있다. 리눅스는 /var/spool/cron/ID, 솔라리스는 /var/spool/corn/crontabs/ID에 위치한다. 그럼 이 파일을 직접 수정해야 하는가? 그렇지 않다. crontab 명령을 통해 설정과 조회를 한다.
crontab 설정 파일을 새롭게 편집하고자 한다면 -e 옵션을 주고, 수정하기 전에 현재 등록된 내용을 보고자 한다면 -l 옵션을 사용하며, 등록된 내용을 삭제하려면 -d 옵션을 사용한다
설정 내용을 조회해 보자(-l 옵션). $ crontab -l no crontab for truefeel 설정한 적이 없어 아직 비어있다.
- /etc/crontab 파일
- /etc/rc.d/init.d/crond 스크립트
- /var/spool/cron 디렉토리 내의 크론 설정 파일들
2) crontab 파일 형식 ---------- ---------- --------------------------------------
필 드 의 미 범 위
---------- ---------- --------------------------------------
첫 번째 분 0-59
두 번째 시 0-23
세 번째 일 0-31
네 번째 월 1-12
다섯 번째 요일 0-7 (0 또는 7=일요일, 1=월, 2=화, ...)
여섯 번째 명령어 실행할 명령을 한줄로 쓴다.
---------- ---------- --------------------------------------
- 모든 엔트리 필드는 공백으로 구분된다.
- 한 줄당 하나의 명령 (두줄로 나눠서 표시할 수 없음) - # 으로 시작하는 줄은 실행하지 않는다.
설정을 해보자. (-e 옵션) crontab -e을 하면 vi 에디터가 나온다(환경변수 EDITOR에 따라 다른 에디터를 사용할 수 있다).
$ crontab -e # /home 디렉토리를 /BACKUP/home으로 백업해둠 # # 30분, 새벽 4시와 낮 12시, 모든 일, 모든 월, 모든 요일 30 4,12 * * * /usr/bin/rsync -avxH --delete /home /BACKUP/home > /dev/null 2>&1 # # 파일/디렉토리 퍼미션 설정 # 40분, 새벽 1시, 매주 일요일 40 1 * * 0 /root/bin/perm_set.sh > /dev/null 2>&1
위는 매일 4:30분과 12:30분에 rsync 명령을, 매주 일요일 1:40분에 perm_set.sh를 실행함을 의미한다.
3) 설정 예
시간 설정에서 몇가지 의미있는 것들을 알아보자. - '*'표시는 해당 필드의 모든 시간을 의미한다. - 3,5,7와 같이 콤마(,)로 구분하여 여러 시간대를 지정할 수 있다. - 2-10와 같이 하이픈(-)으로 시간 범위도 지정할 수 있다. - 2-10/3와 같이 하이픈(-)으로 시간 범위를 슬래쉬(/)로 시간 간격을 지정할 수 있다(2~10시까지 3시간 간격으로. 즉, 3, 6, 9시를 의미함).
원하는 시간 형 식
매주 토요일 새벽 2:20 20 2 * * 6 명령어
매일 오후 4,5,6시 0 4-6 * * * 명령어
매일 2시간 간격으로 5분대에 5 */2 * * * 명령어
매월 1일 새벽 1:15 15 1 1 * * 명령어
1,7월 1일 새벽 0:30 30 0 1 1,7 * 명령어
4) /etc/crontab 파일로 설정
매시 1회 자동실행하기 위한 시스템 크론 설정
01 * * * * root run-parts /etc/cron.hourly
- 매일 매시 01분마다 /etc/cron.hourly 디렉토리내에 존재하는 파일들을 실행
매일 1회 자동실행하기 위한 시스템 크론설정
02 4 * * * root run-parts /etc/cron.daily - 매일 새벽 4시 02분마다 /etc/cron.daily 디렉토리내에 존재하는 파일들을 실행
매주 1회 자동실행하기 위한 시스템 크론설정
22 4 * * 0 root run-parts /etc/cron.weekly - 매주 일요일 새벽 4시 22분마다 /etc/cron.weekly 디렉토리내에 존재하는 파일들을 실행
매월 1회 자동실행하기 위한 시스템 크론설정
42 4 1 * * root run-parts /etc/cron.monthly ->매월 1일 새벽 4시 42분마다 /etc/cron.monthly 디렉토리내에 존재하는 파일들을 실행
command를 제외한 모든 필드에 와일드 카드 문자(*)를 사용할 수 있고, 필드에 - 기호를 사용해서 범위를 지정할 수 있습니다.
예:
30 1 * 2,4,6,8,10,12 3-5 /usr/bin/wall /var/tmp/message
이 명령은 2개월마다 수요일부터 금요일까지 1시 30분에 wall 명령을 사용해서 시스템의 모든 사용자에게 메시지를 전송합니다.
* root 이외의 사용자에게 crontab 명령어를 이용할 수 있게 하는 방법
- /etc/cron.allow 파일에 사용자의 id를 등록
* 일반사용자의 crontab 명령어사용을 제안하고자 한다면 - /etc/cron.deny 파일에 사용자의 id 를 등록
3. FAQ
1) cron 설정한 후에는 crond 데몬을 재실행해야 하나요?
아닙니다. crontab -e 으로 설정 후 빠져나오면 바로 적용됩니다. 2) truefeel 사용자는 cron을 못 쓰게 하고 싶습니다. /etc/cron.allow : 허용할 사용자 ID 목록 /etc/cron.deny : 거부할 사용자 ID 목록 cron.allow 파일이 있으면 이 파일에 들어있는 ID만 사용 가능 cron.deny 파일이 있으면 이 파일에 들어있는 ID는 사용 불가 따라서 cron.deny에 truefeel ID를 추가해주면 됩니다. 3) > /dev/null 2>&1 이 무슨 뜻입니까? 지정한 명령어 처리 결과와 발생할지 모르는 에러메시지를 출력하지 않고 모두 버린다는(/dev/null)는 뜻입니다. 만약 결과와 에러를 파일로 저장하려면 /dev/null 대신 파일명을 적어주면 됩니다
crontab 명령은 지정된 사용자에 대한 crontab 파일을 편집하거나, 표시하거나, 제거하는 데 사용됩니다. root만이 [username] 매개변수를 사용할 수 있습니다.
옵션이나 매개변수 없이 crontab 명령을 실행하면 crontab 파일에 표준 입력을 기록합니다(아래 경고 참조).
crontab 파일의 형식은 다음과 같습니다.
Minutes Hours Date Month Day-of-Week command
추가 설명:
경고
실수로 인수를 지정하지 않고 crontab 명령을 입력했을 경우, CTRL-D를 눌러 종료하지 마십시오. 그러면 crontab 파일의 모든 항목이 삭제됩니다. 대신 중지 문자(일반적으로 CTRL-C)를 눌러 종료하십시오.
일반적인 문제/일반적인 해결 방법, 질문/대답:
P: crontab 파일을 편집했지만 계속 실행되지 않습니다.
S: vi와 같은 텍스트 편집기로 직접 crontab 파일을 편집하면 안됩니다. crontab -e 명령을 사용하면 vi를 호출한 다음 변경된 내용을 cron에 알립니다.
P: crontab -e 명령을 사용해서 crontab 항목을 모두 삭제했지만 crontab -l 명령을 실행하면 삭제한 항목이 나옵니다.
S: crontab 파일을 모두 삭제하려면 crontab -r 명령을 사용하십시오. crontab -e 명령은 빈 파일을 처리하지 못하기 때문에 변경된 내용을 업데이트하지 못합니다.
Q: **** 편집기를 사용할 수 있습니까?
A: 예, 환경 변수 EDITOR를 ****으로 설정하면 됩니다.
Q: cron 작업이 중단될 때 전자 우편 메시지를 받는 것은 왜 그렇습니까?
A: 표준 출력 양식이 없기 때문입니다.
이 메시지를 받지 않으려면 명령을 출력할 장치(/dev/console, /dev/null)나 파일을 지정하십시오.
P: 4.1 이전 시스템을 사용하고 있는데, 가끔 cron 작업이 두 번씩 중단됩니다.
S: 1022379에 대한 패치 100058-01을 전송하십시오.
Q: cron이 정상적으로 실행되고 있는지 확인할 수 있습니까?
A: crontab 파일에 "** * * * date > /dev/console" 항목을 추가하십시오. 그러면 매분마다 콘솔에 날짜가 출력됩니다.
고급 문제:
Q: cron을 사용할 수 있는 사용자를 제한할 수 있습니까?
A: /var/spool/cron/cron.allow 파일을 사용하면 cron 작업을 실행할 수 있는 사용자를 지정할 수 있습니다.
/var/spool/cron/cron.allow 파일이 없으면 crontab이 /var/spool/cron/cron.deny 파일을 통해 작업을 실행할 수 없는 사용자를 확인합니다.
GNU make is definitely required. The connector fails to build with native AIX make, so make absolutely sure that GNU make is found in PATH prior to /usr/bin/make.
GNU automake 1.5, installed from source
GNU autoconf 2.53, installed from IBM-provided RPM
You may just hit this obscure error during make if you originally configured libtool using IBM's C compiler for AIX:
Waiting for jk_ajp12_worker.o.lock to be removed.
The work-around is to edit libtool (whichever one is found in PATH) and change the setting of the variable need_locks to "warn", then run make again. Here is the section in the libtool script:
# Must we lock files when doing compilation ?need_locks="yes"need_locks="warn"
After make completes, the DSO is in the unlikely location apache-1.3/.libs/libmod_jk.so.0. Install it manually instead of using make install:
GNU make is definitely required. The connector fails to build with native AIX make, so make absolutely sure that GNU make is found in PATH prior to /usr/bin/make.
GNU automake 1.5, installed from source
GNU autoconf 2.53, installed from IBM-provided RPM
jakarta-tomcat-connectors-4.0.6-src.tar.gz
IBM's java 1.3.1 filesets for AIX
building Apache 1.3
Build Apache as described here. For this example, we'll assume that you installed it into $HOME/1328_gcc.
building mod_jk
$ cd jakarta-tomcat-connectors-4.0.6-src/jk/native$ ./buildconf.sh$ ./configure --with-apxs=$HOME/1328_gcc/bin/apxs --with-java-home=/usr/java131
Before running make, you need to edit apache-1.3/Makefile and update it for AIX. Replace this section:
You may just hit this obscure error during make if you originally configured libtool using IBM's C compiler for AIX:
Waiting for jk_ajp12_worker.o.lock to be removed.
The work-around is to edit libtool (whichever one is found in PATH) and change the setting of the variable need_locks to "warn", then run make again. Here is the section in the libtool script:
# Must we lock files when doing compilation ?need_locks="yes"need_locks="warn"
After make completes, the DSO is in the unlikely location apache-1.3/.libs/libmod_jk.so.0. Install it manually instead of using make install:
Existing tarballs like jakarta-tomcat-connectors-jk2-2.0.2-src.tar.gz have syntax errors that prevent compiling the code with the native AIX compiler. We'll check out the most recent sources from CVS and apply a minimal patch and be sure to use the unpicky compiler flavor so that we don't have any unnecessary grief.
If you downloaded from CVS prior to 20030403, or you use a tarball built prior to 20030403, then make sure you have downloaded this patch file since it is needed for the build.
If you are using Apache 2.0.45, make sure you specified --enable-so on the configure invocation, since that works around a bug in 2.0.45 that broke DSOs.
Other software needed:
IBM's C for AIX
GNU make (examples below invoke it via gmake
GNU patch (example below invokes it via /opt/freeware/bin/patch
GNU libtool (as needed for Apache 2)
GNU autoconf (ditto)
GNU automake (I used GNU automake 1.5, installed with the same prefix as libtool and autoconf)
So do this to grab the sources.
$ CVSROOT=:pserver:anoncvs@cvs.apache.org:/home/cvspublic cvs login(enter "anoncvs" for the password)$ CVSROOT=:pserver:anoncvs@cvs.apache.org:/home/cvspublic cvs co jakarta-tomcat-connectors
At this point, we have the sources checked out. Change into the directory for mod_jk2, apply my patch file if using connector code older than 20030403, possibly edit server/apache2/Makefile.in, and build the configure script. If the patch fails to apply, it maybe that mod_jk2 is fixed in CVS already, or it may be that there are other changes to the code that needed to be patched.
$ cd jakarta-tomcat-connectors/jk/native2# If using connector code from prior to 20030403, apply this patch:$ /opt/freeware/bin/patch < jk2_cc_patch_20030313# If using Apache older than 2.0.45, edit this line in# jk/native2/server/apache2/Makefile.in and change "-lapr-0" to "-lapr".# JK_LDFLAGS=-L${APACHE2_LIBDIR} -lcrypt -lapr-0 @PCRE_LIBS@$ ./buildconf.shlibtoolize --force --automake --copyaclocalautomake --copy --add-missingautomake: configure.in: installing `scripts/build/unix/install-sh'automake: configure.in: installing `scripts/build/unix/mkinstalldirs'automake: configure.in: installing `scripts/build/unix/missing'autoconf
Now, run configure to customize the build for your machine. Adjust the --with-java-home and --with-apxs2 configure parameters shown below to point to your own java install and the apxs file from your Apache 2.0 installation.
Note that even if you used xlc_r for compiling Apache, you'll need to use CC=cc_r instead of CC=xlc_r when configuring the connector because the connector has various signed-ness problems with character strings which xlc_r will treat as compile failures.
$ CC=cc_r ./configure --with-java-home=/usr/java131 --with-apxs2=/jeff/trawick/apacheinst/bin/apxs[lots of output not shown]
Now run GNU make to build it (the make files are not compatible with native AIX make).
$ gmake[lots of output not shown]
If the build fails with a message like this:
ld: 0706-006 Cannot find or open library file: -l apr-0 ld:open(): No such file or directory
then you forgot to edit server/apache2/Makefile.in (see above).
Now, manually grab the mod_jk2 DSO and rename it to something sane while copying it to the Apache modules directory. Because of libtool &^%$#@, on AIX it will be called libmod_jk2.so after the make completes.
$ cd ../../jk/build/jk2/apache2$ cp -p libmod_jk2.so /jeff/trawick/apacheinst/modules/mod_jk2.so
Add the appropriate LoadModule to Apache 2's configuration file and away you go.
AIX 5.1 ML 02java 1.3.1IBM's RPM install of GCC gcc (gcc-2.9.aix51.020209-3)GNU libtool 1.4.2 installed from sourceIBM's RPM install of GNU autoconf (autoconf-2.53-1)GNU automake 1.5 installed from sourceIBM's RPM install of GNU make (make-3.79.1-3)
I can't say definitively that those levels have to be used beyond the fact that this level of mod_jk2 fails to build with java < 1.3.1.
In the examples below, /home/trawick/gcc_httpd_mod_jk2 is where I unpacked the source distributions and /home/trawick/gcc_httpd_mod_jk2/install is where I installed Apache. You'll need to adjust that, and perhaps other local customizations, as appropriate for your environment.
building Apache
If using Apache httpd >= 2.0.47, setting CPPFLAGS as shown in the example is not required.
If using Apache httpd 2.0.45, add "--enable-so" to your configure invocation.
Don't try it with older Apache httpd since apxs is broken on AIX until 2.0.45. Also, the Tomcat build relies on an APR rename that happened with 2.0.45.
$ cd /home/trawick/gcc_httpd_mod_jk2$ gtar -xzf httpd-2.0.46.tar.gz$ cd httpd-2.0.46$ ./buildconf$ CPPFLAGS=-D_THREAD_SAFE CC=gcc ./configure --prefix=/home/trawick/gcc_httpd_mod_jk2/install --enable-mods-shared=most --with-expat=$PWD/srclib/apr-util/xml/expat$ make$ make install
building mod_jk2
$ cd /home/trawick/gcc_httpd_mod_jk2$ gtar -xzf jakarta-tomcat-connectors-4.1.24-src.tar.gz$ cd jakarta-tomcat-connectors-4.1.24-src$ cd jk/native2$ chmod +x ./buildconf.sh$ ./buildconf.sh$ CC=gcc ./configure --with-java-home=/usr/java131 --with-apxs2=/home/trawick/gcc_httpd_mod_jk2/install/bin/apxs
Before running make, edit ../../jk/native2/server/apache2/Makefile and change the line
being sure not to mess up the character at the start of the line. We're just adding the "-Wl,-brtl" at the end.
A more appropriate fix was submitted to the Tomcat developers on 20030618, so hopefully this problem won't exist forever in the mod_jk distribution. The fix described above is fine for AIX and is easier to insert manually.
Now, on with the build:
$ gmake
You may just hit this obscure error during make if you originally configured libtool using IBM's C compiler for AIX:
Waiting for jk_something.o.lock to be removed.
The work-around is to edit libtool (whichever one is found in PATH) and change the setting of the variable need_locks to "warn", then run gmake again. Here is the section in the libtool script:
# Must we lock files when doing compilation ?need_locks="yes"need_locks="warn"
After gmake completes successfully, install mod_jk.so into the Apache modules directory with this command:
gmake install
If you want to manually copy the DSO, do it like this, since the filename is not correct:
댓글을 달아 주세요