Search code examples
web-servicesjakarta-eehttpswsdlglassfish

Stateless web services do not work in HTTPS for Glassfish 3.1


I still consider myself new to Java webservices, and I have hit a real roadblock that I cannot overcome.

I am trying to deploy a @Stateless Web Service and access it's WSDL over https. Whenever I attempt to access it I get the following error in the browser:

Error generating artifacts for the following WSDL https://localhost:8181/TestService/Test?WSDL

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

The console is showing the following errors:

INFO: parsing WSDL...

WARNING: Invalid request scheme for Endpoint Test. Expected http . Received https
INFO: [ERROR] Premature end of file.
INFO:   line 1 of https://localhost:8181/TestService/Test?WSDL
WARNING: Invalid request scheme for Endpoint Test. Expected http . Received https
WARNING: MEX0008:Failed to parse metadata returned from server at https://localhost:8181/TestService/Test?WSDL using protocol SOAP_1_2. Continuing attempts.
WARNING: Invalid request scheme for Endpoint Test. Expected http . Received https
WARNING: MEX0008:Failed to parse metadata returned from server at https://localhost:8181/TestService/Test?WSDL using protocol SOAP_1_1. Continuing attempts.
WARNING: Invalid request scheme for Endpoint Test. Expected http . Received https
WARNING: MEX0008:Failed to parse metadata returned from server at https://localhost:8181/TestService/Test?WSDL/mex using protocol SOAP_1_2. Continuing attempts.
WARNING: Invalid request scheme for Endpoint Test. Expected http . Received https
WARNING: MEX0008:Failed to parse metadata returned from server at https://localhost:8181/TestService/Test?WSDL/mex using protocol SOAP_1_1. Continuing attempts.
INFO: [ERROR] Premature end of file.
Failed to read the WSDL document: https://localhost:8181/TestService/Test?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>.
INFO: [ERROR] 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.
INFO:   Failed to parse the WSDL.
INFO: Invoking wsimport with https://localhost:8181/TestService/Test?WSDL
SEVERE: wsimport failed

Again, this is ONLY happening when accessing it over HTTPS. Regular HTTP is fine. However, if I were to remove the @Stateless annotation, it works just fine over https. It fails when I add the @Stateless annotation.

I need the @Stateless annotation since I will be working with JMS Queues, and you need it when doing that.

Below is the code for my class:

package service.test;

import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebService;

@Stateless
@WebService
public class Test
{
    public String hello()
    {
        return "Hello!";
    }

    @WebMethod
    public int addNumbers(int number1, int number2)
    {
        return number1 + number2;
    }
}

So far at this point, I have never needed to utilize any web descriptors. Everything I have done is by default handled in Eclipse automatically. Do I have to do anything special with the descriptor files? If so, which ones?

Thank You


Solution

  • This was an odd issue that I never really figured out the cause of. Oddly enough, this issue worked itself out in the end by not needing @Stateless.