ラベル tomcat の投稿を表示しています。 すべての投稿を表示
ラベル tomcat の投稿を表示しています。 すべての投稿を表示

2017/05/06

spring-boot:run does not stop the tomcat

eclipseでmvn spring-boot:run を停止して、tomcatがまだ生きる

the port has been usedになる。


The best way to "fix" that is to not do it. Why would you need to run a maven goal from eclipse when you can just right click in the main class and Run As->Java Application?

boot dashboardも回避できる。
=> boot dashboardの仕組みは?単純に実行したことを思えたかな?
   あとで調べる

2014/06/13

Removing the Apache Tomcat runtime from a project in Eclipse

I had a similar problem. I had a prject referring to a no more existing Tomcat instance. I was not able to remove Tomcat from "Server" and "Runtime Environments" from UI (delete button always gray),so I solved the problem deleting all the reference from the filesystem:

In project folder check files:

    .classpath
    .settings/org.eclipse.wst.common.project.facet.core.xml

In workspace folder check:

    .metadata.plugins\org.eclipse.debug.core
    .metadata.plugins\org.eclipse.wst.server.core
    .metadata.plugins\org.eclipse.core.runtime.settings\org.eclipse.jst.server.tomcat.core.prefs

Maybe a bit brutal but I didn't find a better solution.

2014/06/11

Eclipse Tomcatプラグイン 別プロジェクトのロード


いや?、解決してよかった!

Eclipseで、Tomcatプラグインを使用して、Webアプリケーションを作成していました。Tomcatプロジェクトとしたプロジェクトから、通常のプロジェクトをロードする方法がわからなくて悩んでいました。ネット検索して、いくつか掲示板に悩み相談が載っていたのですが解決していませんでした。でも、解決しました。
目的

プロジェクトA(Tomcatプロジェクト)から、プロジェクトB(通常プロジェクト)をロードして、Webアプリケーションを作成したい。
解決方法

1.プロジェクトA(Tomcatプロジェクト)のプロパティで、ビルドパスの要求プロジェクトに、プロジェクトB(通常プロジェクト)を追加しました。これでコンパイルが通るようになりました。
2.EclipseのTomcatプラグインの設定で、「Tomcat>拡張」の「JavaプロジェクトをTomcatのクラスパスへ追加」から、プロジェクトB(通常プロジェクト)を追加しました。これでブラウザからのアクセスが出来るようになりました。
環境

Eclipse:Version 3.4
Tomcat:Version 5.5.27

2014/03/11

tomcat catalina.sh log

・Tomcat(Java)の標準エラーを標準出力へあらかじめリダイレクトしておく(2>&1)のがミソ。
>> "$CATALINA_OUT" 2>&1 "&"


・rotatelogsへのオプションにより、yyyy-mm-dd形式のタイムスタンプを${CATALINA_BASE}/logs/catalina.out末尾に付与し、
一日ごと(86400秒)に、JST(540分=+9時間のGMTからの時差)のローカルタイム基準でログを午前0時に新しいファイルにローテートする設定となる。
繰り返すけど、二か所あるので、同じように変更しておく。元の設定は、"#"でコメントアウトしておくとよい。
>> 2>&1 | /usr/sbin/rotatelogs "$CATALINA_BASE"/logs/catalina.out.%Y-%m-%d.log 86400 540 &

2014/01/20

tomcat app class ロード順

決まり事である。
ーーーーー>
クラスやリソースのロードの際のリポジトリのチェックは、 Webアプリケーションから見ると以下の順序になります。
  • JVM のブートストラップクラス
  • System クラスローダの各クラス (上述)
  • Webアプリケーションの /WEB-INF/classes
  • Webアプリケーションの /WEB-INF/lib/*.jar
  • $CATALINA_HOME/common/classes
  • $CATALINA_HOME/common/endorsed/*.jar
  • $CATALINA_HOME/common/lib/*.jar
  • $CATALINA_HOME/shared/classes
  • $CATALINA_HOME/shared/lib/*.jar

2013/11/19

apaceh tomcat https

tomcatのserver.xml
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

Connector  port="8009"
           protocol="AJP/1.3"
           scheme="https"
           secure="true";
           />

apacheのrewriteでもできるのようです。。。

設定できる所、いろいろあり、困るね。

2013/10/28

tomcat thread 数 負荷確認

★tomcatが受付可能な最大スレッド数ー>server.xmlのmaxThreads
・コネクションのmaxThread
 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"
    maxThreads="500" />



★tomcatのThread数?上記の指定値はOSで実現できる?
●まずはOSー>Linux(Kernel 2.6及びそれ以降)で用いられているNTPL(Native POSIX Thread Library)。これは1:1モデルのスレッドライブラリで、スレッドをプロセスとして実装してある
・/proc/sys/kernel/threads-max ->linux扱う可能の最大スレッド数
・/proc/sys/vm/max_map_count->linuxで、メモリー関係で対応可能数(いくらを与えるなど。。)
・★/ect/security/limit.cnfで設定された上限。数とサイズ
  max user processes
  stack size=>*MBまで使ってもいいよという意味。上限
●次はJVM -XX:ThreadStackSize こいつのデフォルトは320kである(java1.7)



●●結局、JVMのデフォルトthreadStackSize使う場合、limitで確認できたmax user processesまで行ける。。
計算式であれば、
tomcatなどの起動時状態で、システムの(buffer+free/threadStackSize) と(max user processes)
の少ない方である。



・スレッドの数を確認する
ls -l /proc/$( ps -ef | grep Bootstrap | grep -v grep | awk '{print $2}' | head -1 )/task | wc -l
=>head -N 先頭からN行を表示する
=>awk '{print $2}' 第二列だけ表示する
=>grep -v ** 除外する
=>$() 実行結果をもらう
=>/proc/**/task スレッドの数



