[jboss-user] [JBoss Seam] - messageformat error blows up (JBSEAM-1859)
atao
do-not-reply at jboss.com
Tue Aug 28 08:09:06 EDT 2007
When an EL expression is not closed by a brace, an error is thrown.
It would be better to show the wrong expression as it is:
1/ it's already the way of doing the thing, see in InterpolatorTest the existing case of
// test that a messageformat error doesn't blow up
Assert.assertEquals("{nosuchmessage}", interpolator.interpolate("{nosuchmessage}"));
2/ atm when an EL expression is not closed by a brace, the trace doesn't give a clear clue of what is wrong (see trace below). I wasted too much time with such an error.
With the wrong expression shown in place of the expected result, it'd be straightforward.
In any case I suggest to check that the end bracket is present and at least to throw a exception with a specific message.
====================
Error in Authenticator:
| public boolean authenticate() {
| try {
| User user = (User) entityManager
| .createQuery(
| "from User where username = :username and password = :password")
| .setParameter("username", identity.getUsername())
| .setParameter("password", identity.getPassword())
| .getSingleResult();
|
| if (user.getRoles() != null) {
| for (UserRole mr : user.getRoles())
| Identity.instance().addRole(mr.getName());
| }
| return true;
| } catch (NoResultException ex) {
| FacesMessages.instance().add(
| "#{messages['entity.user.login.invalid']");
| return false;
| }
| }
|
|
and the trace (only the first occurence, as it starts a loop):
anonymous wrote :
| 13:47:43,500 INFO [STDOUT] Hibernate: select user0_.username as username11_, user0_.name as name11_, user0_.password as password11_, user0_.currentBranch as currentB4_11_ from User user0_ where user0_.username=? and user0_.password=?
| 13:47:43,531 ERROR [SeamPhaseListener] uncaught exception
| java.util.NoSuchElementException
| at java.util.StringTokenizer.nextToken(StringTokenizer.java:332)
| at org.jboss.seam.core.Interpolator.interpolateExpressions(Interpolator.java:94)
| at org.jboss.seam.core.Interpolator.interpolate(Interpolator.java:66)
| at org.jboss.seam.faces.FacesMessages.createFacesMessage(FacesMessages.java:371)
| at org.jboss.seam.faces.FacesMessages.createFacesMessage(FacesMessages.java:379)
| at org.jboss.seam.faces.FacesMessages$1.run(FacesMessages.java:425)
| at org.jboss.seam.faces.FacesMessages.runTasks(FacesMessages.java:156)
| at org.jboss.seam.faces.FacesMessages.afterPhase(FacesMessages.java:166)
| at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:224)
| at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:184)
| at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
| at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:82)
| at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
| at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
| at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
| at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
| at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
| at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
| at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
| at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
| at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:149)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
| at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
| at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
| at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:624)
| at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
| at java.lang.Thread.run(Thread.java:595)
| 13:47:43,562 ERROR [CachedConnectionValve] Application error: Faces Servlet did not complete its transaction
| 13:47:43,609 ERROR [SeamPhaseListener] uncaught exception
| java.util.NoSuchElementException
| at java.util.StringTokenizer.nextToken(StringTokenizer.java:332)
| at org.jboss.seam.core.Interpolator.interpolateExpressions(Interpolator.java:94)
| at org.jboss.seam.core.Interpolator.interpolate(Interpolator.java:66)
| at org.jboss.seam.faces.FacesMessages.createFacesMessage(FacesMessages.java:371)
| at org.jboss.seam.faces.FacesMessages.createFacesMessage(FacesMessages.java:379)
| at org.jboss.seam.faces.FacesMessages$1.run(FacesMessages.java:425)
|
| [...]
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078720#4078720
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4078720
More information about the jboss-user
mailing list