java.lang.IllegalArgumentException:接口 org.jboss.seam.persistence.EntityManagerProxy 在类加载器中不可见
我遇到了一个非常奇怪的错误,我无法理解。 简而言之:我有一个 ImporterBean,它应该读取 xml 文件然后执行操作。 该 ImporterBean 是由 ImporterKicker“启动”的,但是当我启动应用程序时 ImporterBean 类中的 ApplicationBean 和 EntityManager 为 null。他们是 没有注入到那个豆子中。在 KickerBean 中,ImporterBean 和 ApplicationBean 已正确注入。
请参阅下面的代码,请告诉我我做错了什么(使用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 {
}
}
}
}
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 stuff.
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 {
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此错误是以下症状:
FullTextHibernateSessionProxy 在类加载器中不可见
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: