IBM Support

A client application throws InvocationTargetException during the lookup of CEI artifacts for WebSphere Process Server (WPS)

Troubleshooting


Problem

A client application outside of the WebSphere Process Server run time environment can throw the InvocationTargetException exception when trying to use Common Event Infrastructure (CEI) services to perform a lookup.

Symptom

In the following scenario, a lookup of CEI artifacts (for example, a CEI emitter factory) fails when it is performed by a client application.

Subsequent tries to emit a Common Base Event (CBE) also fail due to InvocationTargetException being thrown in the client application:

  1. You implement a Java™ client application that is invoked outside the WebSphere Process Server run time using the launchClient command-line tool.
  2. The Java application does a Java Naming and Directory Interface (JNDI) lookup on CEI-related artifacts, as shown in the following example code snippet:

    InitialContext ic = new InitialContext();
    // lookup CEI related artifacts
    EmitterFactory emitterFactory = (EmitterFactory)
    ic.lookup("cell/nodes/wpsnode/servers/server1/com/ibm/
     events/configuration/emitter/Default");
    EventFactory eventFactory = (EventFactory) ic.lookup("cell/nodes/wpsnode/servers/server1/com/ibm/
     events/EventFactory");
    // create a Common Base Event
    CommonBaseEvent event = eventFactory.createCommonBaseEvent();
    //  more code on configuring the event
    Emitter emitter = emitterFactory.getEmitter();
    // following invocation results in a runtime exception
    emitter.sendEvent(event);


  3. Attempts to emit the common base event fail with the InvocationTargetException failure, as shown in the following text:

    [01.01.10 10:00:00:000 CET] 00000001 3 UOW=9-6c006c0-16803004:localhost
    source=com.ibm.websphere.naming.genericURLInitialContextFactory
    org=IBM prod=WebSphere component=Application Server
    thread=[P=642222:O=0:CT]
    Could not invoke method getObjectInstance on object of type com.ibm.ws.naming.urlns.genericURLContextFactory.
    parm0=java.lang.reflect.
    InvocationTargetException at
    sun.reflect.NativeMethodAccessorImpl.invoke0(
     Native Method) at
    sun.reflect.NativeMethodAccessorImpl.invoke(
     NativeMethodAccessorImpl.java:79) at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(
     DelegatingMethodAccessorImpl.java:43) at
    java.lang.reflect.Method.invoke(Method.java:618) at
    com.ibm.websphere.naming.genericURLInitialContextFactory.
     getAndInvokeMethod(genericURLInitialContextFactory.java:476)
    Caused by: javax.naming.
    ConfigurationException:
     There is no name space at
    com.ibm.ws.naming.urlns.genericURLContextFactory.
     isNameSpaceAccessable(genericURLContextFactory.java:90)
    com.ibm.ws.naming.urlbase.UrlContextFactory.
     getObjectInstance(UrlContextFactory.java:73)

Cause

This error occurs because the client application is running outside of the WebSphere Process Server run time and, therefore, it is not known in the server container context. The lookup of the artifacts using JNDI fails if neither a provider URL nor the initial context factory is specified for the client application.
Refer to the Java EE Client topic in the Information Center.

Resolving The Problem

To solve the problem, make sure you specify the provider URL for the JNDI lookup as well as the initial context factory for WebSphere Process Server in the client application code.

Add the following code before getting the initial context for the location. The example uses localhost and the default port for a WebSphere Process Server profile; adjust these settings, as necessary, for your configuration.


Hashtable env = new Hashtable();
// define the context factory
env.put(Context.INITIAL_CONTEXT_FACTORY,
  "com.ibm.websphere.naming.WsnInitialContextFactory");
// define the provider URL for the JNDI lookup
env.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2809");
Context ic = new InitialContext(env);

You can also set up both parameters when invoking the client application using Java virtual memory (JVM) command-line options, as shown in the following example:

wpsProfileRoot/bin/launchClient.(bat|sh) applicationClient.ear -CCBootstrapPort=port -CCproviderURL=providerURL

Important note


This solution allows the application to look up the needed artifacts using JNDI and to successfully emit the common base event. However, the InvocationTargetException runtime exception remains and is written to the application client log. This problem will be fixed in future WebSphere Application Server V7.0 fix packs by APAR PM09660.

[{"Product":{"code":"SSQH9M","label":"WebSphere Process Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Common Event Infrastructure","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"},{"code":"PF035","label":"z\/OS"}],"Version":"7.0;6.2","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21424590