You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Be...@Dev.Helaba.de on 2017/12/08 10:38:24 UTC

Manual Classloading on the job does not work

Hi
I have problems loading resources via the UserCodeClassloader as described in:
https://ci.apache.org/projects/flink/flink-docs-release-1.4/monitoring/debugging_classloading.html#manual-classloading-in-the-job

I have tried in several scenarios to load properties or wsdl files via a RichMapFunction. It never worked. Any ideas?

public class EmbargoClient extends RichMapFunction<MessageEnvelope, MessageEnvelope> {

    private static final String PAYMENT_CHECK_WSDL_LOCATION = "/wsdl/payment_check.wsdl";

...

    private URL readWsldFile() {
        ClassLoader userClassLoader = getRuntimeContext().getUserCodeClassLoader();
        URL url = userClassLoader.getResource(PAYMENT_CHECK_WSDL_LOCATION);
        if ( url == null )
            throw new RuntimeException("Could not load wsdl file from " + PAYMENT_CHECK_WSDL_LOCATION);
        return url;
    }
...
}

Regards,

Bernd



  ________________________________


Landesbank Hessen-Thueringen Girozentrale
Anstalt des oeffentlichen Rechts
Sitz: Frankfurt am Main / Erfurt
Amtsgericht Frankfurt am Main, HRA 29821 / Amtsgericht Jena, HRA 102181

Bitte nutzen Sie die E-Mail-Verbindung mit uns ausschliesslich zum Informationsaustausch. Wir koennen auf diesem Wege keine rechtsgeschaeftlichen Erklaerungen (Auftraege etc.) entgegennehmen.

Der Inhalt dieser Nachricht ist vertraulich und nur fuer den angegebenen Empfaenger bestimmt. Jede Form der Kenntnisnahme oder Weitergabe durch Dritte ist unzulaessig. Sollte diese Nachricht nicht fur Sie bestimmt sein, so bitten wir Sie, sich mit uns per E-Mail oder telefonisch in Verbindung zu setzen.

Please use your E-mail connection with us exclusively for the exchange of information. We do not accept legally binding declarations (orders, etc.) by this means of communication.

The contents of this message is confidential and intended only for the recipient indicated. Taking notice of this message or disclosure by third parties is not
permitted. In the event that this message is not intended for you, please contact us via E-mail or phone.

Re: Manual Classloading on the job does not work

Posted by Stefan Richter <s....@data-artisans.com>.
Hi,

I think the general approach looks good and should be fine. There is even a dedicated end-to-end test checking that this works („ClassLoaderTestProgram“). Have you double checked that all the paths are correct (i.e. the classloading code works in a standalone program with the paths and can find the file) and that the file is actually in the user jar, in the right place? Which Flink version are you using?

Best,
Stefan

> Am 08.12.2017 um 11:38 schrieb Bernd.Winterstein@Dev.Helaba.de:
> 
> Hi
> I have problems loading resources via the UserCodeClassloader as described in:
> https://ci.apache.org/projects/flink/flink-docs-release-1.4/monitoring/debugging_classloading.html#manual-classloading-in-the-job <https://ci.apache.org/projects/flink/flink-docs-release-1.4/monitoring/debugging_classloading.html#manual-classloading-in-the-job>
>  
> I have tried in several scenarios to load properties or wsdl files via a RichMapFunction. It never worked. Any ideas?
>  
> public class EmbargoClient extends RichMapFunction<MessageEnvelope, MessageEnvelope> {
>  
>     private static final String PAYMENT_CHECK_WSDL_LOCATION = "/wsdl/payment_check.wsdl";
>  
> …
>  
>     private URL readWsldFile() {
>         ClassLoader userClassLoader = getRuntimeContext().getUserCodeClassLoader();
>         URL url = userClassLoader.getResource(PAYMENT_CHECK_WSDL_LOCATION);
>         if ( url == null )
>             throw new RuntimeException("Could not load wsdl file from " + PAYMENT_CHECK_WSDL_LOCATION);
>         return url;
>     }
> …
> }
>  
> Regards,
>  
> Bernd
>  
> 
>   ________________________________  
> 
> 
> Landesbank Hessen-Thueringen Girozentrale
> Anstalt des oeffentlichen Rechts
> Sitz: Frankfurt am Main / Erfurt
> Amtsgericht Frankfurt am Main, HRA 29821 / Amtsgericht Jena, HRA 102181
> 
> Bitte nutzen Sie die E-Mail-Verbindung mit uns ausschliesslich zum Informationsaustausch. Wir koennen auf diesem Wege keine rechtsgeschaeftlichen Erklaerungen (Auftraege etc.) entgegennehmen.
> 
> Der Inhalt dieser Nachricht ist vertraulich und nur fuer den angegebenen Empfaenger bestimmt. Jede Form der Kenntnisnahme oder Weitergabe durch Dritte ist unzulaessig. Sollte diese Nachricht nicht fur Sie bestimmt sein, so bitten wir Sie, sich mit uns per E-Mail oder telefonisch in Verbindung zu setzen.
> 
> Please use your E-mail connection with us exclusively for the exchange of information. We do not accept legally binding declarations (orders, etc.) by this means of communication.
> 
> The contents of this message is confidential and intended only for the recipient indicated. Taking notice of this message or disclosure by third parties is not
> permitted. In the event that this message is not intended for you, please contact us via E-mail or phone.