java 可能的原因可能是在应用程序未配置安全性时调用 https

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6476401/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 16:01:57  来源:igfitidea点击:

Possible causes can be invoking https when the application is not configured for security

javaweb-services

提问by Mediator

I create web service

我创建网络服务

@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;
        }
    }

}

I want to test but on the page http://localhost:8080/DynamipsService2/DynamipsService2?Testercrash bug

我想测试但是在页面 http://localhost:8080/DynamipsService2/DynamipsService2?Testercrash bug

Error generating artifacts for the following WSDL http://localhost:8080/DynamipsService2/DynamipsService2?WSDL

Possible causes can be invoking https when the application is not configured for security

为以下 WSDL http://localhost:8080/DynamipsService2/DynamipsService2?WSDL生成工件时出错

可能的原因可能是在应用程序未配置安全性时调用 https

I created other Web services in the same assembly and it works.

我在同一个程序集中创建了其他 Web 服务并且它工作正常。

采纳答案by Javier

I had the same problem and the reason apeared in the Server's log. I'm useing Glassfish 3.1 with netBeans 7. And the error I got in the Glassfish output was: INFO: [ERROR] com.sun.tools.javac.Main is not available in the classpath, requires Suns JDK version 5.0 or latter.

我遇到了同样的问题,原因出现在服务器的日志中。我正在使用带有 netBeans 7 的 Glassfish 3.1。我在 Glassfish 输出中得到的错误是:INFO: [ERROR] com.sun.tools.javac.Main 在类路径中不可用,需要 Suns JDK 5.0 或更高版本。

I googled a bit and it appeared to be because the glassfish server was working with the openjdk that came with ubuntu. If your problem is the same the solution I found was to remove the openjdk jre, like this:

我用谷歌搜索了一下,似乎是因为 glassfish 服务器正在使用 ubuntu 附带的 openjdk。如果您的问题是相同的,我发现的解决方案是删除 openjdk jre,如下所示:

sudo apt-get remove openjdk-6-jre sudo apt-get autoremove

sudo apt-get 删除 openjdk-6-jre sudo apt-get autoremove

Hope this is useful.

希望这是有用的。

PS: I assigned /usr/lib/jvm/java-6-sun/bin/java in the java tab at the servers configuration wizard in netBeans but don't know if that was part of the solution (I'm afraid to change it back :p)

PS:我在 netBeans 的服务器配置向导的 java 选项卡中分配了 /usr/lib/jvm/java-6-sun/bin/java 但不知道这是否是解决方案的一部分(我害怕改变它回来了:p)

回答by David Shaffer

I just experienced this problem as well. The solution for me was to use my hostname rather than localhost in the URL for the Tester.

我也刚遇到这个问题。我的解决方案是在测试者的 URL 中使用我的主机名而不是 localhost。

So in my case, the following, which is what NetBeans/Glassfish did by default when I clicked Test Web Service in the NetBeans UI, did notwork:

所以在我的情况,下面,这是什么的NetBeans / Glassfish的那样在默认情况下,当我在NetBeans UI点击测试Web服务,做工作:

http://localhost:8080/Calculator/Calculator?Tester

However, when I paste the following into a browser, it doeswork:

但是,当我将以下内容粘贴到浏览器中时,它确实有效:

http://david-pc:8080/Calculator/Calculator?Tester

I couldn't figure out how to change the hostname that NetBeans uses for the built-in Test dialog (nor could I cut+paste the URL from the error dialog). So I had to visually copy the URL from the error message into a browser, replacing the hostname along the way.

我不知道如何更改 NetBeans 用于内置测试对话框的主机名(我也无法从错误对话框中剪切+粘贴 URL)。因此,我必须直观地将错误消息中的 URL 复制到浏览器中,并在此过程中替换主机名。

回答by Pawe? Wo?niak

I had the same problem with Glassfish

我在 Glassfish 上遇到了同样的问题

but it was more compilcated because of the NAT

但由于 NAT,它变得更加复杂

I have GF in NAT - do MYDOMAIN and port is redirected to internal machine

我在 NAT 中有 GF - 做 MYDOMAIN 并且端口被重定向到内部机器

the problem in GF is that it tries to connect to itself by the domain name which again redirects to inside network (the ?wsdl works properly)

GF 中的问题是它试图通过再次重定向到内部网络的域名连接到自身(?wsdl 正常工作)

I have made temp solution adding to /etc/hosts (127.0.0.1 domainname)
be aware that it's only a temp solution

我已经将临时解决方案添加到 /etc/hosts (127.0.0.1 域名) 请
注意这只是一个临时解决方案

try to check if you have "localhost" in your hosts file (in windows c:/windows/system32/drivers/etc/hosts ) and ping localhost

尝试检查您的主机文件中是否有“localhost”(在 windows c:/windows/system32/drivers/etc/hosts 中)并 ping localhost

I will add GF log - maybe someone in future will search it by google :) :) moreover I looked GF logs there was something like ->

我将添加 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.

回答by 3alaa baiomy

Which web server do you use? If you use glassfish you can open server admin page and select Configurations===>server-config===>Security

你使用哪个网络服务器?如果您使用 glassfish,您可以打开服务器管理页面并选择Configurations===>server-config===>Security

and make Security Manager enabled

并启用安全管理器

回答by Sherif

Check your domains/{YOUR_DOMAIN}/config/domain.xml

检查您的域/{YOUR_DOMAIN}/config/domain.xml

If you setup Glassfish using Eclipse, all will be done for you automatically.

如果您使用 Eclipse 设置 Glassfish,一切都会自动为您完成。

Now I am surprised if I start the domain from the command line, it gave me that error, but starting Glassfish 4 from Eclipse, it is not showing any problem.

现在我很惊讶,如果我从命令行启动域,它给了我那个错误,但是从 Eclipse 启动 Glassfish 4,它没有显示任何问题。

回答by Luis Carlos

One cause could be that you don't have correctly configured the environment variable JAVA_HOME (with the correct path) and the JAVA_HOME/bin directory added to global PATH environment variable as well. For some processes the glassfish look for the classpath of the JDK installed. Hope this help.

一个原因可能是您没有正确配置环境变量 JAVA_HOME(使用正确的路径)并且 JAVA_HOME/bin 目录也添加到全局 PATH 环境变量中。对于某些进程, glassfish 会查找已安装 JDK 的类路径。希望这有帮助。

回答by Anonymous

I had the exact same problem and it is because you have a static method, I realised after debugging for some while. Just remove static from the method and it should work.

我遇到了完全相同的问题,这是因为您有一个静态方法,我在调试一段时间后意识到。只需从方法中删除静态,它应该可以工作。

@WebMethod(operationName = "StartSession")
public String StartSession(@WebParam(name = "key") String key) {
    try {

            return "100-Session started";

    } catch (Exception ex) {
        return null;
    }
}