[英]How to solve this connectivity configuration cast exception?
I am trying to run some tests on an endpoint of my application but I got a class cast exception.我正在尝试在我的应用程序的端点上运行一些测试,但我得到了 class 强制转换异常。
I get the error when I try to reach the endpoint (localhost) from the same machine I am running my code.当我尝试从正在运行我的代码的同一台机器上到达端点(localhost)时,我得到了错误。 I don't have the same problem when I make the request to a different machine (although the code on the server may vary from my local source, I am pretty sure this section does not)
当我向另一台机器发出请求时,我没有遇到同样的问题(尽管服务器上的代码可能与我的本地源不同,但我很确定本节不会)
I am using this link as reference ConnectivityConfiguration API我使用这个链接作为参考ConnectivityConfiguration API
And this is my code:这是我的代码:
private synchronized ConnectivityConfiguration lookupConnectivityConfiguration() throws IOException {
try {
if (this.localConnectivityConfiguration == null) {
Context ctx = new InitialContext();
this.localConnectivityConfiguration = (ConnectivityConfiguration) ctx.lookup("java:comp/env/connectivityConfiguration");
}
return this.localConnectivityConfiguration;
} catch (NamingException e) {
e.printStackTrace();
throw new IOException(e.getMessage(), e);
}
}
I am expecting to get a com.sap.core.connectivity.api.configurationConnectivityConfiguration
object when the method is called but instead I get the below error:我期望在调用该方法时得到
com.sap.core.connectivity.api.configurationConnectivityConfiguration
object 但我得到以下错误:
java.lang.ClassCastException: com.sap.core.connectivity.apiext.local.LocalConnectivityConfiguration cannot be cast to com.sap.core.connectivity.api.configuration.ConnectivityConfiguration
java.lang.ClassCastException: com.sap.core.connectivity.apiext.local.LocalConnectivityConfiguration cannot be cast to com.sap.core.connectivity.api.configuration.ConnectivityConfiguration
and I am not sure where this class comes or should be imported from:而且我不确定这个 class 来自或应该从哪里进口:
com.sap.core.connectivity.apiext.local.LocalConnectivityConfiguration
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.