0

I have a project where I need to load jsf beans from jars.

The application in packaged as a single ear, with those jars inside lib folder, and faces config file inside its META-INF:

 MyEAR
   |
   |--MyWar
   |
   |--/lib
        |
        |--myJar
             |
             |--/META-INF/faces-config.xml

Faces config is a standard empty faces config:

<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
        http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">
</faces-config>

Beans (inside jars) are annotated as follow:

@ManagedBean(name="myBean", eager=false)
@ViewScoped
public class MyController {
    ...
}

and are referenced from xhtml pages:

<p:commandButton styleClass="myButton"
  update="@form" id="myButton" value="#{myBean.label}"
  actionListener="#{myBean.onMyBeanClick}" />

When loading the page, I got an error 500 with the following message:

    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
Caused by: javax.el.PropertyNotFoundException: /pages/myPage.xhtml at line 140 and column 66 value="#{myBean.label}": Target Unreachable, identifier 'myBean' resolved to null
    at org.apache.myfaces.view.facelets.el.TagValueExpression.getType(TagValueExpression.java:73)
    at org.primefaces.util.ComponentUtils.getConverter(ComponentUtils.java:128)

Environment is WebSphere 8.5, with myfaces 2 and primefaces 5.

There is any configuration I'm missing?

Thanks,

D.

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
Dan M
  • 315
  • 2
  • 13
  • See the third comment in the answer in the 'duplicate'. Found this btw after 5 mininutes of searching in google (I searched in general, not websphere specific, but often 'specific' questions for other environments contain 'general' answers) – Kukeltje Nov 03 '15 at 15:51
  • Thanks for pointing me to the answer, I wasn't able to find it (specially as the answer is in the comment). Even though the answer is correct, I'd still prefer to have the jars outside of the war (best option for me is to have them inside a websphere's shared library), as not to have developer of specific components mess with the main application. I'll try to edit the question accordingly. – Dan M Nov 03 '15 at 16:19
  • Then use cdi managed beans. That works if you read the answer – Kukeltje Nov 03 '15 at 16:21
  • But read the answer carefully. Maybe your managed beans contain to much logic – Kukeltje Nov 03 '15 at 16:23
  • The external jar will contain both xhtml widget and java logic. I want them separated from the main application so that I can completely separate the development and build of the widget and their logic to the development and build of the main application, as the widget will implent all a common interface and will be loaded dinamically – Dan M Nov 03 '15 at 16:31
  • As explained in point 1c of the duplicate, front end artifacts do NOT belong in EAR/lib. Put/split it in WAR/WEB-INF/lib – BalusC Nov 03 '15 at 18:58
  • While I may agree with you from design point of view, how do you satisfy the requisite of separate development of complex widget which I want to be deployed without rebuilding (and deploying) the whole ear/war (as they are developed by different teams, and they follow different change stream)? – Dan M Nov 04 '15 at 11:26

0 Answers0