问题描述
|
我创建网络服务
@WebService(serviceName = \"DynamipsService2\")
@Stateless()
public class DynamipsService2 {
@WebMethod(operationName = \"StartSession\")
public static String StartSession(@WebParam(name = \"key\") String key) {
try {
return \"100-Session started\";
} catch (Exception ex) {
return null;
}
}
}
我想测试,但是在页面上
http:// localhost:8080 / DynamipsService2 / DynamipsService2?Tester崩溃错误
为生成错误的工件
遵循WSDL
http:// localhost:8080 / DynamipsService2 / DynamipsService2?WSDL
可能的原因可能是调用https
未配置应用程序时
为了安全
我在同一程序集中创建了其他Web服务,并且可以正常工作。
解决方法
我在服务器的日志中也遇到了同样的问题和原因。我在netBeans 7中使用Glassfish 3.1。在Glassfish输出中遇到的错误是:
信息:[错误] com.sun.tools.javac.Main在类路径中不可用,需要Suns JDK 5.0或更高版本。
我用谷歌搜索了一下,这似乎是因为glassfish服务器正在使用ubuntu附带的openjdk。如果您的问题相同,我发现的解决方案是删除openjdk jre,如下所示:
sudo apt-get删除openjdk-6-jre
须藤apt-get autoremove
希望这是有用的。
PS:我在netBeans的服务器配置向导的java选项卡中为/ usr / lib / jvm / java-6-sun / bin / java分配了,但是不知道这是否是解决方案的一部分(恐怕是这样)改回来:p)
, 我也遇到了这个问题。对我来说,解决方案是在测试程序的URL中使用我的主机名而不是localhost。
因此,在我的情况下,以下是无效的,这是我在NetBeans UI中单击“测试Web服务”时NetBeans / Glassfish默认情况下执行的操作:
http://localhost:8080/Calculator/Calculator?Tester
但是,当我将以下内容粘贴到浏览器中时,它确实可以工作:
http://david-pc:8080/Calculator/Calculator?Tester
我无法弄清楚如何更改NetBeans用于内置“测试”对话框的主机名(也不能从错误对话框中剪切+粘贴URL)。因此,我必须将错误消息中的URL直观地复制到浏览器中,并一路替换主机名。
, 我对Glassfish也有同样的问题
但是由于NAT而被更编译
我在NAT中有GF-做MYDOMAIN并将端口重定向到内部计算机
GF中的问题是它尝试通过域名重新连接到自身,该域名再次重定向到内部网络
(?wsdl正常工作)
我已将临时解决方案添加到/etc/hosts(127.0.0.1域名)
请注意,这只是一个临时解决方案
尝试检查您的主机文件中是否有\“ localhost \”(在Windows c:/ windows / system32 / drivers / etc / hosts中)
和ping本地主机
我将添加GF日志-也许将来有人会通过Google搜索它:) :)
此外,我看着GF日志有类似->
Connection timed out
Failed to read the WSDL document: http://MYDOMAIN:8080/MYSERVICE?WSDL,because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not <wsdl:definitions>.
failed.noservice=Could not find wsdl:service in the provided WSDL(s):
At least one WSDL with at least one service definition needs to be provided.
Failed to parse the WSDL.
, 您使用哪个Web服务器?如果您使用glassfish,则可以打开服务器管理页面,然后选择Configurations===>server-config===>Security
并启用安全管理器
, 检查您的域/{YOUR_DOMAIN}/config/domain.xml
如果使用Eclipse设置Glassfish,将自动为您完成所有操作。
现在我很惊讶,如果我从命令行启动域,它给了我这个错误,但是从Eclipse启动Glassfish 4,它没有显示任何问题。
, 原因之一可能是您没有正确配置环境变量JAVA_HOME(具有正确的路径),并且还没有将JAVA_HOME / bin目录添加到全局PATH环境变量中。对于某些过程,glassfish会查找已安装的JDK的类路径。
希望对您有所帮助。
, 我遇到了完全相同的问题,这是因为您有一个静态方法,调试了一段时间后才意识到。只需从方法中删除静电,它就可以工作。
@WebMethod(operationName = \"StartSession\")
public String StartSession(@WebParam(name = \"key\") String key) {
try {
return \"100-Session started\";
} catch (Exception ex) {
return null;
}
}