Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #23968 > unrolled thread
| Started by | RVic <rvince99@hotmail.com> |
|---|---|
| First post | 2013-05-09 09:53 -0700 |
| Last post | 2013-05-12 19:10 -0700 |
| Articles | 14 — 6 participants |
Back to article view | Back to comp.lang.java.programmer
Unable to trace RVic <rvince99@hotmail.com> - 2013-05-09 09:53 -0700
Re: Unable to trace Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-05-09 13:04 -0400
Re: Unable to trace markspace <markspace@nospam.nospam> - 2013-05-09 15:39 -0700
Re: Unable to trace Arne Vajhøj <arne@vajhoej.dk> - 2013-05-09 21:45 -0400
Re: Unable to trace RVic <rvince99@hotmail.com> - 2013-05-09 19:32 -0700
Re: Unable to trace RVic <rvince99@hotmail.com> - 2013-05-09 19:41 -0700
Re: Unable to trace Arne Vajhøj <arne@vajhoej.dk> - 2013-05-12 21:51 -0400
Re: Unable to trace RVic <rvince99@hotmail.com> - 2013-05-10 07:26 -0700
Re: Unable to trace Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-05-10 10:43 -0400
Re: Unable to trace Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-10 09:52 -0700
Re: Unable to trace Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-05-10 19:03 +0200
Re: Unable to trace Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-10 11:02 -0700
Re: Unable to trace Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-05-10 23:37 +0200
Re: Unable to trace RVic <rvince99@hotmail.com> - 2013-05-12 19:10 -0700
| From | RVic <rvince99@hotmail.com> |
|---|---|
| Date | 2013-05-09 09:53 -0700 |
| Subject | Unable to trace |
| Message-ID | <a06740e3-a629-42de-944b-6dffd69a1424@googlegroups.com> |
Related to my previous post here, I have a simple piece of code in a servlet:
HttpServletRequest request = RequestData.getRequest();
HttpServletResponse response = RequestData.getResponse();
request.getRequestDispatcher("/something").forward(request, response);
The last line of which throws an error (below) which I am unable to trace further from this line in the stack. The error is :
javax.el.ELException: Cannot convert beta of type class java.lang.String to class com.cblnet.web.data.Env
and com.cblnet.web.data.Env is:
public enum Env {
local,
mirror,
production;
}
But if you look at the stack trace, below (the last line in it is the last line in my simple three lines of code, the request.getRequestDispatcher().forward() ) I have no way to trace what is causing this -- can anyone shed any light here for me on how to track down this frustrating offender? Thanks in advance, RVic
2013-05-09 11:22:23,425 ERROR [ajp-bio-9509-exec-4] [Page] Error forwarding request to display JSP.
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.servlet.jsp.JspException: javax.el.ELException: Cannot convert beta of type class java.lang.String to class com.cblnet.web.data.Env
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at com.cblnet.web.view.Page.forward(Page.java:73)
[toc] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2013-05-09 13:04 -0400 |
| Message-ID | <kmgkov$qoc$1@dont-email.me> |
| In reply to | #23968 |
On 5/9/2013 12:53 PM, RVic wrote:
> Related to my previous post here, I have a simple piece of code in a servlet:
>
> HttpServletRequest request = RequestData.getRequest();
> HttpServletResponse response = RequestData.getResponse();
> request.getRequestDispatcher("/something").forward(request, response);
>
> The last line of which throws an error (below) which I am unable to trace further from this line in the stack. The error is :
>
> javax.el.ELException: Cannot convert beta of type class java.lang.String to class com.cblnet.web.data.Env
>
> and com.cblnet.web.data.Env is:
>
> public enum Env {
> local,
> mirror,
> production;
> }
Just a guess: What happens if you change the Env enum to
public enum Env {
local,
mirror,
production,
beta; // this is the guess
}
? If somebody somewhere calls Env.valueOf("beta") they should get
an IllegalArgumentException (using the original Env), but perhaps
they're catching it and throwing an ElException instead.
--
Eric Sosman
esosman@comcast-dot-net.invalid
[toc] | [prev] | [next] | [standalone]
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Date | 2013-05-09 15:39 -0700 |
| Message-ID | <kmh8cs$ems$1@dont-email.me> |
| In reply to | #23968 |
On 5/9/2013 9:53 AM, RVic wrote: > The last line of which throws an error (below) which I am unable to > trace further from this line in the stack. The error is : > > But if you look at the stack trace, I have to somewhat doubt your premise. If you look at the stack trace, it looks to me like the dispatch succeeded, and you got an error somewhere after that. This line here seems to say that you're in a filter, running code: > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) > at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) And then you seem to dispatch to a servlet: > at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) And then you run a JSP file. Etc. I'm not sure how to find out exactly what file you're running though. That might take a little research and experimentation.
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-05-09 21:45 -0400 |
| Message-ID | <518c5148$0$32115$14726298@news.sunsite.dk> |
| In reply to | #23968 |
On 5/9/2013 12:53 PM, RVic wrote:
> Related to my previous post here, I have a simple piece of code in a servlet:
>
> HttpServletRequest request = RequestData.getRequest();
> HttpServletResponse response = RequestData.getResponse();
> request.getRequestDispatcher("/something").forward(request, response);
>
> The last line of which throws an error (below) which I am unable to trace further from this line in the stack. The error is :
>
> javax.el.ELException: Cannot convert beta of type class java.lang.String to class com.cblnet.web.data.Env
>
> and com.cblnet.web.data.Env is:
>
> public enum Env {
> local,
> mirror,
> production;
> }
>
> But if you look at the stack trace, below (the last line in it is the last line in my simple three lines of code, the request.getRequestDispatcher().forward() ) I have no way to trace what is causing this -- can anyone shed any light here for me on how to track down this frustrating offender? Thanks in advance, RVic
>
>
> 2013-05-09 11:22:23,425 ERROR [ajp-bio-9509-exec-4] [Page] Error forwarding request to display JSP.
> org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.servlet.jsp.JspException: javax.el.ELException: Cannot convert beta of type class java.lang.String to class com.cblnet.web.data.Env
> at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
> at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
> at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
> at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
> at com.cblnet.web.view.Page.forward(Page.java:73)
How does the JSP page you forward to look like?
Does it refer to "beta" anywhere?
Arne
[toc] | [prev] | [next] | [standalone]
| From | RVic <rvince99@hotmail.com> |
|---|---|
| Date | 2013-05-09 19:32 -0700 |
| Message-ID | <50f03997-81fa-4973-8621-2301bb40d7d0@googlegroups.com> |
| In reply to | #23968 |
I have jsp's that DO refer to 'beta' but not the jsp's being forwarded to here. Simply, it is calling this jsp:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="cn" %>
<%@ taglib tagdir="/WEB-INF/tags/admin" prefix="admin" %>
<%@ taglib tagdir="/WEB-INF/tags/footer" prefix="footer" %>
<%@ taglib tagdir="/WEB-INF/tags/header" prefix="header" %>
<%@ taglib tagdir="/WEB-INF/tags/sidebar" prefix="sidebar" %>
<%--@elvariable id="bodyUrl" type="java.lang.String"--%>
<%--@elvariable id="user" type="com.capablenet.domain.User"--%>
">view site
Where bodyUrl is this jsp:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
Administration | Access Denied
${text}
We're sorry, the page you are trying to reach is part of a restricted portion of our site.
You are not currently logged on with proper permissions to view it.
If you believe you should have permissions to view this area, please send us ">Feedback.
[toc] | [prev] | [next] | [standalone]
| From | RVic <rvince99@hotmail.com> |
|---|---|
| Date | 2013-05-09 19:41 -0700 |
| Message-ID | <104d1ae2-151b-46a0-be21-5bcd62b6a4dd@googlegroups.com> |
| In reply to | #23968 |
I have jsp's that DO refer to 'beta' but not the jsp's being forwarded to here. Simply, it is calling this jsp:
'<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
'<%@ taglib tagdir="/WEB-INF/tags" prefix="cn" %>
'<%@ taglib tagdir="/WEB-INF/tags/admin" prefix="admin" %>
'<%@ taglib tagdir="/WEB-INF/tags/footer" prefix="footer" %>
'<%@ taglib tagdir="/WEB-INF/tags/header" prefix="header" %>
'<%@ taglib tagdir="/WEB-INF/tags/sidebar" prefix="sidebar" %>
'
'<%--@elvariable id="bodyUrl" type="java.lang.String"--%>
'<%--@elvariable id="user" type="com.capablenet.domain.User"--%>
'
'<cn:html>
' <admin:head/>
' <body id="admin">
' <div id="container">
' <div id="header" style="float:left;">
' <admin:adminNav/>
' </div>
' <br class="clear"/>
'
' <div id="site_info">
' <header:communityBrand/>
' <div id="site-links">
' <a id="viewsite" href="<c:url value="/"/>">view site</a>
' </div>
' <admin:currentUser user="${user}"/>
' </div>
' <div id="main-content">
' <div id="inner-content">
' <c:import url="${bodyUrl}"/>
' <br class="clear"/>
' </div>
' </div>
' <footer:footer/>
' </div>
' </body>
'</cn:html>
Where ${bodyURL} is:
'<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
'
'<h1 class="title">Administration | <span>Access Denied</span></h1>
'
'<c:choose>
' <c:when test="${!empty text}">
' <p>
' ${text}
' </p>
' </c:when>
' <c:otherwise>
' <p><strong>
' We're sorry, the page you are trying to reach is part of a restricted 'portion of our site.
' You are not currently logged on with proper permissions to view it.
' </strong></p>
'
' <p>
' If you believe you should have permissions to view this area, please 'send us <a href="<c:url value="/help/feedback"/>">Feedback</a>.
' </p>
' </c:otherwise>
'</c:choose>
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-05-12 21:51 -0400 |
| Message-ID | <51904713$0$32104$14726298@news.sunsite.dk> |
| In reply to | #23980 |
On 5/9/2013 10:41 PM, RVic wrote: > I have jsp's that DO refer to 'beta' but not the jsp's being forwarded to here. Simply, it is calling this jsp: ... Apparently the problem has been solved. But I am a bit puzzled. The problem happened in some servlet code that forwarded to a JSP page. If neither that servlet or that JSP page referred to beta - then where did the call that try to parse "beta" occur?? Arne
[toc] | [prev] | [next] | [standalone]
| From | RVic <rvince99@hotmail.com> |
|---|---|
| Date | 2013-05-10 07:26 -0700 |
| Message-ID | <276fd7a3-461d-4df4-855a-63d49b900120@googlegroups.com> |
| In reply to | #23968 |
I got it. Thanks for pointing me in the right direction Eric -- the Env enum needed the enumeration 'beta' in it. Thanks for your help guys, I am most grateful. RVic
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2013-05-10 10:43 -0400 |
| Message-ID | <kmj0r9$aa1$1@dont-email.me> |
| In reply to | #23982 |
On 5/10/2013 10:26 AM, RVic wrote:
> I got it. Thanks for pointing me in the right direction Eric -- the Env enum needed the enumeration 'beta' in it.
>
> Thanks for your help guys, I am most grateful. RVic
That's probably not the end of your problems, just a clue
about their mechanism. Adding a `beta' value to the enum means
that Env.valueOf("beta") will now return Env.beta instead of
throwing an exception. That's all fine and dandy, but what will
the rest of the code do when it encounters this new Env.beta
object? For example, there may be something like
Env env = Env.valueOf(someString);
switch (env) {
case local:
// ...
break;
case mirror:
// ...
break;
case production:
// ...
break;
}
A "beta" value will no longer cause an exception in this code,
but whatever was supposed to have been done by the switch block
will remain un-done ... (This is one reason I think it's almost
always a good idea to have a `default:' label in every switch,
even if all it does is `assert false;'.)
You don't have a cure yet (not for sure, anyhow): You just
have the beginnings of a diagnosis.
--
Eric Sosman
esosman@comcast-dot-net.invalid
[toc] | [prev] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2013-05-10 09:52 -0700 |
| Message-ID | <BB9jt.64$7j7.18@newsfe14.iad> |
| In reply to | #23983 |
On 5/10/13 7:43 AM, Eric Sosman wrote:
> On 5/10/2013 10:26 AM, RVic wrote:
>> I got it. Thanks for pointing me in the right direction Eric -- the
>> Env enum needed the enumeration 'beta' in it.
>>
>> Thanks for your help guys, I am most grateful. RVic
>
> That's probably not the end of your problems, just a clue
> about their mechanism. Adding a `beta' value to the enum means
> that Env.valueOf("beta") will now return Env.beta instead of
> throwing an exception. That's all fine and dandy, but what will
> the rest of the code do when it encounters this new Env.beta
> object? For example, there may be something like
>
> Env env = Env.valueOf(someString);
> switch (env) {
> case local:
> // ...
> break;
> case mirror:
> // ...
> break;
> case production:
> // ...
> break;
> }
>
> A "beta" value will no longer cause an exception in this code,
> but whatever was supposed to have been done by the switch block
> will remain un-done ... (This is one reason I think it's almost
> always a good idea to have a `default:' label in every switch,
> even if all it does is `assert false;'.)
Or make the enum an abstract base class and have all behavior defined in
the enum itself.
For example, using them as a flyweight:
<http://virtualinfinity.net/wordpress/program-design/2007/10/22/using-enums-as-a-flyweight-pattern/>
Switching on an enum is dangerous business, just for the reason Eric is
demonstrating. Someone adds a new enum, and switch logic no longer
handles every case. If I do happen to use an enum and have a switch
statement for it, I *always* have a default case. Sometimes that default
is "throw new UnsupportedOperationException();" Other times that default
is something that is "sensible" if an override isn't specified.
[toc] | [prev] | [next] | [standalone]
| From | Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> |
|---|---|
| Date | 2013-05-10 19:03 +0200 |
| Message-ID | <kmj91p$shb$2@dont-email.me> |
| In reply to | #23985 |
On 10/05/2013 18:52, Daniel Pitts allegedly wrote: > Switching on an enum is dangerous business, just for the reason Eric is > demonstrating. Someone adds a new enum, and switch logic no longer > handles every case. If I do happen to use an enum and have a switch > statement for it, I *always* have a default case. Sometimes that default > is "throw new UnsupportedOperationException();" Other times that default > is something that is "sensible" if an override isn't specified. Crossing the street is dangerous business, too. -- DF.
[toc] | [prev] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2013-05-10 11:02 -0700 |
| Message-ID | <tCajt.34$Ax6.31@newsfe25.iad> |
| In reply to | #23987 |
On 5/10/13 10:03 AM, Daniele Futtorovic wrote: > On 10/05/2013 18:52, Daniel Pitts allegedly wrote: >> Switching on an enum is dangerous business, just for the reason Eric is >> demonstrating. Someone adds a new enum, and switch logic no longer >> handles every case. If I do happen to use an enum and have a switch >> statement for it, I *always* have a default case. Sometimes that default >> is "throw new UnsupportedOperationException();" Other times that default >> is something that is "sensible" if an override isn't specified. > > Crossing the street is dangerous business, too. Switching on an enum is more likely to result in an accident. One can look both ways before crossing the street, but the breaking of a switch statement can happen years after you wrote it. It would be like getting hit by a bus a month after you crossed its path.
[toc] | [prev] | [next] | [standalone]
| From | Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> |
|---|---|
| Date | 2013-05-10 23:37 +0200 |
| Message-ID | <kmjp4i$u1p$1@dont-email.me> |
| In reply to | #23989 |
On 10/05/2013 20:02, Daniel Pitts allegedly wrote: > On 5/10/13 10:03 AM, Daniele Futtorovic wrote: >> On 10/05/2013 18:52, Daniel Pitts allegedly wrote: >>> Switching on an enum is dangerous business, just for the reason Eric is >>> demonstrating. Someone adds a new enum, and switch logic no longer >>> handles every case. If I do happen to use an enum and have a switch >>> statement for it, I *always* have a default case. Sometimes that default >>> is "throw new UnsupportedOperationException();" Other times that default >>> is something that is "sensible" if an override isn't specified. >> >> Crossing the street is dangerous business, too. > > Switching on an enum is more likely to result in an accident. One can > look both ways before crossing the street, but the breaking of a switch > statement can happen years after you wrote it. It would be like getting > hit by a bus a month after you crossed its path. I would also strongly advise, when writing a switch on an enum, to account for all possible (future) cases, possibly using a throw in the default clause, or some similar means. That being said, this goes for switches on other types as well; and either way a switch might purposively and gracefully cover only part of the possible values. What I disagree with is what I construe as an implication that one should steer clear from switches on enums because of those "risks". Such switches are no more and no less "dangerous" than the vast majority of code constructs. And they rank firmly among the Very Useful ones. -- DF.
[toc] | [prev] | [next] | [standalone]
| From | RVic <rvince99@hotmail.com> |
|---|---|
| Date | 2013-05-12 19:10 -0700 |
| Message-ID | <28dd4155-9ae4-412f-aedb-04267d0247f4@googlegroups.com> |
| In reply to | #23968 |
in <admin: head>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web