Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After getting a valueable hint, I found a solution. The WAR has the JSF Implementation JARs inside its WEB-INF\lib. As WAR and HAR are separate deployments, they use separate class loaders, which results in the WAR loading JSF Implementation from its WEB-INF\lib, while the HAR loads it from the JBOSS installation. </p> <p>I was able to force the use of the correct classloader by changing the above code in the following way:</p> <pre><code>protected static String tryToFindUserLogin() { try { /*** Obtain the classLoader from the calling Thread, instead of using the default ***/ ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Class classFacesContext = classLoader.loadClass("javax.faces.context.FacesContext"); Class classExternalContext = classLoader.loadClass("javax.faces.context.ExternalContext"); /**************/ Method methodGetCurrentInstance = classFacesContext.getMethod("getCurrentInstance", (Class[])null); Method methodGetExternalContext = classFacesContext.getMethod("getExternalContext", (Class[])null); Method methodGetRemoteUser = classExternalContext.getMethod("getRemoteUser", (Class[])null); Object currentFacesContext = methodGetCurrentInstance.invoke(null, (Object[])null); Object currentExternalContext = methodGetExternalContext.invoke(currentFacesContext, (Object[])null); String login = (String) methodGetRemoteUser.invoke(currentExternalContext, (Object[])null); logger.debug("Found Weblogin: " + login); return login; } catch (Throwable e) { logger.debug(e, e); } return "anonymous"; } </code></pre> <p>Additionally I changed the catch block to catch(Throwable), because if run in non JSF environment getMethod() might throw a RuntimeException, which ist not caught by catch(Exception)</p> <p>This works perfectly!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload