我正在尝试在无状态EJB计时器服务中执行selenium。 所采取的步骤是:
1-我创建了无状态EJB服务
@Stateless
public class AutomaticSayHello {
private static final Logger logger = Logger.getLogger(AutomaticSayHello.class);
@EJB
private DefaultController defaultController;
@Resource
private TimerService timerService;
@Schedule(hour="*",minute="*/1",persistent=false)
public void automaticHelloService(){
try{
ChromeWrapper chWrapper = ChromeWrapper.getInstance();
chWrapper.get("http:://google.com");
}catch(Exception ex){
logger.info(ex.getMessage());
}
}
}
(在我的项目中,我将ChromeDriver包装在一个名为ChromeWrapper的类中,以支持某些方法的某些快捷方式)
2-在ejb项目的pom.xml文件中导入已存在的selenium项目。
<dependencies>
<dependency>
<groupId>com.ozmuzik.remote</groupId>
<artifactId>remote-mobile</artifactId>
<version>0.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
[INFO] --- wildfly-maven-plugin:1.1.0.Alpha11:deploy (default-cli) @ ozmuzik-test-server-ejb ---
Eyl 25, 2016 10:38:59 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.1.Final
Eyl 25, 2016 10:39:00 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.1.Final
Eyl 25, 2016 10:39:00 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.9.Final
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.176 s
[INFO] Finished at: 2016-09-25T10:39:00+03:00
[INFO] Final Memory: 19M/272M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Alpha11:deploy (default-cli) on project ozmuzik-test-server-ejb: Failed to execute goal deploy: {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"ozmuzik-test-server-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"ozmuzik-test-server-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"ozmuzik-test-server-ejb-0.0.1-SNAPSHOT.jar\"
[ERROR] Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class com.ozmuzik.test.server.timer.AutomaticSayHello with ClassLoader ModuleClassLoader for Module \"deployment.ozmuzik-test-server-ejb-0.0.1-SNAPSHOT.jar:main\" from Service Module Loader
[ERROR] Caused by: java.lang.NoClassDefFoundError: com/facebook/mobile/selenium/ChromeWrapper
[ERROR] Caused by: java.lang.ClassNotFoundException: com.mobile.selenium.ChromeWrapper from [Module \"deployment.ozmuzik-test-server-ejb-0.0.1-SNAPSHOT.jar:main\" from Service Module Loader]"},"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"ozmuzik-test-server-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE"],"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}}}
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
任何人解释为什么会出现这个问题? 我也想知道如何执行一些不属于EJB的代码?
为简单起见,我的目标是执行一项服务,使用selenium抓取一些信息并自动执行ejb。