我正在尝试为现有的 Java EE 应用程序编写集成测试,该应用程序使用 Seam 和 Hibernate 并部署到 Glassfish。
然而,测试目前未能在一开始就启动 Seam。这似乎是因为它无法实例化 Quartz Scheduler 组件 - 请参见下面的代码。异常堆栈跟踪也在下面。
任何帮助将非常感激...
这些可能是不必要的细节,但我使用 JUnit(而不是 TestNG)编写了测试,如此处所述。该测试扩展了 AbstractSeamTest 并具有实例化 ComponentTest 并覆盖 testComponents 的 @Test 方法,如此处所述。该应用程序在 Maven 的预集成阶段使用 Cargo 部署到现有的本地 Glassfish 实例,并使用 Failsafe 插件运行测试。
初始化石英类:
@Name("initialiseQuartz")
@Scope(ScopeType.APPLICATION)
@Startup
public class InitialiseQuartz {
private QuartzTriggerHandle qth;
@In(create=true)
private EmailService emailService;
@Create
public void startSchedule() {
System.out.print("Schedule started");
qth = emailService.generateDailyEmail("0 0 7 * * ?");
}
@Destroy
public void stopSchedule() {
try {
qth.cancel();
} catch (SchedulerException se) {
}
}
}
堆栈跟踪:
org.jboss.seam.InstantiationException: Could not instantiate Seam component: initialiseQuartz
at org.jboss.seam.async.AbstractDispatcher.extractAndValidateParameters(AbstractDispatcher.java:171)
at org.jboss.seam.async.AbstractDispatcher.createTimerSchedule(AbstractDispatcher.java:113)
at org.jboss.seam.async.ThreadPoolDispatcher.scheduleInvocation(ThreadPoolDispatcher.java:56)
at org.jboss.seam.async.ThreadPoolDispatcher.scheduleInvocation(ThreadPoolDispatcher.java:30)
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.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 org.jboss.seam.async.ThreadPoolDispatcher_$$_javassist_seam_3.scheduleInvocation(ThreadPoolDispatcher_$$_javassist_seam_3.java)
at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:40)
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 uk.police.kent.optica.schedule.EmailService_$$_javassist_seam_2.generateDailyEmail(EmailService_$$_javassist_seam_2.java)
at uk.police.kent.optica.schedule.InitialiseQuartz.startSchedule(InitialiseQuartz.java:26)
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.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
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 uk.police.kent.optica.schedule.InitialiseQuartz_$$_javassist_seam_1.startSchedule(InitialiseQuartz_$$_javassist_seam_1.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:2275)
at org.jboss.seam.Component.callCreateMethod(Component.java:2198)
at org.jboss.seam.Component.newInstance(Component.java:2158)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:143)
at org.jboss.seam.init.Initialization.init(Initialization.java:744)
at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:929)
at com.ipl.rdhi.acceptance.RdhiAdapterIT.setUpBeforeClass(RdhiAdapterIT.java:118)