jenkins集成报错:java.lang.Object.wait(Native Method)之解决方案
继上一篇博客https://blog.csdn.net/u012366142/article/details/82756210的错误:java.lang.Object.wait(Native Method) oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource$BlockReleaser.run(BlockSourc...
·
继上一篇博客https://blog.csdn.net/u012366142/article/details/82756210的错误:
java.lang.Object.wait(Native Method)
oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource$BlockReleaser.run(BlockSource.java:327)
18-Sep-2018 14:11:11.978 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CAD_WebService] appears to have started a thread named [OracleTimeoutPollingThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Thread.sleep(Native Method)
oracle.jdbc.driver.OracleTimeoutPollingThread.run(OracleTimeoutPollingThread.java:148)
继续探究优化对jenkins的配置,改为使用SSH publishers进行war包部署,过程如下:
1.配置SSH Server
2.构建完成后,配置SSH Publishers
Exec command规则为:
./publish.sh <项目WEB显示名称> [TOMCAT端口] [tomcat安装主目录]
3.脚本文件publish.sh(存放在/usr/local/java/jenkins/workspace/target/下)
#!/bin/bash
#defined
TOMCAT_HOME="/usr/local/java/tomcat8"
TOMCAT_PORT=8090
PROJECT="$1"
#param validate
if [ $# -lt 1 ]; then
echo "you must use like this : ./publish.sh <projectname> [tomcat port] [tomcat home dir]"
exit
fi
if [ "$2" != "" ]; then
TOMCAT_PORT=$2
fi
if [ "$3" != "" ]; then
TOMCAT_HOME="$3"
fi
#shutdown tomcat
"$TOMCAT_HOME"/bin/shutdown.sh
echo "tomcat shutdown"
#check tomcat process
tomcat_pid=`/usr/sbin/lsof -n -P -t -i :$TOMCAT_PORT`
echo "current :" $tomcat_pid
while [ -n "$tomcat_pid" ]
do
sleep 5
tomcat_pid=`/usr/sbin/lsof -n -P -t -i :$TOMCAT_PORT`
echo "scan tomcat pid :" $tomcat_pid
done
#publish project
echo "scan no tomcat pid,$PROJECT publishing"
rm -rf "$TOMCAT_HOME"/webapps/$PROJECT*
cp /usr/local/java/jenkins/workspace/target/$PROJECT*.war "$TOMCAT_HOME"/webapps/$PROJECT.war
#bak project
BAK_DIR=/usr/local/java/jenkins/workspace/target/bak/$PROJECT/`date +%Y%m%d`
mkdir -p "$BAK_DIR"
cp "$TOMCAT_HOME"/webapps/$PROJECT.war "$BAK_DIR"/"$PROJECT"_`date +%H%M%S`.war
#remove tmp
rm -rf /usr/local/java/jenkins/workspace/target/$PROJECT*.war
#start tomcat
"$TOMCAT_HOME"/bin/startup.sh
echo "tomcat is starting,please try to access $PROJECT conslone url"
该脚本具有自动安全停Tomcat,自动发布项目,自动备份已发布项目版本的功能
编辑脚本后,需要给用户赋予读写权限:
chmod 755 publish.sh
注意:
远程机器的java_home在配置在/etc/profile中的,这个只给shell用户使用的,但对于ssh 这种非login shell(non-login shell)用户,需要配置在/etc/bashrc中。
export JAVA_HOME=/usr/local/java/jdk1.8.0_181
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
至此,jenkins任务job便可正确构建并启动。
更多推荐
已为社区贡献1条内容
所有评论(0)