我有一个 Spring MVC4 网络应用程序:
它有一个控制器类,如下所示 -
@Controller
public class SeleniumController
{
@Autowired
SeleniumService seleniumService;
@RequestMapping(value={"/service/echo"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
@ResponseBody
public String echo() {
System.out.println("Inside Echo .. ");
return "echo";
}
@RequestMapping(value={"/service/changeAddress"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
@ResponseBody
public AddressChangeRequest changeAddress(@RequestBody AddressChangeRequest req) {
System.out.println("Inside AddressChange .. ");
try
{
this.seleniumService.openOipaAddressScreenRemote(req.getPolicyNumber(), req.getCaseId(), req.getTaskId(), req.getAssignedTo());
}
catch (MalformedURLException e) {
e.printStackTrace();
return req;
}
return req;
}
}
服务类 -
@Service("oipaService")
public class SeleniumService {
private static final String HUB_URL = "http://10.227.181.36:4444/wd/hub";
public void openOipaAddressScreenRemote(String policyNumber, String caseID, String taskID, String assignedTo) throws MalformedURLException {
System.out.println("Policy number input : " + policyNumber);
String oipaURL = "https://myDom.com/PASJava_Term";
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new RemoteWebDriver(new URL(HUB_URL), caps);
WebDriverWait wait = new WebDriverWait(driver, 60);
Actions oAction = new Actions(driver);
driver.get(oipaURL);
}
}
我在10.227.181.36:4444
和客户端系统中的节点。用于建立selenium hub和节点的罐子是
selenium-server-standalone-2.53.1.jar
我的目标是将json数据从客户端发布到REST控制器,并在客户端浏览器中启动selenium测试。
当spring应用程序托管在apache-tomcat-7(windows)中并且hub在windows机器(jdk1.7.0_55)和windows机器中的节点(jdk1.7.0_55或更高版本)中设置时,它可以正常工作。
但是当我在weblogic 12C(unix)中托管应用程序并在unix系统(jdk1.7.0_55)和windows中的节点(jdk1.7.0_55或更高版本)中设置集线器时,发布json后出现以下错误到我的休息服务 -
java.lang.NoSuchMethodError: com.google.common.collect.Multimaps.transformValues(Lcom/google/common/collect/ListMultimap;Lcom/google/common/base/Function;)Lcom/google/common/collect/ListMultimap;
at com.google.common.net.MediaType.toString(MediaType.java:708)
at org.openqa.selenium.remote.http.JsonHttpCommandCodec.encode(JsonHttpCommandCodec.java:197)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:130)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:572)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at com.cts.bpaas.service.SeleniumService.openOipaAddressScreenRemote(SeleniumService.java:229)
at com.cts.bpaas.soe.controller.SeleniumController.changeAddress(SeleniumController.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:751)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at com.cts.bpaas.soe.filter.SoECORSFilter.doFilter(SoECORSFilter.java:32)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)</font>
/service/echo
上的GET方法适用于两种设置,但/service/changeAddress
上的POST方法不适用于unix设置。
我错过了什么?
答案 0 :(得分:0)
认为它不是硒的问题。问题是在weblogic 12c中部署应用程序。 guava.jar出现在我的应用程序和weblogic中,我只需要在weblogic.xml中做一点改动,告诉weblogic拿我的jar,而不是weblogic&#39。
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:context-root>/csoe_rest</wls:context-root>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>com.google.common.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>
它像魅力一样