Java笔记-解决java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast to
maven是这样的
<dependencies> ...............<!-- web service 相关 --><dependency><groupId>org.springframework.ws</groupId><artifactId>spring-ws-security</artifactId><version>3.0.8.RELEASE</version></dependency><dependency><groupId>javax.xml.bind</groupId><artifactId>jaxb-api</artifactId><version>2.3.0</version></dependency><dependency><groupId>org.glassfish.jaxb</groupId><artifactId>jaxb-runtime</artifactId><version>2.3.0</version></dependency><dependency><groupId>javax.activation</groupId><artifactId>activation</artifactId><version>1.1</version></dependency><dependency><groupId>org.springframework.ws</groupId><artifactId>spring-ws-core</artifactId><version>3.0.8.RELEASE</version></dependency><dependency><groupId>wsdl4j</groupId><artifactId>wsdl4j</artifactId><version>1.6.1</version></dependency><dependency><groupId>org.springframework.ws</groupId><artifactId>spring-ws-support</artifactId><version>3.0.8.RELEASE</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.1.10.RELEASE</version><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin><plugin><groupId>org.jvnet.jaxb2.maven2</groupId><artifactId>maven-jaxb2-plugin</artifactId><version>0.14.0</version><executions><execution><goals><goal>generate</goal></goals></execution></executions><configuration><schemaLanguage>WSDL</schemaLanguage><generatePackage>xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx</generatePackage><schemas><schema><url>file:///D:/xxxx/xxxx/xxxx/xxxx/xxxx/xxxx/xxxx.wsdl</url></schema></schemas></configuration></plugin></plugins></build>
相关调用代码是这样的:
public class CountryClient extends WebServiceGatewaySupport {private static final Logger log = LoggerFactory.getLogger(CountryClient.class);public GetCountryResponse getCountry(String country) {GetCountryRequest request = new GetCountryRequest();request.setName(country);log.info("Requesting location for " + country);GetCountryResponse response = (GetCountryResponse) getWebServiceTemplate().marshalSendAndReceive("http://localhost:8080/ws/countries", request,new SoapActionCallback("http://spring.io/guides/gs-producing-web-service/GetCountryRequest"));return response;}}
改成这样即可:
public class CountryClient extends WebServiceGatewaySupport {private static final Logger log = LoggerFactory.getLogger(CountryClient.class);public GetCountryResponse getCountry(String country) {GetCountryRequest request = new GetCountryRequest();request.setName(country);log.info("Requesting location for " + country);JAXBElement<GetFileRequestResponse> response = (JAXBElement<GetFileRequestResponse>) getWebServiceTemplate().marshalSendAndReceive("http://localhost:8080/ws/countries", request,new SoapActionCallback("http://spring.io/guides/gs-producing-web-service/GetCountryRequest"));return response.getValue();}}
Java笔记-解决java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast to相关推荐
- 控制台报错:java.lang.ClassNotFoundException: javax.xml.bind.JAXBException之解决方法
控制台报错:java.lang.ClassNotFoundException: javax.xml.bind.JAXBException之解决方法 参考文章: (1)控制台报错:java.lang.C ...
- java.lang.ClassNotFoundException:javax.xml.bind.DatatypeConverter【解决办法】
遇到的问题 java.lang.ClassNotFoundException:javax.xml.bind.DatatypeConverter 原因:这有可能是因为SpringBoot项目结合jwt进 ...
- java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter 报错的解决办法
如果你在使用 JWT 处理登录时,出现 java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter 这样的报错信息. 其主要原 ...
- 喵喵遇到java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter怎么办
B站链接 https://www.bilibili.com/read/cv5661355 java.lang.NoClassDefFoundError: javax/xml/bind/Datatype ...
- java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
今天执行 flutter doctor -v 的时候发现一个问题,提示信息是 [!] Android toolchain - develop for Android devices (Android ...
- `Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
在执行java包时,遇到了Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter 错误. 原因是因为 ...
- Caused by java.lang.ClassNotFoundException javax.xml.bind.ValidationException异常
一.问题描述 Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException at java.base/ja ...
- nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
相信这个问题很多小伙伴已经遇到了,这是在你的jdk版本由8.0升级到9.0之后发生的事情,实际上jdk的版本并不是类似于9.0就会完全兼容8.0的, 但是比如说8.1是完全兼容8.0的8.2是完全兼容 ...
- 报错Exception in thread “main“ java.lang.NoClassDefFoundError: javax/xml/bind/...
项目一开始用的是jdk8,后来重新导入项目没有设置jdk的版本,idea自动设置jdk11 , jdk11没有javax.xml.bind 这个包,需要手动导包: <!-- https://mv ...
最新文章
- Request header field token is not allowed by Access-Control-Allow-Headers in
- c++ fstream用法
- 俄罗斯方块剖析之一总体计划
- 这个拖后腿的“in”
- js文件处理File
- joblib多线程、多进程学习案例(一)——一步步写多进程任务
- webpack2.7.0配置不同的打包环境
- atitit 数字音频技术概论 艾提拉著 目录 1. 声学基础	2 1.1. 1.2人耳的听觉效应9	2 2. 第1章数字音频基础	2 2.1. 1.1音频的发展历史	2 2.2. 1.2音频的发展
- 网站克隆工具_科研|值得收藏的分子生物学必用工具(第二弹~)
- 51/STC12单片机SCON,PCON,TMOD寄存器定义及功能
- linux之hugepage
- 《余世维 - 有效沟通》讲义zz
- 英文文本关键词抽取——使用NLTK进行关键词抽取
- idea注释不顶格(不在行首)
- 1225:金银岛 题解
- python中tk窗口刷新_用按钮刷新tk窗口
- LOCKTIME寄存器
- (手写识别) Zinnia库及其实现方法研究
- 【经典】Mybatis百万级高效批量插入
- 视频综合平台架构分析
热门文章
- JavaScript中的Array对象
- 虚拟座谈会:有关分布式存储的三个基本问题
- 千万别强制停机!我嘴都气歪了!
- 3种思路,快速打破制造业质量追溯困境,成为行业领先企业
- 大数据之路:阿里巴巴大数据实践,附339页PPT下载
- 码农心目中的高富帅甲骨文公司在走下坡路
- 获取IE (控件)的所有链接(包括Frameset, iframe)zz
- 细谈Web框架设计与实现
- 我想重构网站的前端!不,你不想....
- oracle 去除英文字母,请教:如何去掉字段中的所有标点符号(包括全角的和半角的)...