我的应用程序,在JBoss 5中运行,需要启动一个线程来异步执行一些工作。代码使用'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
启动该线程的代码如下:
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)
我认为问题是JBoss线程池和我的应用程序(EAR)之间的不同类加载器。问题出现在引用Hibernate时,系统中有两个版本(一个在JBoss中,一个在EAR中)。
是否可以在JBoss-5中以这种方式使用JBoss线程池?或者我是否需要在应用程序中定义自己的线程池,可能在JCA适配器中?
答案 0 :(得分:0)
你耳朵里有jboss-app.xml吗?看一下这个站点的JBoss类加载隔离问题http://community.jboss.org/wiki/ClassLoadingConfiguration