0

I am using TomEE 7 and JSF 2.2.

I use ajax in a commandButton and it worked fine. But suddenly (not sure what exactly has changed in the application), it is not working, and the commandButton refreshes the page. Checking the JS console it says:

Uncaught ReferenceError: mojarra is not defined
    at HTMLInputElement.onclick

So thanks to this post I discovered that the JSF script was not accessible. So it was loaded in the page:

<head id="j_idt3">
....
<script type="text/javascript" src="/myApp/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&amp;stage=Development"></script>
</head>

But if I try to load the script directly in the browser I get a 500 error, and the logs in TomEE say this a bunch of times:

21-Jun-2017 11:28:48.496 SEVERE [http-nio-8080-exec-2] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Faces Servlet] in context with path [/myApp] threw exception [Error processing webservice request] with root cause
 java.lang.NullPointerException
    at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:245)
    at org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:94)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1102)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:788)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1485)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

So I am now a bit lost on what to try or which direction to go for further research of the problem. Any ideas?


UPDATE

After some testing I have seen that one of my new added dependencies (I am using Maven) seems the responsible for the error. How a dependency can interfere the JSF libraries I don't know. Any suggestion on how I can continue isolating the problem?


Kukeltje
  • 12,223
  • 4
  • 24
  • 47
user1156544
  • 1,725
  • 2
  • 25
  • 51
  • If you read the stacktrace carefully it is **not* the faces servlet that actually throws the NPE but the `org.apache.openejb.server.cxf.rs.CxfRsHttpListener` CXF is probably the framework you added. So effectively you should 'blame' this framework. How they can interfere? Well, if the urls they process are not specifically for them, weird things can always happen. url filters for filters/servlets are always important – Kukeltje Jun 21 '17 at 18:46
  • Perhaps this is another problem... :-? Because CXF has been added and working for a long time already (it is actually shipped with TomEE so I didn't add the dependencies). So perhaps my new database was applying some sort of filter that prevented the JS from being accessed (?) – user1156544 Jun 22 '17 at 16:41

1 Answers1

0

Finally, I think I got it. Solution at bnguyen82 answer in this question. I had to add

<scope>provided</scope>

Inside the dependency in my pom.xml.

user1156544
  • 1,725
  • 2
  • 25
  • 51
  • Scope provide to **what**? What did you add (like you mentioned in your question)? So 'suddenly' not working is not suddenly but after you added some other framework... What framework? CXF? – Kukeltje Jun 21 '17 at 18:42
  • And btw, there is **nothing** by this user in the question/answer you refer to. – Kukeltje Jun 21 '17 at 18:56
  • Thanks! I corrected the link. I didn't add another framework, I updated my database to a new version and needed to consequently update the new version dependencies in the pom. Everything seemed to work for some days without me realising the js was missing. I added the scope to the dependency of the new database. – user1156544 Jun 22 '17 at 16:38