gpt4 book ai didi

maven - 尝试在 Glassfish 上创建 WebClient 时出现 NoSuchMethodError

转载 作者:行者123 更新时间:2023-12-02 09:37:01 24 4
gpt4 key购买 nike

我正在尝试创建一个 HtmlUnit WebClient,以便解析 Glassfish 上 Java EE Servlet 过滤器 内的 Ember 应用程序网页服务器。

servlet 代码:

  final WebClient webClient = new WebClient(); // causes error
HtmlPage page = webClient.getPage(originalUrl);

pom.xml

<build>
<plugins>
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<version>1.29</version>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
<configuration>
<configFile>enunciate.xml</configFile>
<enunciateArtifactId/>
<enunciateArtifactId/>
<moduleName/>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceExcludes>**/web.xml</warSourceExcludes>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.15</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.15</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>

<dependency>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>enunciate-rt</artifactId>
<version>1.29</version>
</dependency>

<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-core</artifactId>
<version>4.0.6</version>
</dependency>

<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-tcp</artifactId>
<version>4.0.6</version>
</dependency>

<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-extensions</artifactId>
<version>4.0.6</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>com.paymill</groupId>
<artifactId>paymill-java</artifactId>
<version>5.0.0</version>
</dependency>

<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.3m</version>
</dependency>

<dependency>
<groupId>com.restfb</groupId>
<artifactId>restfb</artifactId>
<version>1.7.1</version>
</dependency>

<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.19.1</version>
</dependency>

<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson</artifactId>
<version>1.19.0</version>
</dependency>

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-plus</artifactId>
<version>v1-rev209-1.19.1</version>
</dependency>

<dependency>
<groupId>org.codemonkey.simplejavamail</groupId>
<artifactId>simple-java-mail</artifactId>
<version>2.1</version>
</dependency>

<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.10</version>
</dependency>
</dependencies>

错误:

java.lang.NoSuchMethodError: org.apache.http.impl.cookie.BrowserCompatSpecFactory.create(Lorg/apache/http/protocol/HttpContext;)Lorg/apache/http/cookie/CookieSpec;
at com.gargoylesoftware.htmlunit.CookieManager.<init>(CookieManager.java:54)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:136)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:199)

最佳答案

显然,将 HtmlUnit 依赖项移动到依赖项列表的底部解决了该问题。就像 peeskillet 提到的那样,这并不是一个完整的修复,因为我们仍然不知道是什么导致了这个问题,但它可以作为第一个解决方案。如果您找到罪魁祸首,请回答。

关于maven - 尝试在 Glassfish 上创建 WebClient 时出现 NoSuchMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28412299/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com