Error with HtmlUnit / WebClient / WildFly10

1

I'm trying to use htmlunit but it's happening:

*** Environment / Server: WildFly10

When you run the following command:

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_45);

The error happens:

17:34:19,139 WARN  [org.jboss.modules] (default task-4) Failed to define class com.gargoylesoftware.htmlunit.html.DomElement in Module "deployment.teste.war:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link com/gargoylesoftware/htmlunit/html/DomElement (Module "deployment.teste.war:main" from Service Module Loader): org/w3c/dom/ElementTraversal
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
at org.jboss.modules.Module.loadModuleClass(Module.java:605)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:358)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:437)
   .
   .
   .
Caused by: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: Failed to link com/gargoylesoftware/htmlunit/html/BaseFrameElement (Module "deployment.teste.war:main" from Service Module Loader): Failed to link com/gargoylesoftware/htmlunit/html/HtmlElement (Module "deployment..war:main" from Service Module Loader): Failed to link com/gargoylesoftware/htmlunit/html/DomElement (Module "deployment.sigeap.war:main" from Service Module Loader): org/w3c/dom/ElementTraversal
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 50 more  
   .
   .
   .
17:34:19,168 ERROR [io.undertow.request] (default task-4) UT005023: Exception handling request to /teste/pages/teste/teste.jsf: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Failed to link com/gargoylesoftware/htmlunit/html/BaseFrameElement (Module "deployment.teste.war:main" from Service Module Loader): Failed to link  

Maven:

<dependency>     
     <groupId>net.sourceforge.htmlunit</groupId>     
     <artifactId>htmlunit</artifactId>            
     <version>2.23</version> 
</dependency>
    
asked by anonymous 03.10.2016 / 22:48

1 answer

1

I had the same problem, but I decided to put a version compatible with my project. I discovered that some libraries of my project were clashing with HtmlUnit. When I modified the version of HtmlUnit that contained the same dependencies of my project everything worked correctly.

Httpclient-4.2.1 (used in my project) was in conflict with HtmlUnit-2.21 (which uses httpclient-4.5.2.jar). So I switched to the HtmlUnit version 2.10 (which uses Httpclient-4.2.1) and everything worked correctly.

    
29.08.2018 / 22:33