Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException while initializing SOAP client #5059

Closed
peterpz1 opened this issue Dec 15, 2020 · 9 comments
Closed

NullPointerException while initializing SOAP client #5059

peterpz1 opened this issue Dec 15, 2020 · 9 comments
Assignees
Labels
Status: Abandoned User has not supplied reproducers for bug report, soon to be closed if user doesn’t come back Type: Bug Label issue as a bug defect

Comments

@peterpz1
Copy link

peterpz1 commented Dec 15, 2020

Description


We have auto generated JAX-WS client code (Apache CXF) like that:

@WebServiceClient(name = "CPEManagementService",
                  wsdlLocation = "classpath:/resources/wsdl/PapyrusGetCPEInfos/GetCPEInfos-v1.wsdl",
                  targetNamespace = "http://WSA.francetelecom.com/wsdl/getCPEInfos/v1")
public class CPEManagementService extends Service {

    public final static URL WSDL_LOCATION;

    public final static QName SERVICE = new QName("http://WSA.francetelecom.com/wsdl/getCPEInfos/v1", "CPEManagementService");
    public final static QName GetCPEInfos = new QName("http://WSA.francetelecom.com/wsdl/getCPEInfos/v1", "GetCPEInfos");
    static {
        URL url = CPEManagementService.class.getClassLoader().getResource("/resources/wsdl/PapyrusGetCPEInfos/GetCPEInfos-v1.wsdl");
        if (url == null) {
            url = CPEManagementService.class.getClassLoader().getResource("resources/wsdl/PapyrusGetCPEInfos/GetCPEInfos-v1.wsdl");
        }
        if (url == null) {
            java.util.logging.Logger.getLogger(CPEManagementService.class.getName())
                .log(java.util.logging.Level.INFO,
                     "Can not initialize the default wsdl from {0}", "classpath:/resources/wsdl/PapyrusGetCPEInfos/GetCPEInfos-v1.wsdl");
        }
        WSDL_LOCATION = url;
    }

    public CPEManagementService(URL wsdlLocation) {
        super(wsdlLocation, SERVICE);
    }

    public CPEManagementService(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public CPEManagementService() {
        super(WSDL_LOCATION, SERVICE);
    }

And after 2 or 3 application redeployments there is nullpointer exception in the generic JAX-WS code:
java.lang.NullPointerException: null at org.apache.catalina.core.StandardContext.getResource(StandardContext.java:7354) at org.glassfish.webservices.metroglue.WebInfResourceLoader.getResource(WebInfResourceLoader.java:77) at com.sun.xml.ws.util.xml.XmlCatalogUtil.parseResourcesToCatalog(XmlCatalogUtil.java:104) at com.sun.xml.ws.util.xml.XmlCatalogUtil.createDefaultCatalogResolver(XmlCatalogUtil.java:78) at com.sun.xml.ws.util.xml.XmlUtil.createDefaultCatalogResolver(XmlUtil.java:296) at com.sun.xml.ws.client.WSServiceDelegate.createCatalogResolver(WSServiceDelegate.java:348) at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:334) at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:292) at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:201) at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:182) at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:178) at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:89) at javax.xml.ws.Service.<init>(Service.java:82) at com.francetelecom.papyrus.getcpeinfos.v1.CPEManagementService.<init>(CPEManagementService.java:47)

The only way to resolve this issue is the server restart. After it everything starts to work properly until... a couple of application redeployments... Whas is causing this issue?

  • Payara Version: Payara Server 5.201 #badassfish (build 512)
  • Edition: Full (running in cluster mode - instances + deployment group)
  • JDK Version: zulu11.37.17-ca-jdk11.0.6-linux_x64
  • Operating System: Linux
  • Database: na
@AlanRoth AlanRoth added Status: Open Issue has been triaged by the front-line engineers and is being worked on verification Type: Bug Label issue as a bug defect labels Dec 16, 2020
@AlanRoth
Copy link

Hi @peterpz1,

Would you be able to reproduce your issue on the latest release 5.2020.7? Could you also provide a sample application to make reproducing for us easier?

Thank you,
Alan

@MeroRai MeroRai added Status: Pending Waiting on the issue requester to give more details or share a reproducer and removed Status: Open Issue has been triaged by the front-line engineers and is being worked on verification labels Dec 16, 2020
@AlanRoth AlanRoth assigned MeroRai and unassigned AlanRoth Dec 16, 2020
@peterpz1
Copy link
Author

We are now preparing installation pack for 5.2020.7 to check if this issue exsists. I don't know if I would be able to prepare app for testing because:

  1. Current app is quite hughe - I cannot give you it, and there is possibility that some relation to the other packs / code that we are using.
  2. I can prepare simple app with this code, but I would not be even sure if this issue will exist on the small app, because I would have to test it on production, but I cannot use it on prod...

PS: Why you are removing production domain from Community version? Are you trying to force us to migrate to EE version?

@MeroRai
Copy link
Member

MeroRai commented Dec 16, 2020

Hi @peterpz1,

First, I would like to thank you for raising this issue. To help us find the cause and fix the issue, we need, as you have mentioned, a simple application that reproduces this issue on the latest release of Payara Community Edition. A reproducer should ideally follow the SSCCE rules: http://www.sscce.org/. Without any reproducer, I am afraid we won't be able to investigate this issue further.

You can read about the rationale behind removing the Production domain from the Payara Community Edition by Steve Millidge, the founder and Director of Payara on https://groups.google.com/g/payara-forum/c/Uw5eiEFfF0Y/m/ccrqHZVoAgAJ.

