简体   繁体   English

使用jboss5线程池启动线程

[英]starting thread using jboss5 thread pool

My application, running in JBoss 5, needs to start a thread to perform some work asynchronously. 我的应用程序在JBoss 5中运行,需要启动一个线程才能异步执行一些工作。 The code uses the 'ThreadPoolMBean' to use a thread from JBoss's own thread pool -- this worked in JBoss 4 but now seems to be running up against classloader problems, since I get this exception: 代码使用'ThreadPoolMBean'使用JBoss自己的线程池中的线程-这在JBoss 4中有效,但是现在似乎遇到了类加载器问题,因为我得到了以下异常:

14:52:15,918 WARN [org.jboss.util.threadpool.RunnableTaskWrapper] (JBoss System Threads(1)-413:) Unhandled throwable for runnable: application.NSP@4c80c3ab () 
    org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.IllegalArgumentException: interface org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:596)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:127)
    at application.NSP.run(NotfallStopperProzess.java:105)
    at org.jboss.util.threadpool.RunnableTaskWrapper.run(RunnableTaskWrapper.java:147)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalArgumentException: interface org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
    at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
    at org.hibernate.jdbc.BorrowedConnectionProxy.generateProxy(BorrowedConnectionProxy.java:67)
    at org.hibernate.jdbc.ConnectionManager.borrowConnection(ConnectionManager.java:163)
    at org.hibernate.jdbc.JDBCContext.borrowConnection(JDBCContext.java:111)
    at org.hibernate.impl.SessionImpl.connection(SessionImpl.java:360)
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:507)
    ... 8 more

The code to start the thread is as follows: 启动线程的代码如下:

MBeanServer server = MBeanServerLocator.locateJBoss();
ObjectName objName;
objName = new ObjectName("jboss.system:service=ThreadPool");
ThreadPoolMBean poolMBean =
   (ThreadPoolMBean) MBeanServerInvocationHandler.newProxyInstance(server, objName, ThreadPoolMBean.class, false);
poolMBean.getInstance().run(runnable)

I assume the problem is the differing classloader between the JBoss thread pool and my application (EAR). 我认为问题是JBoss线程池和我的应用程序(EAR)之间的类加载器不同。 The problem occurs referencing Hibernate, of which there are two versions in the system (one in JBoss and one in the EAR). 引用Hibernate时会发生问题,系统中有两个版本(JBoss中一个版本和EAR中一个版本)。

Is it possible to use the JBoss thread pool in this way in JBoss-5? 是否可以在JBoss-5中以这种方式使用JBoss线程池? Or do I need to define my own thread pool in the application, maybe in a JCA adapter? 还是我需要在应用程序中(也许在JCA适配器中)定义自己的线程池?

Do you have a jboss-app.xml in your ear? 您的耳朵中有jboss-app.xml吗? Take a look at this site for JBoss classloading isolation issues http://community.jboss.org/wiki/ClassLoadingConfiguration 在此站点上查看有关JBoss类加载隔离问题的信息, 网址为http://community.jboss.org/wiki/ClassLoadingConfiguration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM