Hassnain Alvi
Hassnain Alvi

Reputation: 87

Use Bundled libs Websphere liberty

I am using websphere liberty with java 8 docker image but after trying everything. i am unable to load my own bundled libs instead of liberty built-in as per my assumption and from logs My jsp and other libs are in WEB-INF/lib directory inside my war file

Here is the config I am using

<?xml version="1.0" encoding="UTF-8"?>
<server description="Default server">

    <!-- Enable features -->
    <featureManager>
        <feature>javaee-8.0</feature>
        <feature>microProfile-3.0</feature>
    </featureManager>

    <basicRegistry id="basic" realm="BasicRealm">
        <!-- <user name="yourUserName" password="" />  -->
    </basicRegistry>

    <logging  traceSpecification="com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HTTPChannel=all:GenericBNF=all:HTTPDispatcher=all"
    traceFileName="trace.log"
    maxFileSize="20"
    maxFiles="10"
    traceFormat="BASIC" />

    <library id="OJDBC5Lib">
        <fileset dir="/config/ojdbc5.jar" includes="ojdbc5.jar"/>
    </library>

    <!-- To allow access to this server from a remote client host="*" has been added to the following element -->
    <httpEndpoint id="defaultHttpEndpoint"
                  host="*"
                  httpPort="9080"
                  httpsPort="9443" />

    <webApplication id="e-app" name="e-app" location="/apps/e-app.war" contextRoot="/e-app">
        <classloader delegation="parentLast" />
    </webApplication>

When I run. the application I get an exception

[AUDIT   ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 14.831 seconds.
[ERROR   ] SRVE0271E: Uncaught init() exception created by servlet [Faces Servlet] in application [e-app]: java.lang.IllegalStateException: Could not find ba
ckup for factory javax.faces.context.FacesContextFactory.
        at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1004)
        at [internal classes]

[ERROR   ] SRVE0276E: Error while initializing Servlet [Faces Servlet]: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:360)
        at [internal classes]
Caused by: java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory.
        at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1004)
        ... 1 more

Can someone tell me what needs to be done in config to make it work

Upvotes: 0

Views: 709

Answers (1)

Andy McCright
Andy McCright

Reputation: 1283

The problem here is that the javaee-8.0 feature includes the jsf-2.3 feature that includes the JSF APIs and Liberty's JSF implementation. In order to provide your own JSF implementation, you will need to remove the jsf-2.3 feature and use the jsfContainer-2.3 feature instead. This doc has more details: https://www.ibm.com/support/knowledgecenter/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_jsf23_implementations.html

The javaee-8.0 feature includes a ton of features - many of which you may not need, but unfortunately you will need to specify all of the features that you do need (in addition to jsfContainer-2.3). So your server.xml's <featureManager> element might end up looking something like this:

<featureManager>
  <!-- webprofile-8.0 features but using jsfContainer instead of jsf -->
  <feature>appSecurity-3.0</feature>
  <feature>beanValidation-2.0</feature>
  <feature>cdi-2.0</feature>
  <feature>ejbLite-3.2</feature>
  <feature>el-3.0</feature>
  <feature>jaspic-1.1</feature>
  <feature>jaxrs-2.1</feature>
  <feature>jdbc-4.2</feature>
  <feature>jndi-1.0</feature>
  <feature>jpa-2.2</feature>
  <feature>jsfContainer-2.3</feature>
  <feature>jsonb-1.0</feature>
  <feature>jsonp-1.1</feature>
  <feature>jsp-2.3</feature>
  <feature>managedBeans-1.0</feature>
  <feature>servlet-4.0</feature>
  <feature>transaction-1.2</feature>
  <feature>websocket-1.1</feature>

  <!-- full profile 8 features not in web profile -->
  <feature>appClientSupport-1.0</feature>
  <feature>batch-1.0</feature>
  <feature>concurrent-1.0</feature>
  <feature>ejb-3.2</feature>
  <feature>jacc-1.5</feature>
  <feature>javaMail-1.6</feature>
  <feature>javax.persistence.base-2.2</feature>
  <feature>jaxws-2.2</feature>
  <feature>jca-1.7</feature>
  <feature>jcaInboundSecurity-1.0</feature>
  <feature>jms-2.0</feature>
  <feature>j2eeManagement-1.1</feature>
  <feature>wasJmsClient-2.0</feature>
  <feature>wasJmsSecurity-1.0</feature>
  <feature>wasJmsServer-1.0</feature>
</featureManager>

It's a huge list, so you'll likely want to prune it a little (for example, remove all JMS-related feature if you are not using JMS). But once you swap jsf-2.3 for jsfContainer-2.3 then Liberty should find and use the JSF implementation in your app - and you shouldn't need to use parentLast delegation in your app either.

Upvotes: 1

Related Questions