・DB接続数
netstat -t | grep DBアドレス | wc -l



・クラント側の接続数
netstat -t | grep 8009(apcheから) | wc -l
netstat -t | grep bot**(負荷書けるマシン) | wc -l

tomcat does not release memory

The JVM does return memory to the operating system. I use -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=10 frequently for a process that needs 1GB at startup until it is settled, but then runs fine with 250MB forever.

2013/09/13

java reflect (from tomcat)


        Class<?> startupClass =
            catalinaLoader.loadClass
            ("org.apache.catalina.startup.Catalina");
        Object startupInstance = startupClass.newInstance();

        // Set the shared extensions class loader
        if (log.isDebugEnabled())
            log.debug("Setting startup class properties");
        String methodName = "setParentClassLoader";
        Class<?> paramTypes[] = new Class[1];
        paramTypes[0] = Class.forName("java.lang.ClassLoader");
        Object paramValues[] = new Object[1];
        paramValues[0] = sharedLoader;
        Method method =
            startupInstance.getClass().getMethod(methodName, paramTypes);
        method.invoke(startupInstance, paramValues);
       
       ★paramTypes[0] = Boolean.TYPE;

2013/09/09

Tomcat timeout config

Apache-Tomcat間コネクションのタイムアウト値が設定されておらず、
デフォルトのままだったために、コネクションを無制限に維持する
最新のは60秒、ゴロゴロ変わるね。。。

Tomcatのserver.xmlのconnectionTimeoutを明示的に設定し、
connectionTimeoutはミリ秒単位なので、以下の例だと5分
<Connector port=”8083″maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
    enableLookups=”false” redirectPort=”443″ acceptCount=”100″
    debug=”0″ connectionTimeout=”30000″
    disableUploadTimeout=”true” />


The number of milliseconds this Connector will wait, after accepting a connection, for the request URI line to be presented. Use a value of -1 to indicate no (i.e. infinite) timeout. The default value is 60000 (i.e. 60 seconds) but note that the standard server.xml that ships with Tomcat sets this to 20000 (i.e. 20 seconds).



Connection timeout and session timeout are two totally different things.

Connection timeouts have to do with how long the server will leave a connection between the browser and server open after a response is complete.

Session-timeout is what controls the length of time that an idle session will last.

As to the session-timeout setting in conf/web.xml; I can't say for sure, but I'm guessing that 30 minutes is the default whether that entry is there or not and that the entry is there to make it easier for folks who want to change it to find it.
Out of curiosity, why do you care if there is a default value? 

2013/06/20

tomcat 配置 デプロイ deploy

・webappの下で
・5からは変わった。
=>$CATALINA_HOME\conf\[engine name]\[host name]ディレクトリ配下にコンテキスト名.xml

2013/06/19

tomcat - CATALINA_BASE and CATALINA_HOME variables

catalina.shでpwdで設定したね。
ーーー
# Only set CATALINA_HOME if not already set
[ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
# Copy CATALINA_BASE from CATALINA_HOME if not already set
[ -z "$CATALINA_BASE" ] && CATALINA_BASE="$CATALINA_HOME"
ーーー

使い分け:
ーーーー
#   CATALINA_HOME   May point at your Catalina "build" directory.
#
#   CATALINA_BASE   (Optional) Base directory for resolving dynamic portions
#                   of a Catalina installation.  If not present, resolves to
#                   the same directory that CATALINA_HOME points to.

こんなの感じ
  ・  CATALINA_HOME
         -  /some/where/apache-tomcat-7.0.11/
         ※ apache-tomcat-7.0.11.tar.gz を展開したもの。

  ・  CATALINA_BASE (ホントに最低限の構成例)
         -  /some/where/my-instance/conf/server.xml
         -  /some/where/my-instance/lib/
         -  /some/where/my-instance/logs/
         -  /some/where/my-instance/temp/
         -  /some/where/my-instance/webapps/my-app.war
         -  /some/where/my-instance/work/