source: trunk/www/exception/exception.jsp @ 7534

Last change on this file since 7534 was 7534, checked in by Nicklas Nordborg, 3 years ago

References #2130: Upgrade 3-rd party libraries

The change made in [7521] removed the db.driver setting. It was still used in two JSP pages. They have now been updated to use the DriverManager with the db.url setting instead.

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