我在OpenShift上遇到WildFly AS的问题。当我尝试在服务器上部署WAR时,我会继续跟踪异常。
2014-12-20 04:31:33,072 INFO [org.jboss.as.connector.deployment] (MSC service thread 1-7) JBAS010406: Registered connection factory java:/JmsXA
2014-12-20 04:31:33,444 ERROR [org.hornetq.core.client] (Thread-0 (HornetQ-client-global-threads-32821528)) HQ214017: Caught unexpected Throwable: java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method) [rt.jar:1.8.0_05]
at java.lang.Thread.start(Thread.java:714) [rt.jar:1.8.0_05]
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950) [rt.jar:1.8.0_05]
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1368) [rt.jar:1.8.0_05]
at org.hornetq.core.client.impl.ClientSessionFactoryImpl$Channel0Handler.notifyTopologyChange(ClientSessionFactoryImpl.java:1618) [hornetq-core-client-2.4.5.Final.jar:]
at org.hornetq.core.client.impl.ClientSessionFactoryImpl$Channel0Handler.handlePacket(ClientSessionFactoryImpl.java:1609) [hornetq-core-client-2.4.5.Final.jar:]
at org.hornetq.core.protocol.core.impl.ChannelImpl.handlePacket(ChannelImpl.java:641) [hornetq-core-client-2.4.5.Final.jar:]
at org.hornetq.core.protocol.core.impl.RemotingConnectionImpl.doBufferReceived(RemotingConnectionImpl.java:556) [hornetq-core-client-2.4.5.Final.jar:]
at org.hornetq.core.protocol.core.impl.RemotingConnectionImpl.bufferReceived(RemotingConnectionImpl.java:532) [hornetq-core-client-2.4.5.Final.jar:]
at org.hornetq.core.client.impl.ClientSessionFactoryImpl$DelegatingBufferHandler.bufferReceived(ClientSessionFactoryImpl.java:1712) [hornetq-core-client-2.4.5.Final.jar:]
at org.hornetq.core.remoting.impl.invm.InVMConnection$1.run(InVMConnection.java:165) [hornetq-server-2.4.5.Final.jar:]
at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:104) [hornetq-core-client-2.4.5.Final.jar:]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_05]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_05]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_05]
我不知道它是否相关但我认为当我将hibernate添加到我的应用程序时错误开始了。这是hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.datasource">java:comp/env/jdbc/MyDataSource</property>
<property name="hibernate.current_session_context_class">thread</property>
<!-- GENERAL CONFIGURATION -->
<property name="connection.pool_size">1</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.connection.release_mode">after_statement</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.connection.defaultAutoCommit">false</property>
<!-- DB MAPING -->
</session-factory>
</hibernate-configuration>
我的HibernateUtil.java
:
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
public class HibernateUtil {
private static SessionFactory sessionFactory;
public static SessionFactory getSessionFactory() {
if (sessionFactory == null) {
// loads configuration and mappings
Configuration configuration = new Configuration().configure();
ServiceRegistry serviceRegistry
= new StandardServiceRegistryBuilder()
.applySettings(configuration.getProperties()).build();
// builds a session factory from the service registry
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
}
return sessionFactory;
}
}
我的DaoImpl的一部分用于登录:
public User login(String username, String password) {
User result = null;
Session session = HibernateUtil.getSessionFactory().openSession();
try {
String sql = "select s from User s where username=:username and password=password(:password)";
Query query = session.createQuery(sql);
query.setString("username", username);
query.setString("password", password);
result = (User) query.uniqueResult();
}
finally {
session.close();
}
return result;
}
我不是百分之百地避免了hibernate的问题,因为我通过SSH连接了wildfly/standalone/deployments/
并重新启动了应用程序,但我执行{时仍然遇到了错误{1}}命令。
gear start
答案 0 :(得分:5)
查看此thread。
我发现我必须禁用
不仅消息,还有 clustering.jgroups 。但是,之后我偶尔遇到OutOfMemoryError
。我限制了数据库连接池。默认情况下它是无限的。
可悲的是,这还不够,我也跟着
走了仍然没有为phpMyAdmin留下线程:(令人沮丧......
答案 1 :(得分:4)
小型齿轮的线程限制为250个线程,尝试将消息传递服务的线程数限制为50(甚至根据应用程序尝试20个)。
配置位于standalone.xml
文件中。
<强>例如强>
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
<hornetq-server>
<thread-pool-max-size>50</thread-pool-max-size>
<scheduled-thread-pool-max-size>50</scheduled-thread-pool-max-size>
<!-- ... -->
</hornetq-server>
</subsystem>
我希望这有帮助。