开发者

java.lang.IllegalArgumentException: interface org.jboss.seam.persistence.EntityManagerProxy is not visible from class loader

I have run into a pretty strange error that I can't get my head around. In short: I have an ImporterBean that should read an xml file and then do s开发者_JS百科tuff. That ImporterBean is "kickstarted" by a ImporterKicker, but when I start the app the ApplicationBean and EntityManager in the ImporterBean class are null. They are not injected into that bean. In the KickerBean the ImporterBean and ApplicationBean are injected properly.

See code below and please tell me what I'm doing wrong(Using seam SEAM 2.2.1.CR2).

@SuppressWarnings({"UnusedDeclaration"})
@Name("importerBean")
@AutoCreate
public class ImporterBean {

private static final FilenameFilter ONLY_XML_FILES = (FilenameFilter) new SuffixFileFilter(".xml");
public static final String IN_DIR = "IN";
public static final String ERROR_DIR = "ERROR";
public static final String PROCESSED_DIR = "PROCESSED";

@In(create = true)
public ApplicationBean applicationBean;

@In
private EntityManager entityManager;


@Asynchronous
@Transactional
public void runImport(@Duration long firstStart, @IntervalDuration long startTimer) {
    log.info("<118100>");
    File inDir = Doing some file stuff...
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

/**
 * Inner class bean to kick the background tasks.
 */
@Startup
@Scope(APPLICATION)
@Name("importerKicker")
public static class ImporterKicker {


    @In(create = true)
    public ImporterBean importerBean;

    @In(create = true)
    public ApplicationBean applicationBean;

    @Create
    public void scheduleOptimizer() {
        final int interval = applicationBean.getImporter118checkInterval();
        if (interval != 0) {

            importerBean.runImport(30 * MILLIS_PER_SECOND, interval * MILLIS_PER_SECOND);
        } else {
        }
    }

}

}


This error was a symptom of this: FullTextHibernateSessionProxy is not visible from class loader


Since you are using an Asynchronous call, you cannot use injections like that in an event scoped component.

Instead inside the Asyncrhonous method write:

@Asynchronous
@Transactional
public void runImport(@Duration long firstStart, @IntervalDuration long startTimer) {
    EntityManager entityManager = (EntityManager) Component.getInstance("entityManager");
    ApplicationBean applicationBean = (ApplicationBean) Component.getInstance("applicationBean",true);
    log.info("<118100>");
    File inDir = Doing some file stuff...
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