Java Apache 轴配置异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/65310/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache Axis ConfigurationException
提问by Craig H
I am using Apache Axis to connect my Java app to a web server. I used wsdl2java to create the stubs for me, but when I try to use the stubs, I get the following exception:
我正在使用 Apache Axis 将我的 Java 应用程序连接到 Web 服务器。我使用 wsdl2java 为我创建存根,但是当我尝试使用存根时,出现以下异常:
org.apache.axis.ConfigurationException: No service named
<web service name>
is available
org.apache.axis.ConfigurationException: 没有
<web service name>
可用的服务命名
any idea?
任何的想法?
采纳答案by KC Baltz
Just a guess, but it looks like that error message is reporting that you've left the service name blank. I imagine the code that generates that error message looks like this:
只是猜测,但该错误消息似乎报告您已将服务名称留空。我想象生成该错误消息的代码如下所示:
throw new ConfigurationException("No service named" + serviceName + " is available");
回答by ScArcher2
This is what my code looks like. It seems to work fine. Are you using a service locator or just creating your service?
这就是我的代码的样子。它似乎工作正常。您是在使用服务定位器还是只是在创建您的服务?
SomeServiceLocator locator = new SomeServiceLocator();
SomeService service = null;
try
{
service = locator.getSomeServiceImplPort();
}
catch (ServiceException e)
{
e.printStackTrace();
}
回答by Vinze
I don't know what version of Axis you're using but I'm using Axis2 for both server and client and the Java2WSDL create a default endpoint for the service on localhost. If you create the client stub with WSDL2Java, the default constructor of the stub will then point to localhost. If the service is on other endpoint you must use the constructor with the endpoint as parameter... Maybe the problem is not that at all but as said on other answers, without the WSDL you're using as WSDL2Java input it's hard to say.
我不知道您使用的是哪个版本的 Axis,但我将 Axis2 用于服务器和客户端,并且 Java2WSDL 为本地主机上的服务创建了一个默认端点。如果您使用 WSDL2Java 创建客户端存根,那么存根的默认构造函数将指向 localhost。如果服务在其他端点上,您必须使用带有端点作为参数的构造函数......也许问题根本不是那样,而是正如其他答案所说,如果没有您用作 WSDL2Java 输入的 WSDL,则很难说。
回答by arnonym
It is an exception used by Axis' control flow.
它是 Axis 控制流使用的一个例外。
http://wiki.apache.org/ws/FrontPage/Axis/DealingWithCommonExceptions--> org.apache.axis.ConfigurationException: No service named XXX is available
http://wiki.apache.org/ws/FrontPage/Axis/DealingWithCommonExceptions--> org.apache.axis.ConfigurationException:没有名为 XXX 的服务可用
回答by kldavis4
According to the documentationlinked to by @arnonym, this exception is somewhat misleading. In the first attempt to find the service a ConfigurationException is thrown and caught. It is logged at DEBUG level by the ConfigurationException class. Then another attempt is made using a different method to find the service that may then succeed. The workaround for this is to just change the log level on the ConfigurationException class to INFO in your log4j.properties:
根据@arnonym 链接的文档,这个例外有点误导。在第一次尝试查找服务时,会抛出并捕获 ConfigurationException。它由 ConfigurationException 类在调试级别记录。然后使用不同的方法进行另一次尝试以找到可能成功的服务。解决方法是在 log4j.properties 中将 ConfigurationException 类的日志级别更改为 INFO:
log4j.logger.org.apache.axis.ConfigurationException = INFO