-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JBrowserDriver does not work inside of Java EE server (wildfly) #229
Comments
I don't think there's a workaround for now. This project depends on https://github.com/lukehutch/fast-classpath-scanner and we need to update to the latest version of that. That's what gets the classpath at runtime that allows us to spawn a java process. |
Actually ... JBrowserDriver implements remote ... I'm not sure, but is it possible that I can expose this as an executable on my system just like phantomjs, then simply remote control it that way? Then, I wouldn't need to worry about whatever classpath scanner stuff is going on because I'd be isolated from that: https://github.com/MachinePublishers/jBrowserDriver#usage |
Just made a commit to allow a custom classpath to be set like this: |
Great, where do I get the uber jar, do I have to modify the pom.xml and then build it? |
Added an uber jar to the artifacts released on Maven Central, starting with v0.17.3. To pull in the uber jar if you use maven do something like this: <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.machinepublishers</groupId>
<artifactId>jbrowserdriver</artifactId>
<version>0.17.3</version>
<classifier>uberjar</classifier>
<outputDirectory>target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin> This would be needed in addition to the normal dependency: <dependencies>
<dependency>
<groupId>com.machinepublishers</groupId>
<artifactId>jbrowserdriver</artifactId>
<version>0.17.3</version>
</dependency>
</dependencies> |
There's probably a better way to make use of the uber jar... Following the above essentially duplicates the dependency (adding 16MB instead of 8MB). |
This works, but now I am getting NoSuchElementExceptions when trying to use Yandex's AShot library to take screenshots. The same code worked fine with RemoteWebDriver setup, but I could not use a proxy with the remote instance. |
A child process is launched with JBrowserDriver. To do this it needs the classpath at runtime. Something in wildfly is preventing that from happening. Still need to update the dependency which helps get the classpath. Add the yandex lib to the classpath in |
Ah, thanks, very clever ... I appreciate your timely help:). |
I'm actually running it on the command line through Weld-SE, so the CDI container is active. I tried that and got the same error. You made a good point, I may need to include other libraries that AShot relies on ... |
I am still not having luck, I understand that jbrowserdriver launches a child process, but I guess I'm having difficulty understanding why it would need the full classpath. Wouldn't just the "client" implementation or jar suffice? I tried a bunch of combinations, I'm using an uber jar with the main class being Weld SE something. i tried passing in that uber jar, the uber jar with jbrowserdriver's uber jar, etc. I continue getting the NoSuchElementException. Thanks for your help. Walter |
The problem was due to the improper scoping of beans. I had multiple instances of a web driver ... the first one actually did the crawling, and the second one was used for the screenshot. In my logs, this was apparent because there were multiple processes opened up instead of just one. |
I am unable to utilize JBrowserDriver inside of a Java EE server (wildfly 10). I guess it has something to do with the fact that JBrowserDriverServer has a main method and is attempting to do things on startup that should be called in the proper manner inside an EE environment.
Is there a workaround for this?
See issue below:
06:52:56,795 WARNING [com.machinepublishers.jbrowserdriver] (Thread-106) Error: Could not find or load main class com.machinepublishers.jbrowserdriver.JBrowserDriverServer
06:52:56,972 WARNING [com.machinepublishers.jbrowserdriver] (Thread-109) Error: Could not find or load main class com.machinepublishers.jbrowserdriver.JBrowserDriverServer
06:52:57,074 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 70) MSC000001: Failed to start service jboss.deployment.unit."service-0.1-SNAPSHOT.war".component.DefaultCrawlerProcessor.START: org.jboss.msc.service.StartException in service jboss.deployment.unit."service-0.1-SNAPSHOT.war".component.DefaultCrawlerProcessor.START: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:57)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)
at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134)
at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:88)
at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:124)
at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:138)
at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54)
The text was updated successfully, but these errors were encountered: