2

I have a very simple "dynamic web application" which results in a war-file. I (deliberately) used the name of a non-existing bean (for experimentation and learning purpose). When deployed to tomcat I can see the page in firefox, but I get no error or warning neither in catalina.out nor in catalina*.log.

What is wrong, where can I see such warnings?

I'm using java 8, tomcat 8, eclipse 4.5.1 (mars), jsf-api.2.2.8.jar and jsf-impl.2.2.8.jar.

I don't have any java code of my own (yet), especially no beans.

The index.xhtml that is used (and, aside of the missing bean value) displayed correctly is:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
</head>
<body>
<ins>This is some other xhtml</ins>

<h:commandButton value="A#{missingBean.name}Z" action="#{missingBean.doAction}"></h:commandButton>
<h:messages></h:messages>
</body>
</html>

EDIT: thanks to @Kukeltje I added

<context-param>
    <param-name>javax.faces.DEVELOPMENT_STAGE
    </param-name>
    <param-value>Development</param-value>
</context-param>

to my web.xml file. This results in an HTTP Status 500 - javax.el.PropertyNotFoundException: /index.xhtml @13,81 action="#{missingBean.doAction}": Target Unreachable, identifier 'missingBean' resolved to null.

This solved the original problem that I didn't get errors nor even warnings on an obvious (and deliberate) coding error.

Background information: I try to learn jsf and did some experiments based on a tutorials-point tutorial. Having messed that up by trying far too many things in one go, I resolved to start a new eclipse project from scratch, going very tiny step by step, to see not only the result (as would be by blindly doing copy&paste), but also what errors I'll see if I neglect something on the way.

Gyro Gearloose
  • 1,056
  • 1
  • 9
  • 26
  • 1
    Try setting the PROJECT_STAGE to development. See http://stackoverflow.com/questions/19193912/uses-of-javax-faces-project-stage – Kukeltje Nov 13 '15 at 15:14
  • Thanks, but no change to the behavior. Only when I changed javax.faces.DEVELOPEMENT_STAGE to javax.faces.UNDERDEVELOPEMENT_STAGE tomcat crashed (coredump) but worked like before after stop/start: no warnings, no errors – Gyro Gearloose Nov 13 '15 at 15:28
  • Try changing HTML tags to JSF equivalent components such `` to ``, `` to `` and whatever there might be in the actual code. Look also into the rendered HTML on the browser. – Tiny Nov 13 '15 at 15:32
  • @Tiny: shame, shame, shame I missed those. – Kukeltje Nov 13 '15 at 15:39
  • Good idea, adding a cured some problems with a previous try to learn jsf, but for this question, no, no change. The turns into a

    in firefox Ctrl-U / view source.

    – Gyro Gearloose Nov 13 '15 at 15:40
  • Where did you find those properties: javax.faces.DEVELOPEMENT_STAGE and javax.faces.UNDERDEVELOPEMENT_STAGE... and where did you set them. It should be 'javax.faces.PROJECT_STAGE'..... – Kukeltje Nov 13 '15 at 15:41
  • Found it in https://weblogs.java.net/blog/driscoll/archive/2009/09/28/jsf-20-reminder-project-stage (thanks to your hint) .The "UNDER" was just a prefix trying to get some warnings about non-existing constants. – Gyro Gearloose Nov 13 '15 at 15:43
  • Ah, now explicitly with 'javax.faces.PROJECT_STAGE" the browser shows "The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within ", will try this asap. – Gyro Gearloose Nov 13 '15 at 15:47
  • Success! Now I get "Target Unreachable, identifier 'missingBean' resolved to null" in the browser window, but only after clicking the button. Now I wonder why a h:form is required to execute #{...} statements and trigger error messages. – Gyro Gearloose Nov 13 '15 at 15:53
  • Spelling DEVELOPMENT_STAGE correctly is a great advantage, wish I had payed more attention in school when reading and writing was learned. – Gyro Gearloose Nov 13 '15 at 16:17
  • Sorry, having been all eager to try everything, in the meantime I created a bean named missingBean having a name-attribute and forgot about it. So my comment about error only when clicking the button is obsolete, thanks to @Kukeltje, the problem is solved. – Gyro Gearloose Nov 13 '15 at 17:02
  • Without a form nothing is submitted to the client – Kukeltje Nov 13 '15 at 17:45
  • That context param doesn't have any effect when rendering the response. That exception occurs only when you actually submit the form, regardless of the context param. – BalusC Nov 13 '15 at 18:07
  • @BallusC I'm a bit confused ... what "context param" are you referring to? And the original "problem" was that there was NO exception that could have warned me that something wasn't right with my coding. – Gyro Gearloose Nov 13 '15 at 18:36
  • @BallusC, o please excuse me, you are referring to that javax.faces.DEVELOPMENT_STAGE Development that I've from Kukeltje's hint --- copy&paste just bypasses the brain. With no actual bean method present, I actually see an error message. (My fault that I asked and experimented at the same time and got confused about it). – Gyro Gearloose Nov 13 '15 at 19:16
  • As Kukeltje said, both javax.faces.DEVELOPEMENT_STAGE and javax.faces.UNDERDEVELOPEMENT_STAGE do not appear to be valid, only javax.faces.PROJECT_STAGE. See [Configuring Project Stage](http://docs.oracle.com/javaee/6/tutorial/doc/bnaxj.html#giqxl) for documentation. Note: with Mojarra JSF2.2.8-11 on Tomcat 7.0.68, I find I never get an exception for "#{nonexistentBean.method}", and I always get an exception for "#{validBean.illegalMethod}" regardless of the setting of either variable. – Pixelstix Oct 04 '16 at 18:18
  • The previous link was in the Java EE 6 documentation. The corresponding link in the Java EE 7 documentation, [Configuring Project Stage](https://docs.oracle.com/javaee/7/tutorial/jsf-configure012.htm#GIQXL). – Pixelstix Oct 04 '16 at 18:28

0 Answers0