Glassfish基本身份验证错误

时间:2013-11-18 08:50:15

标签: java xml web-services soap glassfish

我有下一个方法:

@RolesAllowed("basicUser")
    @Override
    public boolean LogOn(String UserName, String Password) {
...
}

这是我的web.xml:

http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">   HelloService的

<session-config>
    <session-timeout>30</session-timeout>
</session-config>
<security-constraint>
    <display-name>SecurityConstraint</display-name>
    <!-- web resources that are protected -->
    <web-resource-collection>
        <web-resource-name>Secure Pages</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <!-- role-name indicates roles that are allowed to access the web resource specified above -->
        <role-name>basicUser</role-name>
    </auth-constraint>
     <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>
<login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>file</realm-name>
</login-config>
<security-role>
    <role-name>basicUser</role-name>
</security-role>

sun-web:

<security-role-mapping>
    <role-name>basicUser</role-name>
    <group-name>client</group-name>
</security-role-mapping>

在Glassfish服务器中,在Server-config中 - &gt;安全性 - &gt;领域 - &gt;文件,分配组: cleint ,以及组客户端的用户。部署运行成功。当我测试网络服务时,我得到下一个错误:

INFO:   parsing WSDL...
INFO:   [ERROR] Server returned HTTP response code: 401 for URL:
http://localhost:8080/CalculatorWSApplication/WebServiceImplService?WSDL,
"http://localhost:8080/CalculatorWSApplication/WebServiceImplService?WSDL" needs 
authorization, please provide authorization file with read access at
C:\Users\user.t\.metro\auth or use -Xauthfile to give the authorization
file and on each line provide authorization information using this format :
http[s]://user:password@host:port//<url-path>

P.S。没有基本身份验证,Web服务部署和测试成功。

UPD

例外详情:null

    com.sun.tools.ws.wscompile.AbortException at 
com.sun.tools.ws.wsdl.parser.MetadataFinder$WSEntityResolver.resolveEntity(MetadataFinder.java:202) at 
com.sun.tools.ws.wsdl.parser.DOMForest.parse(DOMForest.java:212) at
com.sun.tools.ws.wsdl.parser.DOMForest.parse(DOMForest.java:148) at
com.sun.tools.ws.wsdl.parser.MetadataFinder.parseWSDL(MetadataFinder.java:111) at
com.sun.tools.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:439) at
com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:205) at
com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:183) at
com.sun.tools.ws.util.WSToolsObjectFactoryImpl.wsimport(WSToolsObjectFactoryImpl.java:60)at 
com.sun.tools.ws.spi.WSToolsObjectFactory.wsimport(WSToolsObjectFactory.java:88) at
org.glassfish.webservices.monitoring.WebServiceTesterServlet.wsImport(WebServiceTesterServlet.java:642) at
org.glassfish.webservices.monitoring.WebServiceTesterServlet.initializePort(WebServiceTesterServlet.java:528) at 
org.glassfish.webservices.monitoring.WebServiceTesterServlet.doGet(WebServiceTesterServlet.java:169) at 
org.glassfish.webservices.monitoring.WebServiceTesterServlet.invoke(WebServiceTesterServlet.java:104) at 
org.glassfish.webservices.JAXWSServlet.doGet(JAXWSServlet.java:210) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:687) at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at
com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at 
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357) at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260) at 
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188) at
org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) at
org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) at
org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) at
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) at
org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)at 
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)at 
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at
org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)at 
org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) at
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) at 
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) at
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564) at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)at java.lang.Thread.run(Thread.java:744)

2 个答案:

答案 0 :(得分:1)

您似乎需要首先创建一个由wsdl URI加上我的用户名和密码组成的authfile。您可以看到详细信息here

答案 1 :(得分:1)

如果您使用JAX-WS,请尝试使用下一个内容添加sun-jaxws.xml文件:

<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>
    <endpoint
        name='YOUR_NAME'
        implementation='yourpacket.Web_Service_Implementation'
        url-pattern='/*'/>
</endpoints>