异常原因
根据官方文档,当方法接收到了一个不合法或不正确的参数时会抛出此类异常。
解决方案
因为参数不合法导致抛出IllegalArgumentException,请根据堆栈信息描述的出错的函数参数,按照要求传入正确的参数。
举例
错误堆栈信息
java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.sslContext
at org.apache.commons.lang3.Validate.isTrue(Validate.java:155)
at org.apache.commons.lang3.reflect.FieldUtils.readDeclaredField(FieldUtils.java:512)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getField(HttpWebConnection.java:1095)
at com.gargoylesoftware.htmlunit.HttpWebConnection.createConnectionManager(HttpWebConnection.java:1017)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:174)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1397)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1315)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:394)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:315)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:463)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:448)
at com.epoint.dzdamanager.login.DnetDefaultLoginForUrlImpl.doLogin(DnetDefaultLoginForUrlImpl.java:87)
at com.epoint.ztb.htmlutil.HtmlToPdf.getHtmlPageFromUrlF9(vb:80)
at com.epoint.dzdamanager.domain.DownZtbData.pageToPdf(DownZtbData.java:446)
at com.epoint.dzdamanager.domain.DownZtbData.genFileList(DownZtbData.java:319)
at com.epoint.dzdamanager.domain.DownZtbData.workForBarStep(DownZtbData.java:152)
at com.epoint.dzdamanager.pack.job.DoPackServiceImp.doPack(DoPackServiceImp.java:87)
at com.epoint.dzdamanager.pack.job.DoPackJob.execute(DoPackJob.java:35)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
分析
重点提示“Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.sslContext”
经排查,htmlunit.jar包在4.4.1版本中HttpClientBuilder该类无sslContext属性,属性名称为sslcontext,从而引发参数报错。
网友评论