文章目录

平常心博客

平常心的日常积累

标签: 问题解决收集 (8)

【转载】启动tomcat时,一直卡在Deploying web application directory这块的解决方案 有更新!

1、现象

Tomcat在启动时一直卡在Deploying web application directory这句日志上,日志如下:

[root@iz8vbdzx7y7owm488t4d89z bin]# tail -f ../logs/catalina.out
09-Jun-2017 15:57:06.666 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
09-Jun-2017 15:57:06.667 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
09-Jun-2017 15:57:06.667 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 535 ms
09-Jun-2017 15:57:06.684 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
09-Jun-2017 15:57:06.684 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.15
09-Jun-2017 15:57:06.690 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/apache-tomcat-8.0.15-server/webapps/ROOT

【转载】Centos 7 使用Yum 安装 MySQL 有更新!

1、介绍

centos 从7 开始将原先自带的MySQL被更替为mariadb,默认情况下推荐安装mariadb或Percona,如果对于原版有比较深的情节,可以按照如下方式进行安装。

2、安装YUM Repo

Repo地址可从官方获取:https://dev.mysql.com/downloads/repo/yum/
5066d619c9a54eb086fd72ae891325e1-mysql.png
这里选择的是 Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package(原因是CentOS就是RedHat重新编译的版本)。下载地址可以点击链接查看,或自己按照规则拼接:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
完成后可以检测下md5是否与页面上的一致:
md5sum mysql57-community-release-el7-9.noarch.rpm
然后进行repo的安装:
rpm -ivh mysql57-community-release-el7-9.noarch.rpm

【原创】nginx 301跳转到带www域名方法(不带www访问时重定向到带www域名) 有更新!

直接上代码:

server {
	listen       80;
	server_name  v5cn.cn;
	return       301 http://www.v5cn.cn$request_uri;
}

server {
	listen       80;
	server_name  www.v5cn.cn;
	
	location / {
		proxy_read_timeout 500s;
		proxy_connect_timeout 200s;
		proxy_pass http://blog;
	 }
}

Linux下安装elasticsearch报找不到java

centos7.2下安装elasticsearch5.x你的java环境是没有问题的但是在启动是就会报:

which: no java in (/sbin:/bin:/usr/sbin:/usr/bin)
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME

简单解决方案是:

  1. vi /etc/sysconfig/elasticsearch
  2. 将 JAVAHOME=/root/jdk1.8.060 写到文件中保存后启动
  3. service elasticsearch start
    正在启动 elasticsearch: [确定]

这样就能解决找不到java环境的问题了。

【转载】解决Linux操作系统下AES解密失败的问题

现象描述:

windows上加解密正常,linux上加密正常,解密时发生如下异常:

javax.crypto.BadPaddingException: Given final block not properly padded

       at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
       at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
       at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA13*..)
       at javax.crypto.Cipher.doFinal(DashoA13*..)
       at chb.test.crypto.AESUtils.crypt(AESUtils.java:386)
       at chb.test.crypto.AESUtils.AesDecrypt(AESUtils.java:254)
       at chb.test.crypto.AESUtils.main(AESUtils.java:40)

解决方法:

经过检查之后,定位在生成KEY的方法上,如下:

public static SecretKey getKey (String strKey) {  
	try {           
		KeyGenerator _generator = KeyGenerator.getInstance( "AES" );  
		_generator.init(128, new SecureRandom(strKey.getBytes()));  
			return _generator.generateKey();  
	}  catch (Exception e) {  
		 throw new RuntimeException( " 初始化密钥出现异常 " );  
	}  
} 

http client调用API接口发生Stream closed错误

java中使用httpcomponents调用远程的API接口时发生Stream closed错误:

