FullTextHibernateSessionProxy не отображается из загрузчика классов - PullRequest
2 голосов
/ 25 марта 2011

Я столкнулся с очень странной ошибкой, что не могу обернуть голову.Я использую 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>

Следующий компонент запланирован и должен работать асинхронно.Он находится в моем модуле 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);
        }
    }

}

Когда событие вызывается, его получает компонент (также в модуле 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);
    }

}

component.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

Менеджер fulltextentity происходит из hibernatesearch-3.0.1.GA.

Если я удаляювызов строки .index сохранение сущности работает (em.persist (new CompanyInNeedOfIndexing (company, getNodeName ()));), но только если у меня установлена ​​область действия APPLICATION.

Есть ли у вас идеи, почему этоне работает?Есть ли у вас какие-либо советы или вам нужна дополнительная информация?

1 Ответ

6 голосов
/ 26 марта 2011

Краткий ответ:

Проверьте, находятся ли hibernatesearch.jar и quartz.jar в одном и том же каталоге библиотеки, то есть в default/lib (или <yourserver>/lib).

У вас может быть quartz.jar от quartz-ra.rar, который также должен работать.Однако, если вам не нужны средства quart-ra.rar, я предлагаю вам удалить их и поставить quartz.jar в default/lib.

Длинный ответ:

При настройке диспетчера Quartz для управления асинхронными заданиями в Seam эти задания запускаются в пуле кварцевых потоков, который создается во время запуска.В Java EE много логики, которая зависит от Thread.currentThread().getContextClassLoader(), поэтому крайне важно, чтобы потоки в пуле были связаны с правильным загрузчиком классов.

Чего следует избегать, так это повторного использования пула потоков, который обычно создаетсямодуль quartz-ra.rar установлен по умолчанию в JBoss.

У вас есть два варианта здесь.Либо вы удалите модуль quartz-ra.rar (если не нужен) и поместите quartz.jar в server / lib, либо сконфигурируете пользовательскую конфигурацию кварца для своего приложения, создав файл seam.quartz.properties в корне пути к классам приложения.

В пользовательском 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 - хорошая идеяв любом случае, потому что вы можете настроить некоторые другие параметры кварца, такие как threadCount.

...