211 |
22 Mar 05 |
nicklas |
1 |
<%-- $Id$ |
211 |
22 Mar 05 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2005 Nicklas Nordborg |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Johan Enell, Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Johan Enell, Nicklas Nordborg |
211 |
22 Mar 05 |
nicklas |
6 |
|
2304 |
22 May 06 |
jari |
7 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
8 |
Available at http://base.thep.lu.se/ |
211 |
22 Mar 05 |
nicklas |
9 |
|
211 |
22 Mar 05 |
nicklas |
10 |
BASE is free software; you can redistribute it and/or |
211 |
22 Mar 05 |
nicklas |
11 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
12 |
as published by the Free Software Foundation; either version 3 |
211 |
22 Mar 05 |
nicklas |
13 |
of the License, or (at your option) any later version. |
211 |
22 Mar 05 |
nicklas |
14 |
|
211 |
22 Mar 05 |
nicklas |
15 |
BASE is distributed in the hope that it will be useful, |
211 |
22 Mar 05 |
nicklas |
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
211 |
22 Mar 05 |
nicklas |
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
211 |
22 Mar 05 |
nicklas |
18 |
GNU General Public License for more details. |
211 |
22 Mar 05 |
nicklas |
19 |
|
211 |
22 Mar 05 |
nicklas |
20 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
21 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
211 |
22 Mar 05 |
nicklas |
22 |
------------------------------------------------------------------ |
211 |
22 Mar 05 |
nicklas |
23 |
|
211 |
22 Mar 05 |
nicklas |
24 |
All exceptions are directed to this page, by the server configuration |
211 |
22 Mar 05 |
nicklas |
25 |
See <error-page> tag in the /WEB-INF/web.xml file. |
211 |
22 Mar 05 |
nicklas |
26 |
|
211 |
22 Mar 05 |
nicklas |
27 |
Some exceptions are fowarded to other pages to be able to |
211 |
22 Mar 05 |
nicklas |
28 |
display a more appropriate error message. |
211 |
22 Mar 05 |
nicklas |
29 |
|
211 |
22 Mar 05 |
nicklas |
30 |
Only severe, unexpected exceptions, are handled by this page, |
211 |
22 Mar 05 |
nicklas |
31 |
which will only display a stack trace! |
211 |
22 Mar 05 |
nicklas |
32 |
|
211 |
22 Mar 05 |
nicklas |
33 |
@author Nicklas |
211 |
22 Mar 05 |
nicklas |
34 |
@version 2.0 |
211 |
22 Mar 05 |
nicklas |
35 |
--%> |
5426 |
24 Sep 10 |
nicklas |
36 |
<%@ page pageEncoding="UTF-8" session="false" |
2118 |
28 Mar 06 |
nicklas |
37 |
import="net.sf.basedb.core.Application" |
2118 |
28 Mar 06 |
nicklas |
38 |
import="net.sf.basedb.core.Config" |
532 |
09 May 05 |
nicklas |
39 |
import="net.sf.basedb.core.NotLoggedInException" |
532 |
09 May 05 |
nicklas |
40 |
import="net.sf.basedb.core.PermissionDeniedException" |
532 |
09 May 05 |
nicklas |
41 |
import="net.sf.basedb.core.InvalidDataException" |
1960 |
10 Feb 06 |
martin |
42 |
import="net.sf.basedb.core.SessionControl" |
211 |
22 Mar 05 |
nicklas |
43 |
import="net.sf.basedb.clients.web.WebException" |
3518 |
20 Jun 07 |
nicklas |
44 |
import="net.sf.basedb.clients.web.DuplicateWizardException" |
1960 |
10 Feb 06 |
martin |
45 |
import="net.sf.basedb.clients.web.Base" |
368 |
05 Apr 05 |
nicklas |
46 |
import="net.sf.basedb.clients.web.util.HTML" |
2753 |
20 Oct 06 |
nicklas |
47 |
import="net.sf.basedb.util.Values" |
676 |
30 May 05 |
nicklas |
48 |
import="javax.servlet.ServletException" |
2600 |
28 Aug 06 |
nicklas |
49 |
import="java.sql.Driver" |
7534 |
27 Nov 18 |
nicklas |
50 |
import="java.sql.DriverManager" |
2600 |
28 Aug 06 |
nicklas |
51 |
import="java.util.Properties" |
211 |
22 Mar 05 |
nicklas |
52 |
isErrorPage="true" |
211 |
22 Mar 05 |
nicklas |
53 |
%> |
211 |
22 Mar 05 |
nicklas |
54 |
<%@ |
211 |
22 Mar 05 |
nicklas |
55 |
taglib prefix="base" uri="/WEB-INF/base.tld" %> |
211 |
22 Mar 05 |
nicklas |
56 |
<% |
7158 |
25 May 16 |
nicklas |
57 |
SessionControl sc = null; |
7158 |
25 May 16 |
nicklas |
58 |
try |
7158 |
25 May 16 |
nicklas |
59 |
{ |
7158 |
25 May 16 |
nicklas |
60 |
sc = Application.isRunning() ? Base.getSessionControl(pageContext, false) : null; |
7158 |
25 May 16 |
nicklas |
61 |
} |
7158 |
25 May 16 |
nicklas |
62 |
catch (RuntimeException ex) |
7158 |
25 May 16 |
nicklas |
63 |
{} |
1973 |
13 Feb 06 |
nicklas |
64 |
final String reportbuglink = sc == null ? "" : Values.getStringOrNull(sc.getClientDefaultSetting("server.links.reportbug")); |
211 |
22 Mar 05 |
nicklas |
65 |
Throwable ex = exception; |
2384 |
15 Jun 06 |
nicklas |
66 |
|
2384 |
15 Jun 06 |
nicklas |
67 |
if (ex instanceof org.apache.jasper.JasperException) |
2384 |
15 Jun 06 |
nicklas |
68 |
{ |
2384 |
15 Jun 06 |
nicklas |
69 |
org.apache.jasper.JasperException jex = (org.apache.jasper.JasperException)ex; |
6767 |
10 Mar 15 |
nicklas |
70 |
if (jex.getRootCause() != null) ex = jex.getRootCause(); |
2384 |
15 Jun 06 |
nicklas |
71 |
} |
2384 |
15 Jun 06 |
nicklas |
72 |
|
1960 |
10 Feb 06 |
martin |
73 |
if (ex instanceof ServletException) |
676 |
30 May 05 |
nicklas |
74 |
{ |
676 |
30 May 05 |
nicklas |
75 |
ServletException sex = (ServletException)ex; |
676 |
30 May 05 |
nicklas |
76 |
if (sex.getRootCause() != null) ex = sex.getRootCause(); |
676 |
30 May 05 |
nicklas |
77 |
} |
676 |
30 May 05 |
nicklas |
78 |
|
211 |
22 Mar 05 |
nicklas |
79 |
if (ex instanceof WebException) |
211 |
22 Mar 05 |
nicklas |
80 |
{ |
211 |
22 Mar 05 |
nicklas |
81 |
pageContext.forward("/exception/web.jsp"); |
211 |
22 Mar 05 |
nicklas |
82 |
return; |
211 |
22 Mar 05 |
nicklas |
83 |
} |
3518 |
20 Jun 07 |
nicklas |
84 |
else if (ex instanceof DuplicateWizardException) |
3518 |
20 Jun 07 |
nicklas |
85 |
{ |
3518 |
20 Jun 07 |
nicklas |
86 |
pageContext.forward("/exception/duplicate_wizard.jsp"); |
3518 |
20 Jun 07 |
nicklas |
87 |
return; |
3518 |
20 Jun 07 |
nicklas |
88 |
} |
211 |
22 Mar 05 |
nicklas |
89 |
else if (ex instanceof NotLoggedInException) |
211 |
22 Mar 05 |
nicklas |
90 |
{ |
211 |
22 Mar 05 |
nicklas |
91 |
pageContext.forward("/exception/not_logged_in.jsp"); |
211 |
22 Mar 05 |
nicklas |
92 |
return; |
211 |
22 Mar 05 |
nicklas |
93 |
} |
211 |
22 Mar 05 |
nicklas |
94 |
else if (ex instanceof PermissionDeniedException) |
211 |
22 Mar 05 |
nicklas |
95 |
{ |
211 |
22 Mar 05 |
nicklas |
96 |
pageContext.forward("/exception/permission_denied.jsp"); |
211 |
22 Mar 05 |
nicklas |
97 |
return; |
211 |
22 Mar 05 |
nicklas |
98 |
} |
532 |
09 May 05 |
nicklas |
99 |
else if (ex instanceof InvalidDataException) |
532 |
09 May 05 |
nicklas |
100 |
{ |
532 |
09 May 05 |
nicklas |
101 |
pageContext.forward("/exception/invalid_data.jsp"); |
532 |
09 May 05 |
nicklas |
102 |
return; |
532 |
09 May 05 |
nicklas |
103 |
} |
2600 |
28 Aug 06 |
nicklas |
104 |
|
7534 |
27 Nov 18 |
nicklas |
105 |
final String dbUrl = Config.getString("db.url"); |
7534 |
27 Nov 18 |
nicklas |
106 |
String driverName = "unknown"; |
2600 |
28 Aug 06 |
nicklas |
107 |
String driverVersion = ""; |
2600 |
28 Aug 06 |
nicklas |
108 |
try |
2600 |
28 Aug 06 |
nicklas |
109 |
{ |
7534 |
27 Nov 18 |
nicklas |
110 |
final Driver driver = DriverManager.getDriver(dbUrl); |
7534 |
27 Nov 18 |
nicklas |
111 |
driverName = driver.getClass().getName(); |
2600 |
28 Aug 06 |
nicklas |
112 |
driverVersion = "(version " + driver.getMajorVersion() + "." + driver.getMinorVersion() + ")"; |
2600 |
28 Aug 06 |
nicklas |
113 |
} |
2600 |
28 Aug 06 |
nicklas |
114 |
catch (Throwable t) |
7534 |
27 Nov 18 |
nicklas |
115 |
{} |
7534 |
27 Nov 18 |
nicklas |
116 |
|
2600 |
28 Aug 06 |
nicklas |
117 |
final Properties properties = System.getProperties(); |
2600 |
28 Aug 06 |
nicklas |
118 |
final Runtime runtime = Runtime.getRuntime(); |
211 |
22 Mar 05 |
nicklas |
119 |
String exceptionClassName = ex.getClass().getName().replaceAll("net.sf.basedb.core.", ""); |
211 |
22 Mar 05 |
nicklas |
120 |
%> |
415 |
18 Apr 05 |
nicklas |
121 |
<base:page type="default" menu="exception" title="Unexpected error"> |
5940 |
31 Jan 12 |
nicklas |
122 |
<base:head scripts="exception.js" styles="popup.css" /> |
6309 |
21 Aug 13 |
nicklas |
123 |
<base:body data-resize-if-popup="1"> |
5940 |
31 Jan 12 |
nicklas |
124 |
<h1><%=exceptionClassName + " on page "+request.getAttribute("javax.servlet.error.request_uri")%></h1> |
6309 |
21 Aug 13 |
nicklas |
125 |
|
5940 |
31 Jan 12 |
nicklas |
126 |
<div class="content bottomborder" style="bottom: 3em;"> |
5940 |
31 Jan 12 |
nicklas |
127 |
<table class="fullform outlined topborder"> |
2118 |
28 Mar 06 |
nicklas |
128 |
<tr> |
5940 |
31 Jan 12 |
nicklas |
129 |
<th>BASE Version</th> |
5940 |
31 Jan 12 |
nicklas |
130 |
<td><%=Application.getVersionString()%></td> |
2118 |
28 Mar 06 |
nicklas |
131 |
</tr> |
2118 |
28 Mar 06 |
nicklas |
132 |
<tr> |
5940 |
31 Jan 12 |
nicklas |
133 |
<th>Web server</th> |
5940 |
31 Jan 12 |
nicklas |
134 |
<td><%=application.getServerInfo()%></td> |
2118 |
28 Mar 06 |
nicklas |
135 |
</tr> |
2118 |
28 Mar 06 |
nicklas |
136 |
<tr> |
5940 |
31 Jan 12 |
nicklas |
137 |
<th>Database Server</th> |
5940 |
31 Jan 12 |
nicklas |
138 |
<td><%=Application.getDatabaseVersionString()%></td> |
3501 |
15 Jun 07 |
enell |
139 |
</tr> |
3501 |
15 Jun 07 |
enell |
140 |
<tr> |
5940 |
31 Jan 12 |
nicklas |
141 |
<th>Database Dialect</th> |
5940 |
31 Jan 12 |
nicklas |
142 |
<td><%=Config.getString("db.dialect")%></td> |
2118 |
28 Mar 06 |
nicklas |
143 |
</tr> |
2118 |
28 Mar 06 |
nicklas |
144 |
<tr> |
5940 |
31 Jan 12 |
nicklas |
145 |
<th>JDBC Driver</th> |
7534 |
27 Nov 18 |
nicklas |
146 |
<td><%=driverName%> <%=driverVersion%></td> |
2118 |
28 Mar 06 |
nicklas |
147 |
</tr> |
2118 |
28 Mar 06 |
nicklas |
148 |
<tr> |
5940 |
31 Jan 12 |
nicklas |
149 |
<th>Operating system</th> |
5940 |
31 Jan 12 |
nicklas |
150 |
<td><%=properties.getProperty("os.name")%> |
2600 |
28 Aug 06 |
nicklas |
151 |
<%=properties.getProperty("os.arch")%> |
2600 |
28 Aug 06 |
nicklas |
152 |
<%=properties.getProperty("os.version")%> |
2600 |
28 Aug 06 |
nicklas |
153 |
</td> |
2600 |
28 Aug 06 |
nicklas |
154 |
</tr> |
2600 |
28 Aug 06 |
nicklas |
155 |
<tr> |
5940 |
31 Jan 12 |
nicklas |
156 |
<th>Java runtime</th> |
5940 |
31 Jan 12 |
nicklas |
157 |
<td><%=properties.getProperty("java.runtime.name")%> |
5940 |
31 Jan 12 |
nicklas |
158 |
(<%=properties.getProperty("java.runtime.version")%>), |
6139 |
19 Sep 12 |
nicklas |
159 |
<a href="<%=properties.getProperty("java.vendor.url")%>" target="_blank"><%=properties.getProperty("java.vendor")%></a></td> |
5940 |
31 Jan 12 |
nicklas |
160 |
</tr> |
5940 |
31 Jan 12 |
nicklas |
161 |
<tr> |
5940 |
31 Jan 12 |
nicklas |
162 |
<th class="subprompt">Memory</th> |
5940 |
31 Jan 12 |
nicklas |
163 |
<td>Total: <%=Values.formatBytes(runtime.totalMemory())%><br> |
2600 |
28 Aug 06 |
nicklas |
164 |
Free: <%=Values.formatBytes(runtime.freeMemory()) %><br> |
2600 |
28 Aug 06 |
nicklas |
165 |
Max: <%=Values.formatBytes(runtime.maxMemory()) %></td> |
2600 |
28 Aug 06 |
nicklas |
166 |
</tr> |
2600 |
28 Aug 06 |
nicklas |
167 |
<tr> |
5940 |
31 Jan 12 |
nicklas |
168 |
<th>Browser</th> |
5940 |
31 Jan 12 |
nicklas |
169 |
<td><%=HTML.encodeTags(request.getHeader("User-Agent"))%></td> |
2118 |
28 Mar 06 |
nicklas |
170 |
</tr> |
2118 |
28 Mar 06 |
nicklas |
171 |
<tr> |
5940 |
31 Jan 12 |
nicklas |
172 |
<th>Error message</th> |
5940 |
31 Jan 12 |
nicklas |
173 |
<td><%=HTML.formatLineBreaks(HTML.encodeTags(ex.getMessage(), ""))%></td> |
2118 |
28 Mar 06 |
nicklas |
174 |
</tr> |
5940 |
31 Jan 12 |
nicklas |
175 |
<tr class="dynamic"> |
5940 |
31 Jan 12 |
nicklas |
176 |
<th>Stacktrace</th> |
5940 |
31 Jan 12 |
nicklas |
177 |
<td> |
5940 |
31 Jan 12 |
nicklas |
178 |
<% |
5940 |
31 Jan 12 |
nicklas |
179 |
StackTraceElement[] st = ex.getStackTrace(); |
5940 |
31 Jan 12 |
nicklas |
180 |
out.println("<pre>"); |
5940 |
31 Jan 12 |
nicklas |
181 |
out.println(exceptionClassName); |
5940 |
31 Jan 12 |
nicklas |
182 |
int i = 0; |
5940 |
31 Jan 12 |
nicklas |
183 |
for (i=0; i < st.length && i < 8; i++) |
415 |
18 Apr 05 |
nicklas |
184 |
{ |
415 |
18 Apr 05 |
nicklas |
185 |
out.print("...at "); |
5940 |
31 Jan 12 |
nicklas |
186 |
out.println(HTML.encodeTags(st[i].toString().replaceAll("net.sf.basedb.core.", ""))); |
415 |
18 Apr 05 |
nicklas |
187 |
} |
5940 |
31 Jan 12 |
nicklas |
188 |
out.println("</pre>"); |
5940 |
31 Jan 12 |
nicklas |
189 |
if ((i < st.length) || (ex.getCause() != null)) |
415 |
18 Apr 05 |
nicklas |
190 |
{ |
5940 |
31 Jan 12 |
nicklas |
191 |
out.println("<pre id=\"error_detail\" style=\"display:none;\">"); |
5940 |
31 Jan 12 |
nicklas |
192 |
while (ex != null) |
5940 |
31 Jan 12 |
nicklas |
193 |
{ |
5940 |
31 Jan 12 |
nicklas |
194 |
for (int j=i; j < st.length; j++) |
5940 |
31 Jan 12 |
nicklas |
195 |
{ |
5940 |
31 Jan 12 |
nicklas |
196 |
out.print("...at "); |
5940 |
31 Jan 12 |
nicklas |
197 |
out.println(HTML.encodeTags(st[j].toString().replaceAll("net.sf.basedb.core.", ""))); |
5940 |
31 Jan 12 |
nicklas |
198 |
} |
5940 |
31 Jan 12 |
nicklas |
199 |
ex = ex.getCause(); |
5940 |
31 Jan 12 |
nicklas |
200 |
if (ex != null) |
5940 |
31 Jan 12 |
nicklas |
201 |
{ |
5940 |
31 Jan 12 |
nicklas |
202 |
st = ex.getStackTrace(); |
5940 |
31 Jan 12 |
nicklas |
203 |
i = 0; |
5940 |
31 Jan 12 |
nicklas |
204 |
out.print("\nCaused by: "+ex.getClass().getName()+": " + ex.getMessage() + "\n"); |
5940 |
31 Jan 12 |
nicklas |
205 |
} |
5940 |
31 Jan 12 |
nicklas |
206 |
} |
5940 |
31 Jan 12 |
nicklas |
207 |
out.println("</pre>"); |
415 |
18 Apr 05 |
nicklas |
208 |
} |
5940 |
31 Jan 12 |
nicklas |
209 |
%> |
6309 |
21 Aug 13 |
nicklas |
210 |
<base:icon |
6309 |
21 Aug 13 |
nicklas |
211 |
id="showMoreDetails" |
6309 |
21 Aug 13 |
nicklas |
212 |
data-show-id="error_detail" |
6309 |
21 Aug 13 |
nicklas |
213 |
image="gonext.png"><%=st.length-i%> more...</base:icon> |
5940 |
31 Jan 12 |
nicklas |
214 |
</td> |
5940 |
31 Jan 12 |
nicklas |
215 |
</table> |
5940 |
31 Jan 12 |
nicklas |
216 |
</div> |
5940 |
31 Jan 12 |
nicklas |
217 |
|
5940 |
31 Jan 12 |
nicklas |
218 |
<base:buttongroup subclass="dialogbuttons"> |
6309 |
21 Aug 13 |
nicklas |
219 |
<base:button id="goback" title="Back"/> |
6309 |
21 Aug 13 |
nicklas |
220 |
<base:button id="close" title="Close"/> |
6309 |
21 Aug 13 |
nicklas |
221 |
<base:button id="reportbug" title="Report bug…" image="bug.png" |
6309 |
21 Aug 13 |
nicklas |
222 |
data-report-link="<%=HTML.encodeTags(reportbuglink) %>" |
6309 |
21 Aug 13 |
nicklas |
223 |
visible="<%=HTML.isValidUrl(reportbuglink)%>"/> |
1960 |
10 Feb 06 |
martin |
224 |
</base:buttongroup> |
522 |
04 May 05 |
nicklas |
225 |
|
415 |
18 Apr 05 |
nicklas |
226 |
</base:body> |
211 |
22 Mar 05 |
nicklas |
227 |
</base:page> |
211 |
22 Mar 05 |
nicklas |
228 |
|