2015/08/07 13:03:12,887 ERROR [stderr] (Thread-101) java.io.IOException: Stream closed
2015/08/07 13:03:12,887 ERROR [stderr] (Thread-101)     at java.util.zip.GZIPInputStream.ensureOpen(GZIPInputStream.java:61)
2015/08/07 13:03:12,887 ERROR [stderr] (Thread-101)     at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:112)
2015/08/07 13:03:12,887 ERROR [stderr] (Thread-101)     at org.apache.http.client.entity.LazyDecompressingInputStream.read(LazyDecompressingInputStream.java:74)
2015/08/07 13:03:12,887 ERROR [stderr] (Thread-101)     at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
2015/08/07 13:03:12,887 ERROR [stderr] (Thread-101)     at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
2015/08/07 13:03:12,887 ERROR [stderr] (Thread-101)     at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
2015/08/07 13:03:12,887 ERROR [stderr] (Thread-101)     at java.io.InputStreamReader.read(InputStreamReader.java:184)
2015/08/07 13:03:12,888 ERROR [stderr] (Thread-101)     at java.io.Reader.read(Reader.java:140)
2015/08/07 13:03:12,888 ERROR [stderr] (Thread-101)     at org.apache.http.util.EntityUtils.toString(EntityUtils.java:244)
2015/08/07 13:03:12,888 ERROR [stderr] (Thread-101)     at org.apache.http.util.EntityUtils.toString(EntityUtils.java:288)
2015/08/07 13:03:12,888 ERROR [stderr] (Thread-101)     at mainThread.Search.doRequest(Search.java:70)
2015/08/07 13:03:12,888 ERROR [stderr] (Thread-101)     at mainThread.Search.search(Search.java:29)

经过查找在Stack Overflow中找到了答案。

【转载】解决 - java.lang.OutOfMemoryError: unable to create new native thread

一、概述

工作中碰到过这个问题好几次了,觉得有必要总结一下,所以有了这篇文章,这篇文章分为三个部分:认识问题、分析问题、解决问题。

二、认识问题:

首先我们通过下面这个 测试程序 来认识这个问题:
运行的环境 (有必要说明一下,不同环境会有不同的结果):32位 Windows XP,Sun JDK 1.6.0_18, eclipse 3.4,
测试程序:

import java.util.concurrent.CountDownLatch;

public class TestNativeOutOfMemoryError {

	public static void main(String[] args) {

		for (int i = 0;; i++) {
			System.out.println("i = " + i);
			new Thread(new HoldThread()).start();
		}
	}
}

class HoldThread extends Thread {
	CountDownLatch cdl = new CountDownLatch(1);

	public HoldThread() {
		this.setDaemon(true);
	}

	public void run() {
		try {
			cdl.await();
		} catch (InterruptedException e) {
		}
	}
}

【转载】MySql+Mybatis+Druid在一个Mybatis中执行多条SQL 有更新!

做一个批量update的操作 ,sqlmap如下:

<update id="updateBatch" parameterType="java.util.List">  
  <foreach collection="list" item="item" index="index" open="" close="" separator=";">  
    update devicebdtoken   
	 <set>  
	   access_token=#{item.accessToken}  
	 <set>  
    where device_id = #{item.deviceId}  
  <foreach>  
<update>

在不设置的情况下会报错:

Caused by: java.sql.SQLException: sql injection violation, multi-statement not allow : update device_bd_token 
                 SET access_token=? 
                where device_id = ?
          ; 
                update device_bd_token 
                 SET access_token=? 
                where device_id = ?
	at com.alibaba.druid.wall.WallFilter.check(WallFilter.java:714)
	at com.alibaba.druid.wall.WallFilter.connection_prepareStatement(WallFilter.java:240)
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448)
	at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:928)
	at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:122)
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448)
	at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342)
	at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:318)

刚开始以为是连接数据库的url上没有加上支持批量的参数,然后就改了下:

jdbc.url=jdbc:mysql://192.168.11.107:3306/alarm_db?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8

结果还是同样的错误!但是在命令行直接执行又是没问题的,这就很奇怪了!

浏览次数:3525599   文章总数:80   评论总数:10   当前访客:3
平常心博客 © 2018 ×
¥
每天领支付宝红包
Powered by B3log 开源Solo 2.4.0