问题
I have run into a very strange error that I can´t wrap my head around. I´m running Seam 2.2.1.CR2 and JBoss 4.3.0.GA. My application consist of 3 modules:
application.xml
<display-name>CoolWebApp</display-name>
<module id="EJB3">
<ejb>EJB3.jar</ejb>
</module>
<module id="WEB">
<web>
<web-uri>WEB.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<module>
<ejb>jboss-seam-2.2.1.CR2.jar</ejb>
</module>
The following bean is scheduled and should run asynchronously. It resides in my EJB3 module:
package com.coolwebapp.indexing;
import org.apache.commons.lang.time.DateUtils;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Startup;
import org.jboss.seam.annotations.Transactional;
import org.jboss.seam.annotations.async.Asynchronous;
import org.jboss.seam.annotations.async.Expiration;
import org.jboss.seam.annotations.async.IntervalDuration;
import org.jboss.seam.core.Events;
import org.jboss.seam.log.Log;
import com.coolwebapp.events.CompanyTouched;
import com.coolwebapp.model.Company;
import com.coolwebapp.model.CompanyInNeedOfIndexing;
import javax.persistence.EntityManager;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*/
@Name("indexBean")
@AutoCreate
public class IndexBean {
@Logger
private static Log log;
/**
* @return Will fetch an applicationBean
*/
private EntityManager entityManager() {
return (EntityManager) Component.getInstance("entityManager", true);
}
@SuppressWarnings({"unchecked"})
@Transactional
@Asynchronous
public void investigatePendingIndexings(@Expiration Date when, @IntervalDuration Long interval) {
log.info("IndexBean.investigatePendingIndexings()");
final EntityManager em = entityManager();
List<CompanyInNeedOfIndexing> indexingTasks =
em.createQuery(
"from CompanyInNeedOfIndexing C where C.hasBeenIndexedOnNode not like :nodeName")
.setParameter("nodeName", getNodeName())
.getResultList();
Map<Long, Company> idToCompanyToIndexMap = new HashMap<Long, Company>();
for (CompanyInNeedOfIndexing indexingTask : indexingTasks) {
final Company company = indexingTask.getCompany();
final long id = company.getId();
if (!idToCompanyToIndexMap.containsKey(id))
idToCompanyToIndexMap.put(id, company);
}
for (Company company : idToCompanyToIndexMap.values()) {
log.info("Indexing " + company.getName());
Events.instance().raiseEvent(CompanyTouched.EVENT_NAME, company, em);
em.persist(new CompanyInNeedOfIndexing(company, getNodeName()));
}
}
private String getNodeName() {
return "N0"; // TODO get from -D param
}
@Startup(depends = {"applicationBean", "entityManager"})
@Scope(ScopeType.APPLICATION)
@Name("indexBeanKicker")
public static class Kicker {
private final long INTERVAL = 15;
@In
private IndexBean indexBean;
@Create
public void initBean() {
log.info("Will check for indexing every " + INTERVAL + " minutes.");
final Date firstRunIn30sec = new Date(30 * DateUtils.MILLIS_PER_SECOND + System.currentTimeMillis());
indexBean.investigatePendingIndexings(
firstRunIn30sec,
INTERVAL * DateUtils.MILLIS_PER_MINUTE);
}
}
}
When the event is raised following bean picks it up(also in EJB3 module):
package com.coolwebpp.search.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.Document;
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
import org.hibernate.search.engine.DocumentBuilder;
import org.hibernate.search.jpa.FullTextEntityManager;
import org.hibernate.search.jpa.Search;
import org.hibernate.search.store.NotShardedStrategy;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Scope;
import com.coolwebapp.events.CompanyTouched;
import com.coolwebapp.model.Company;
import javax.persistence.EntityManager;
import java.io.Serializable;
@Name("indexUtils")
@AutoCreate
@Scope(ScopeType.SESSION)
public class IndexUtils implements ArticleSaved, ReviewsUpdated, CompanyPublished, CompanyRemoved, SearchWordsUpdated, CompanyTouched, Serializable {
public final static Log log = LogFactory.getLog(IndexUtils.class);
public IndexUtils() {
}
public static FullTextEntityManager getFullTextEntityManager(EntityManager entityManager) {
if (entityManager instanceof FullTextEntityManager)
return (FullTextEntityManager) entityManager;
else
return Search.createFullTextEntityManager(entityManager);
}
private void reindexWithoutModifyingLastUpdated(Company company, EntityManager entityManager) {
log.warn("--------------->>> Reindexing without updating lastModified: " + company.getName());
getFullTextEntityManager(entityManager).index(company);
}
@Observer(CompanyTouched.EVENT_NAME)
public void handleCompanyTouched(Company owningCompany, EntityManager entityManager) {
reindexWithoutModifyingLastUpdated(owningCompany, entityManager);
}
}
components.xml
<persistence:managed-persistence-context name="entityManager"
auto-create="true"
entity-manager-factory="#{entityManagerFactory}"/>
<persistence:entity-manager-factory name="entityManagerFactory"
persistence-unit-name="theDatabase"/>
When I start the application and the kicker kicks in everything works well until
getFullTextEntityManager(entityManager).index(company);
Then following exception is thrown:
11:10:34,681 ERROR [AsynchronousExceptionHandler] Exception thrown whilst executing asynchronous call
java.lang.IllegalArgumentException: interface org.jboss.seam.persistence.EntityManagerProxy 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.jboss.seam.persistence.PersistenceProvider.proxyEntityManager(PersistenceProvider.java:220)
at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyEntityManager(HibernatePersistenceProvider.java:314)
at org.jboss.seam.persistence.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:81)
at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.Component.callComponentMethod(Component.java:2275)
at org.jboss.seam.Component.unwrap(Component.java:2301)
at org.jboss.seam.Component.getInstance(Component.java:2044)
at org.jboss.seam.Component.getInstance(Component.java:1986)
at org.jboss.seam.Component.getInstance(Component.java:1980)
at com.coolwebapp.indexing.IndexBean.entityManager(IndexBean.java:43)
at com.coolwebapp.indexing.IndexBean.investigatePendingIndexings(IndexBean.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
at org.jboss.seam.util.Work.workInTransaction(Work.java:61)
at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:52)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at com.coolwebapp.indexing.IndexBean_$$_javassist_seam_2.investigatePendingIndexings(IndexBean_$$_javassist_seam_2.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.async.AsynchronousInvocation$1.process(AsynchronousInvocation.java:62)
at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:80)
at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44)
at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:243)
at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
if I add scope to my managed-persistance-context:
<persistence:managed-persistence-context name="entityManager"
auto-create="true" scope="APPLICATION"
entity-manager-factory="#{entityManagerFactory}"/>
<persistence:entity-manager-factory name="entityManagerFactory"
persistence-unit-name="theDatabase"/>
I get the following error:
10:49:46,689 WARN [HibernatePersistenceProvider] Unable to wrap into a FullTextSessionProxy, regular SessionProxy returned
java.lang.IllegalArgumentException: interface org.jboss.seam.persistence.FullTextHibernateSessionProxy 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.jboss.seam.persistence.HibernatePersistenceProvider.proxySession(HibernatePersistenceProvider.java:119)
at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:142)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.handleGetDelegate(EntityManagerInvocationHandler.java:81)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:40)
at $Proxy229.getDelegate(Unknown Source)
at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.getFullTextSession(FullTextEntityManagerImpl.java:32)
at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.index(FullTextEntityManagerImpl.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:46)
at $Proxy230.index(Unknown Source)
at com.coolwebapp.search.util.IndexUtils.reindexWithoutModifyingLastUpdated(IndexUtils.java:85)
at com.coolwebapp.search.util.IndexUtils.handleCompanyTouched(IndexUtils.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at com.coolwebapp.search.util.IndexUtils_$$_javassist_seam_21.handleCompanyTouched(IndexUtils_$$_javassist_seam_21.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.Component.callComponentMethod(Component.java:2279)
at org.jboss.seam.core.Events.raiseEvent(Events.java:85)
at com.coolwebapp.indexing.IndexBean.investigatePendingIndexings(IndexBean.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
at org.jboss.seam.util.Work.workInTransaction(Work.java:61)
at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:52)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at com.coolwebapp.indexing.IndexBean_$$_javassist_seam_2.investigatePendingIndexings(IndexBean_$$_javassist_seam_2.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.async.AsynchronousInvocation$1.process(AsynchronousInvocation.java:62)
at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:80)
at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44)
at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:243)
at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
10:49:46,702 ERROR [AsynchronousExceptionHandler] Exception thrown whilst executing asynchronous call
java.lang.RuntimeException: could not proxy delegate
at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:150)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.handleGetDelegate(EntityManagerInvocationHandler.java:81)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:40)
at $Proxy229.getDelegate(Unknown Source)
at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.getFullTextSession(FullTextEntityManagerImpl.java:32)
at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.index(FullTextEntityManagerImpl.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:46)
at $Proxy230.index(Unknown Source)
at com.coolwebapp.search.util.IndexUtils.reindexWithoutModifyingLastUpdated(IndexUtils.java:85)
at com.coolwebapp.search.util.IndexUtils.handleCompanyTouched(IndexUtils.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at com.coolwebapp.search.util.IndexUtils_$$_javassist_seam_21.handleCompanyTouched(IndexUtils_$$_javassist_seam_21.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.Component.callComponentMethod(Component.java:2279)
at org.jboss.seam.core.Events.raiseEvent(Events.java:85)
at com.coolwebapp.indexing.IndexBean.investigatePendingIndexings(IndexBean.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
at org.jboss.seam.util.Work.workInTransaction(Work.java:61)
at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:52)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at com.coolwebapp.indexing.IndexBean_$$_javassist_seam_2.investigatePendingIndexings(IndexBean_$$_javassist_seam_2.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.async.AsynchronousInvocation$1.process(AsynchronousInvocation.java:62)
at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:80)
at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44)
at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:243)
at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
Caused by: java.lang.IllegalArgumentException: interface org.jboss.seam.persistence.HibernateSessionProxy 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.jboss.seam.persistence.HibernatePersistenceProvider.proxySession(HibernatePersistenceProvider.java:125)
at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:142)
... 74 more
The fulltextentitymanager comes from hibernatesearch-3.0.1.GA.
If I remove the line calling .index saving the entity works( em.persist(new CompanyInNeedOfIndexing(company, getNodeName())); ), but only if I have the scope set to APPLICATION.
Do you have any ideas why this doesn't work? Do you any tips or do you need more information?
回答1:
Short answer:
Check if hibernatesearch.jar
and quartz.jar
are in the same library directory, that is both in default/lib
(or <yourserver>/lib
).
You may have quartz.jar
coming from quartz-ra.rar
, that should also works. However, if you don't need the quart-ra.rar
facilities I suggest you to remove it and put quartz.jar
in default/lib
.
Long answer:
When you configure the Quartz dispatcher to manage asynchronous jobs in Seam, that jobs run in the quartz threads pool that is created at startup time. There is much logic in Java EE that depends on Thread.currentThread().getContextClassLoader()
so it's critical for the threads in the pool to be associated to the correct classloader.
What you should avoid is reusing the thread pool that is commonly created by the quartz-ra.rar
module installed by default in JBoss.
You have two options here. Either you remove quartz-ra.rar
module (if not needed) and put quartz.jar in server/lib, or you configure a custom quartz configuration for your application creating a seam.quartz.properties file in the root of the application classpath.
In the custom seam.quartz.properties
you define an instance name different by the default one, so that your application keeps using her private threads pool:
org.quartz.scheduler.instanceName = MyApplicationQuartzInstance
org.quartz.scheduler.instanceId = 1
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 5
Creating a seam.quartz.properties
is a good idea anyway, because you can tune some other quartz parameters like threadCount
.
来源:https://stackoverflow.com/questions/5431190/fulltexthibernatesessionproxy-is-not-visible-from-class-loader