[英]Tomcat 7.0.42 server crash randomly in windows
I am running java maven project on tomcat server. 我在tomcat服务器上运行java maven项目。 This is a server side script using atmosphere framework for chat app. 这是一个使用大气框架聊天应用程序的服务器端脚本。
When socket.fire("message="+"testmessage")
is fired from client side to server the some times the following error is getting in tomcat console. 当从客户端到服务器触发socket.fire("message="+"testmessage")
有时,以下错误在tomcat控制台中出现。
Oct 16, 2013 7:26:39 PM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
This error is getting randomly. 该错误越来越随机。
And sometimes the server crashes due to which all the message transmission fails. 有时服务器崩溃,导致所有消息传输失败。
I am using following server side code for message broadcasting: @Path("/pubsub/{topic}") public class JerseyPubSub { 我正在使用以下服务器端代码进行消息广播:@Path(“ / pubsub / {topic}”)公共类JerseyPubSub {
private @PathParam("topic")
Broadcaster topic;
@GET
public SuspendResponse<String> subscribe() {
return new SuspendResponse.SuspendResponseBuilder<String>()
.broadcaster(topic)
.outputComments(true)
.addListener((AtmosphereResourceEventListener) new EventsLogger())
.build();
}
@POST
@Broadcast
@Produces("text/html;charset=ISO-8859-1")
public Broadcastable publish(@FormParam("message") String message) throws JSONException, IOException, SQLException {
JedisPool pool = new JedisPool(new JedisPoolConfig(), "localhost", 6379);
Jedis jedis = pool.getResource();
int remote_id = 0;
int local_id = 0;
int from = 0;
int to = 0;
String msg = null;
int chatroomid = 0;
JSONObject json = new JSONObject();
JSONObject sender_respondejson = new JSONObject();
String msg_for = null;
String msg_content = null;
String msg_type = null;
//{"local_id": "123", "from": "100", "to": "200", "message": "'+getElementByIdValue("phrase")+'", "msg_for": "0", "msg_content": "0", "msg_type": "0"}
JSONObject msgObject = new JSONObject(message.toString());
//if(msgObject.has("msg_for")){
msg_for = msgObject.getString("msg_for");
msg_content = msgObject.getString("msg_content");
msg_type = msgObject.getString("msg_type");
if (msg_for.equals("0")) {
//One-to-one message
if (msg_content.equals("0")) {
if (msg_type.equals("0")) {
local_id = msgObject.getInt("local_id");
from = msgObject.getInt("from");
to = msgObject.getInt("to");
msg = msgObject.getString("message");
//json.put("local_id", local_id);
json.put("from", from+"");
json.put("to", to+"");
json.put("message", msg);
Date now = new Date();
Long sent = new Long(now.getTime() / 1000);
json.put("sent", sent);
String key = (from + "_" + to);
String rkey = (to + "_" + from);
String val = json.toString();
jedis.rpush(key, val);
jedis.rpush(rkey, val);
String history = (jedis.lrange(key, 0, 10)).toString();
jedis.set(msg, history);
MysqlConnection mysqlcon = new MysqlConnection();
String lastmessageid = mysqlcon.send_message(message, sent);
sender_respondejson.put("remote_id", lastmessageid);
sender_respondejson.put("local_id", local_id);
sender_respondejson.put("to", to+"");
sender_respondejson.put("msg_for", msg_for);
sender_respondejson.put("msg_content", msg_content);
sender_respondejson.put("msg_type", "1");
json.put("remote_id", lastmessageid);
json.put("msg_for", msg_for);
json.put("msg_content", msg_content);
json.put("msg_type", msg_type);
jedis.publish(to + "", json.toString());
} else if (msg_type.equals("2")) {
//{"to": "1", "remote_id": "234", "msg_content": "0", "msg_for": "0", "msg_type": "2"}
from = msgObject.getInt("from");
to = msgObject.getInt("to");
remote_id = msgObject.getInt("remote_id");
json.put("remote_id", remote_id+"");
json.put("to", to+"");
json.put("msg_for", msg_for);
json.put("msg_content", msg_content);
json.put("msg_type", msg_type);
MysqlConnection mysqlcon = new MysqlConnection();
mysqlcon.update_message_status(remote_id);
sender_respondejson.put("remote_id", remote_id);
sender_respondejson.put("msg_for", msg_for);
sender_respondejson.put("msg_content", msg_content);
sender_respondejson.put("msg_type", "3");
jedis.publish(from + "", json.toString());
}
}
} else if (msg_for.equals("1")) {
//Chatroom message
if (msg_content.equals("0")) {
if (msg_type.equals("0")) {
local_id = msgObject.getInt("local_id");
from = msgObject.getInt("from");
chatroomid = msgObject.getInt("chatroomid");
to = chatroomid;
msg = msgObject.getString("message");
Date now = new Date();
Long timestamp = new Long(now.getTime() / 1000);
MysqlConnection mysqlcon = new MysqlConnection();
String chatroomusersjson = mysqlcon.send_chatroom_message(message, timestamp, msg_content);
json.put("from", from+"");
json.put("message", msg);
json.put("chatroomid", chatroomid+"");
json.put("msg_for", msg_for);
json.put("msg_content", msg_content);
json.put("msg_type", msg_type);
String key = "chatroom_" + chatroomid;
String val = json.toString();
jedis.rpush(key, val);
JSONObject chatroomusersjsonobject = new JSONObject(chatroomusersjson);
JSONArray chartoomusers = chatroomusersjsonobject.getJSONArray("chatroomusers");
String lastchatroommessageid = chatroomusersjsonobject.getString("lastchatroommessageid");
json.put("remote_id", lastchatroommessageid);
sender_respondejson.put("local_id", local_id);
sender_respondejson.put("remote_id", lastchatroommessageid);
sender_respondejson.put("msg_for", msg_for);
sender_respondejson.put("msg_content", msg_content);
sender_respondejson.put("msg_type", "1");
for (int i = 0; i < chartoomusers.length(); i++) {
to = chartoomusers.getInt(i);
jedis.publish(to + "", json.toString());
}
/*for(int i=0; i<500; i++){
jedis.publish(to + "", i+ " " + chatroomusersjson + " " +json.toString());
}*/
}
}
} else if (msg_for.equals("2")) {
//Group message
}
//}
/*String[] temptp = topic.toString().split("Name: ");
String[] temptp1 = temptp[1].split("AtmosphereResource:");
String[] temptp2 = topic.toString().split(temptp1[0]);
String newtopic = "Name: " + to + " " + temptp2[1];*/
return new Broadcastable(sender_respondejson.toString(), "", topic);
}
} }
Can anyone tell me what should I do to avoid this crash of the tomcat server. 谁能告诉我该怎么办才能避免tomcat服务器崩溃。
log info is less. 日志信息较少。 please show me more info. 请向我显示更多信息。
This is similar to this SO question: " No provider classes found: when running Jersey REST example application ". 这类似于以下SO问题:“未找到提供程序类:运行Jersey REST示例应用程序时 ”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.