FullTextHibernateSessionProxy 从类加载器中不可见

发布于 2024-10-26 17:04:58 字数 26132 浏览 5 评论 0原文

我遇到了一个非常奇怪的错误,我无法理解。我正在运行 Seam 2.2.1.CR2 和 JBoss 4.3.0.GA。我的应用程序由 3 个模块组成:

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>

以下 bean 已计划并应异步运行。它驻留在我的 EJB3 模块中:

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);
        }
    }

}

当引发事件时,以下 bean 会拾取它(也在 EJB3 模块中):

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"/>

当我启动应用程序并且踢球器启动时,一切正常,直到

getFullTextEntityManager(entityManager).index(company);

然后抛出以下异常:

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)

如果我添加范围到我的托管持久性上下文:

<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"/>

我收到以下错误:

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

fulltextentitymanager 来自 hibernatesearch-3.0.1.GA。

如果我删除调用 .index 保存实体的行( em.persist(new CompanyInNeedOfIndexing(company, getNodeName())); ),但前提是我将范围设置为 APPLICATION。

您知道为什么这行不通吗?您有什么建议或需要更多信息吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那片花海 2024-11-02 17:04:58

简短回答:

检查hibernatesearch.jarquartz.jar是否位于同一个库目录中,即都在default/lib中(或/lib)。

您可能有来自 quartz-ra.rarquartz.jar,它也应该可以工作。但是,如果您不需要 quart-ra.rar 设施,我建议您将其删除并将 quartz.jar 放入 default/lib >。

长答案

当您配置 Quartz 调度程序来管理 Seam 中的异步作业时,该作业在启动时创建的quartz 线程池中运行。 Java EE 中有很多逻辑依赖于 Thread.currentThread().getContextClassLoader(),因此将池中的线程关联到正确的类加载器至关重要。

您应该避免重用通常由 JBoss 中默认安装的 quartz-ra.rar 模块创建的线程池。

这里你有两个选择。您可以删除 quartz-ra.rar 模块(如果不需要)并将quartz.jar 放入 server/lib 中,或者为您的应用程序配置自定义的quartz 配置,并在应用程序类路径的根。

在自定义 seam.quartz.properties 中,您定义一个与默认名称不同的实例名称,以便您的应用程序继续使用她的私有线程池:

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

创建一个 seam.quartz.properties无论如何,> 是一个好主意,因为您可以调整其他一些quartz参数,例如threadCount

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文