Many thanks for your understanding.

Mero Rai

@peterpz1
Copy link
Author

peterpz1 commented Dec 22, 2020

@MeroRai
I'm trying to reproduce this issue on simple app but it is really hard to do it. On the test app everything is working properly. So I don't know if I will be able to provide you with a simple reproducer. Something is happening on our setup, which is hard to reproduce. But what I observe is that the issue is per thread basics. For example currently only single thread "http-thread-pool::http-ssl-mutual-auth-listener(50)" has this issue:

2020-12-22 08:42:13.693 [http-thread-pool::http-ssl-mutual-auth-listener(50)] ERROR pl.orangelabs.commons.downloader.AbstractDataDownloader - Exception while downloading connector data for serviceIdentifier=ServiceIdInputIdentifier(super=DownloaderIdentifier(dbId=7211933753, userLogin=OlszoKrz, serviceDbIndex=1688231), serviceId=7211933753)
java.lang.NullPointerException: null
        at org.apache.catalina.core.StandardContext.getResource(StandardContext.java:7409)
        at org.glassfish.webservices.metroglue.WebInfResourceLoader.getResource(WebInfResourceLoader.java:77)
--
2020-12-22 08:42:17.042 [http-thread-pool::http-ssl-mutual-auth-listener(50)] ERROR pl.orangelabs.commons.downloader.AbstractDataDownloader - Exception while downloading connector data for serviceIdentifier=MacInputIdentifier(super=DownloaderIdentifier(dbId=B0:98:2B:7E:A9:44, userLogin=OlszoKrz, serviceDbIndex=1688231), mac=B0:98:2B:7E:A9:44)
java.lang.NullPointerException: null
        at org.apache.catalina.core.StandardContext.getResource(StandardContext.java:7409)
        at org.glassfish.webservices.metroglue.WebInfResourceLoader.getResource(WebInfResourceLoader.java:77)
--
2020-12-22 08:46:46.100 [http-thread-pool::http-ssl-mutual-auth-listener(50)] ERROR pl.orangelabs.commons.downloader.AbstractDataDownloader - Exception while downloading connector data for serviceIdentifier=ServiceIdInputIdentifier(super=DownloaderIdentifier(dbId=9991142282, userLogin=zakrzka6, serviceDbIndex=1688260), serviceId=9991142282)
java.lang.NullPointerException: null
        at org.apache.catalina.core.StandardContext.getResource(StandardContext.java:7409)
        at org.glassfish.webservices.metroglue.WebInfResourceLoader.getResource(WebInfResourceLoader.java:77)

Other threads are OK. I'm looking at StandardContext.getResource(StandardContext.java:7409) and since it looks like that:
obraz
I suppose that for this case context is null. It looks like it is set to null it will be null forever... Also we can see that this part of the StandardContext was modified in the past:
obraz

@peterpz1
Copy link
Author

@MeroRai what I did was to catch this NPE and after that try to force the context to be build. I just copied the code from metroglue and executed it mysfelf:
obraz
The most important line is the webModule1.getServletContext();, which causes context to be assigned with value:
obraz

After that I'm trying to build the WebService client again - and what is the suprise? There is no NPE...

@sgflt
Copy link
Contributor

sgflt commented Dec 22, 2020

Also note that other resource* methods use different approach to get resource:

 if (alternateDocBases == null
                || alternateDocBases.isEmpty()) {
            resources = getResources();
        }

@peterpz1
Copy link
Author

Currently I deployed a workaround for all SOAP clients. Each client is created like that:

    public static <T extends Service> T buildMetroSoapClient(Class<T> clazz) {
        ensureServletContextIsBuild();
        try {
            return clazz.getDeclaredConstructor().newInstance();
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
    }

    public static void ensureServletContextIsBuild() {
        InvocationManager invocationManager = Globals.get(InvocationManager.class);
        if (invocationManager != null) {
            Optional<WebModule> optionalWebModule =
                    invocationManager.getAllInvocations()
                            .stream()
                            .filter(e -> e instanceof WebComponentInvocation)
                            .map(WebComponentInvocation.class::cast)
                            .map(e -> (WebModule) e.getContainer())
                            .findFirst();

            final boolean present = optionalWebModule.isPresent();
            if (present) {
                final WebModule webModule = optionalWebModule.get();
                webModule.getServletContext();
            }
        }
    }

@MeroRai
Copy link
Member

MeroRai commented Dec 23, 2020

Hi @peterpz1,

You seem to be very familiar with our codebase, is this something you will be interested in creating a PR with a fix? You can read more on contributing to Payara here: https://github.com/payara/Payara/blob/master/.github/CONTRIBUTING.md

@AlanRoth AlanRoth added Status: Abandoned User has not supplied reproducers for bug report, soon to be closed if user doesn’t come back and removed Status: Pending Waiting on the issue requester to give more details or share a reproducer labels Feb 23, 2021
@MeroRai
Copy link
Member

MeroRai commented Mar 4, 2021

Hi, since we haven’t received a reproducer, we’ll proceed to close this issue. Feel free to re-open it in the future if you are able to provide us with a simple reproducer using the current release of Payara Community Edition at that point in time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Abandoned User has not supplied reproducers for bug report, soon to be closed if user doesn’t come back Type: Bug Label issue as a bug defect
Projects
None yet
Development

No branches or pull requests

4 participants