Exception Fact Sheet for "Struts"

The goal of an Exception Fact Sheet is to reveal the design of exception handling in an application.

--Maxence, Martin

For feedback, please contact Martin

Table of contents

Basic Statistics

Number of Classes 362
Number of Domain Exception Types (Thrown or Caught) 1
Number of Domain Checked Exception Types 0
Number of Domain Runtime Exception Types 0
Number of Domain Unknown Exception Types 1
nTh = Number of Throw 199
nTh = Number of Throw in Catch 37
Number of Catch-Rethrow (may not be correct) 5
nC = Number of Catch 140
nCTh = Number of Catch with Throw 37
Number of Empty Catch (really Empty) 1
Number of Empty Catch (with comments) 7
Number of Empty Catch 8
nM = Number of Methods 2084
nbFunctionWithCatch = Number of Methods with Catch 93 / 2084
nbFunctionWithThrow = Number of Methods with Throw 171 / 2084
nbFunctionWithThrowS = Number of Methods with ThrowS 246 / 2084
nbFunctionTransmitting = Number of Methods with "Throws" but NO catch, NO throw (only transmitting) 155 / 2084
P1 = nCTh / nC 26.4% (0.264)
P2 = nMC / nM 4.5% (0.045)
P3 = nbFunctionWithThrow / nbFunction 8.2% (0.082)
P4 = nbFunctionTransmitting / nbFunction 7.4% (0.074)
P5 = nbThrowInCatch / nbThrow 18.6% (0.186)
R2 = nCatch / nThrow 0.704
A1 = Number of Caught Exception Types From External Libraries 25
A2 = Number of Reused Exception Types From External Libraries (thrown from application code) 13

W1 is a rough estimation of the richness of the exception model. It does not take into account the inheritance relationships between domain exceptions.

Proportion P1 measures the overall exception flow. According to our experience, it varies from 5% to 70%. Early-catch design generally yields a low P1, libraries that must warn clients about errors (e.g. databases) generally have a high P1.

Proportion P2 measures the dispersion of catch blocks in the application. According to our experience, it varies from 2% to 15%. A small P2 indicates a rather centralized management of errors.

R1 shows how many exceptions types from libraries (incl. JDK) are thrown from application code. For instance, IllegalArgumentException comes from the JDK but is used in many applications.

A1 measures the awareness of the application to library exceptions. A high value of A1 means either that the application is polluted with checked exceptions or that it is able to apply specific recovery depending on the library exception.

Exception Hierachy

Exception Map

Each exception that is used at least once in the project is a dot. A orange dot represents a domain exception that is defined in the application. A blue dot exception is defined in the JDK or in a library. The x-axis represents the number of times an exception is caught, the y-axis the number of times an exception is thrown.

Exceptions With State

State means fields. Number of exceptions with state: 0

Thrown Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be thrown, thrown from within a catch, or declared in the signature of a method (usually for checked exceptions). Hovering over a number triggers showing code snippets from the application code.

Type Exception Thrown Thrown
from Catch
Declared
- Unknown 77
              
//in java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java
throw bp.getException();

              
//in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
throw e;

              
//in java/org/apache/struts2/config/DelegatingSettings.java
throw e;

              
//in java/org/apache/struts2/config/DelegatingSettings.java
throw e;

              
//in java/org/apache/struts2/config/DelegatingSettings.java
throw (e == null) ? new UnsupportedOperationException() : e;

              
//in java/org/apache/struts2/components/template/VelocityTemplateEngine.java
throw exception;

              
//in java/org/apache/struts2/components/template/JspTemplateEngine.java
throw exception;

              
//in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
throw exception;

              
//in java/org/apache/struts2/components/Component.java
throw fieldError(field, errorMsg, null);

              
//in java/org/apache/struts2/components/Component.java
throw fieldError(field, errorMsg, null);

              
//in java/org/apache/struts2/components/Component.java
throw fieldError(field, errorMsg, problem);

              
//in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
throw throwable;

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/ProxyAttrAdapter.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/ProxyAttrAdapter.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleTextNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleTextNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleTextNode.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/XSLTResult.java
throw e;

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
throw operationNotSupported();

              
//in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
throw operationNotSupported();

              
//in java/org/apache/struts2/dispatcher/VelocityResult.java
throw e;

              
//in java/org/apache/struts2/util/FastByteArrayOutputStream.java
throw e;

              
//in java/org/apache/struts2/util/StrutsUtil.java
throw e;

            
- -
- Builder 66
              
// in java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java
throw bp.getException();

              
// in java/org/apache/struts2/config/DelegatingSettings.java
throw (e == null) ? new UnsupportedOperationException() : e;

              
// in java/org/apache/struts2/components/Component.java
throw fieldError(field, errorMsg, null);

              
// in java/org/apache/struts2/components/Component.java
throw fieldError(field, errorMsg, null);

              
// in java/org/apache/struts2/components/Component.java
throw fieldError(field, errorMsg, problem);

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/ProxyAttrAdapter.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/ProxyAttrAdapter.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/AbstractAdapterElement.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
throw operationNotSupported();

              
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
throw operationNotSupported();

            
- -
- Variable 12
              
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
throw e;

              
// in java/org/apache/struts2/config/DelegatingSettings.java
throw e;

              
// in java/org/apache/struts2/config/DelegatingSettings.java
throw e;

              
// in java/org/apache/struts2/config/DelegatingSettings.java
throw (e == null) ? new UnsupportedOperationException() : e;

              
// in java/org/apache/struts2/components/template/VelocityTemplateEngine.java
throw exception;

              
// in java/org/apache/struts2/components/template/JspTemplateEngine.java
throw exception;

              
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
throw exception;

              
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
throw throwable;

              
// in java/org/apache/struts2/views/xslt/XSLTResult.java
throw e;

              
// in java/org/apache/struts2/dispatcher/VelocityResult.java
throw e;

              
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
throw e;

              
// in java/org/apache/struts2/util/StrutsUtil.java
throw e;

            
- -
(Lib) UnsupportedOperationException 32
              
// in java/org/apache/struts2/config/Settings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { throw new UnsupportedOperationException("Settings: This implementation does not support setting a value."); }
// in java/org/apache/struts2/config/Settings.java
public Iterator listImpl() { throw new UnsupportedOperationException("Settings: This implementation does not support listing the registered settings"); }
// in java/org/apache/struts2/components/IteratorComponent.java
public void remove() { throw new UnsupportedOperationException("Values cannot be removed from this iterator"); }
// in java/org/apache/struts2/views/xslt/ProxyAttrAdapter.java
public void setValue(String string) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyNamedNodeMap.java
public Node removeNamedItem(String name) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyNamedNodeMap.java
public Node setNamedItem(Node arg) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyNamedNodeMap.java
public Node setNamedItemNS(Node arg) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyNamedNodeMap.java
public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public Text splitText(int offset) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public void deleteData(int offset, int count) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public void replaceData(int offset, int count, String arg) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public void insertData(int offset, String arg) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public void appendData(String arg) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public void setData(String data) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public void removeAttribute(String name) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public void removeAttributeNS(String namespaceURI, String localName) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public void setAttribute(String name, String value) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public Attr removeAttributeNode(Attr oldAttr) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public Attr setAttributeNode(Attr newAttr) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public Attr setAttributeNodeNS(Attr newAttr) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/util/IteratorGenerator.java
public void remove() { throw new UnsupportedOperationException("Remove is not supported in IteratorGenerator."); }
// in java/org/apache/struts2/util/AppendIteratorFilter.java
public void remove() { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/util/SortIteratorFilter.java
public void remove() { throw new UnsupportedOperationException("Remove is not supported in SortIteratorFilter."); }
// in java/org/apache/struts2/util/IteratorFilterSupport.java
public void remove() { throw new UnsupportedOperationException("Remove is not supported in IteratorFilterSupport."); }
// in java/org/apache/struts2/util/MergeIteratorFilter.java
public void remove() { throw new UnsupportedOperationException("Remove is not supported in MergeIteratorFilter."); }
// in java/org/apache/struts2/util/AttributeMap.java
public boolean isEmpty() { throw new UnsupportedOperationException(UNSUPPORTED); }
// in java/org/apache/struts2/util/AttributeMap.java
public void clear() { throw new UnsupportedOperationException(UNSUPPORTED); }
// in java/org/apache/struts2/util/AttributeMap.java
public boolean containsValue(Object value) { throw new UnsupportedOperationException(UNSUPPORTED); }
// in java/org/apache/struts2/util/AttributeMap.java
public void putAll(Map t) { throw new UnsupportedOperationException(UNSUPPORTED); }
// in java/org/apache/struts2/util/AttributeMap.java
public Object remove(Object key) { throw new UnsupportedOperationException(UNSUPPORTED); }
// in java/org/apache/struts2/util/AttributeMap.java
public int size() { throw new UnsupportedOperationException(UNSUPPORTED); }
0 4
              
// in java/org/apache/struts2/config/DefaultSettings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { delegate.setImpl(name, value); }
// in java/org/apache/struts2/config/Settings.java
public static void set(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { getInstance().setImpl(name, value); }
// in java/org/apache/struts2/config/Settings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { throw new UnsupportedOperationException("Settings: This implementation does not support setting a value."); }
// in java/org/apache/struts2/config/DelegatingSettings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { IllegalArgumentException e = null; for (Settings delegate : delegates) { try { delegate.getImpl(name); // Throws exception if not found delegate.setImpl(name, value); // Found it return; // Done } catch (IllegalArgumentException ex) { e = ex; // Try next delegate } } throw e; }
(Domain) StrutsException 30
              
// in java/org/apache/struts2/interceptor/ScopeInterceptor.java
static final void lock(Object o, ActionInvocation invocation) throws Exception { synchronized (o) { int count = 3; Object previous = null; while ((previous = locks.get(o)) != null) { if (previous == invocation) { return; } if (count-- <= 0) { locks.remove(o); o.notify(); throw new StrutsException("Deadlock in session lock"); } o.wait(10000); } ; locks.put(o, invocation); } }
// in java/org/apache/struts2/components/I18n.java
public boolean end(Writer writer, String body) throws StrutsException { if (pushed) { Object o = getStack().pop(); if ((o == null) || (!o.equals(textProvider))) { LOG.error("A closing i18n tag attempted to pop its own TextProvider from the top of the ValueStack but popped an unexpected object ("+(o != null ? o.getClass() : "null")+"). " + "Refactor the page within the i18n tags to ensure no objects are pushed onto the ValueStack without popping them prior to the closing tag. " + "If you see this message it's likely that the i18n's TextProvider is still on the stack and will continue to provide message resources after the closing tag."); throw new StrutsException("A closing i18n tag attempted to pop its TextProvider from the top of the ValueStack but popped an unexpected object ("+(o != null ? o.getClass() : "null")+")"); } } return super.end(writer, body); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
public void renderUrl(Writer writer, UrlProvider urlComponent) { String scheme = urlComponent.getHttpServletRequest().getScheme(); if (urlComponent.getScheme() != null) { scheme = urlComponent.getScheme(); } String result; ActionInvocation ai = (ActionInvocation) ActionContext.getContext().get(ActionContext.ACTION_INVOCATION); if (urlComponent.getValue() == null && urlComponent.getAction() != null) { result = urlComponent.determineActionURL(urlComponent.getAction(), urlComponent.getNamespace(), urlComponent.getMethod(), urlComponent.getHttpServletRequest(), urlComponent.getHttpServletResponse(), urlComponent.getParameters(), scheme, urlComponent.isIncludeContext(), urlComponent.isEncode(), urlComponent.isForceAddSchemeHostAndPort(), urlComponent.isEscapeAmp()); } else if (urlComponent.getValue() == null && urlComponent.getAction() == null && ai != null) { // both are null, we will default to the current action final String action = ai.getProxy().getActionName(); final String namespace = ai.getProxy().getNamespace(); final String method = urlComponent.getMethod() != null || !ai.getProxy().isMethodSpecified() ? urlComponent.getMethod() : ai.getProxy().getMethod(); result = urlComponent.determineActionURL(action, namespace, method, urlComponent.getHttpServletRequest(), urlComponent.getHttpServletResponse(), urlComponent.getParameters(), scheme, urlComponent.isIncludeContext(), urlComponent.isEncode(), urlComponent.isForceAddSchemeHostAndPort(), urlComponent.isEscapeAmp()); } else { String _value = urlComponent.getValue(); // We don't include the request parameters cause they would have been // prioritised before this [in start(Writer) method] if (_value != null && _value.indexOf("?") > 0) { _value = _value.substring(0, _value.indexOf("?")); } result = urlHelper.buildUrl(_value, urlComponent.getHttpServletRequest(), urlComponent.getHttpServletResponse(), urlComponent.getParameters(), scheme, urlComponent.isIncludeContext(), urlComponent.isEncode(), urlComponent.isForceAddSchemeHostAndPort(), urlComponent.isEscapeAmp()); } String anchor = urlComponent.getAnchor(); if (StringUtils.isNotEmpty(anchor)) { result += '#' + urlComponent.findString(anchor); } if (urlComponent.isPutInContext()) { String var = urlComponent.getVar(); if (StringUtils.isNotEmpty(var)) { urlComponent.putInContext(result); // add to the request and page scopes as well urlComponent.getHttpServletRequest().setAttribute(var, result); } else { try { writer.write(result); } catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); } } } else { try { writer.write(result); } catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); } } }
// in java/org/apache/struts2/components/Component.java
protected boolean end(Writer writer, String body, boolean popComponentStack) { assert(body != null); try { writer.write(body); } catch (IOException e) { throw new StrutsException("IOError while writing the body: " + e.getMessage(), e); } if (popComponentStack) { popComponentStack(); } return false; }
// in java/org/apache/struts2/components/Component.java
protected StrutsException fieldError(String field, String errorMsg, Exception e) { String msg = "tag '" + getComponentName() + "', field '" + field + ( parameters != null && parameters.containsKey("name")?"', name '" + parameters.get("name"):"") + "': " + errorMsg; throw new StrutsException(msg, e); }
// in java/org/apache/struts2/components/Debug.java
public boolean start(Writer writer) { boolean result = super.start(writer); ValueStack stack = getStack(); Iterator iter = stack.getRoot().iterator(); List stackValues = new ArrayList(stack.getRoot().size()); while (iter.hasNext()) { Object o = iter.next(); Map values; try { values = reflectionProvider.getBeanMap(o); } catch (Exception e) { throw new StrutsException("Caught an exception while getting the property values of " + o, e); } stackValues.add(new DebugMapEntry(o.getClass().getName(), values)); } addParameter("stackValues", stackValues); return result; }
// in java/org/apache/struts2/components/ActionComponent.java
protected void executeAction() { String actualName = findString(name, "name", "Action name is required. Example: updatePerson"); if (actualName == null) { throw new StrutsException("Unable to find value for name " + name); } // handle "name!method" convention. final String actionName; final String methodName; ActionMapping mapping = actionMapper.getMappingFromActionName(actualName); actionName = mapping.getName(); methodName = mapping.getMethod(); String namespace; if (this.namespace == null) { namespace = TagUtils.buildNamespace(actionMapper, getStack(), req); } else { namespace = findString(this.namespace); } // get the old value stack from the request ValueStack stack = getStack(); // execute at this point, after params have been set ActionInvocation inv = ActionContext.getContext().getActionInvocation(); try { proxy = actionProxyFactory.createActionProxy(namespace, actionName, methodName, createExtraContext(), executeResult, true); // set the new stack into the request for the taglib to use req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack()); req.setAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION, Boolean.TRUE); proxy.execute(); } catch (Exception e) { String message = "Could not execute action: " + namespace + "/" + actualName; LOG.error(message, e); if (rethrowException) { throw new StrutsException(message, e); } } finally { req.removeAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION); // set the old stack back on the request req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); if (inv != null) { ActionContext.getContext().setActionInvocation(inv); } } if ((getVar() != null) && (proxy != null)) { putInContext(proxy.getAction()); } }
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
public Node getChildBeforeOrAfter(Node child, boolean before) { log.debug("getChildBeforeOrAfter: "); List adapters = getChildAdapters(); if (log.isDebugEnabled()) { log.debug("childAdapters = " + adapters); log.debug("child = " + child); } int index = adapters.indexOf(child); if (index < 0) throw new StrutsException(child + " is no child of " + this); int siblingIndex = before ? index - 1 : index + 1; return ((0 < siblingIndex) && (siblingIndex < adapters.size())) ? ((Node) adapters.get(siblingIndex)) : null; }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public void setData(String string) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public void appendData(String string) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public void deleteData(int i, int i1) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public void insertData(int i, String string) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public void replaceData(int i, int i1, String string) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public Text splitText(int i) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void error(TransformerException exception) throws TransformerException { throw new StrutsException("Error transforming result", exception); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void fatalError(TransformerException exception) throws TransformerException { throw new StrutsException("Fatal error transforming result", exception); }
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
private synchronized PropertyDescriptor[] getPropertyDescriptors(Object bean) { try { if (propertyDescriptorCache == null) { propertyDescriptorCache = new HashMap<Class, PropertyDescriptor[]>(); } PropertyDescriptor[] props = propertyDescriptorCache.get(bean.getClass()); if (props == null) { log.debug("Caching property descriptor for " + bean.getClass().getName()); props = Introspector.getBeanInfo(bean.getClass(), Object.class).getPropertyDescriptors(); propertyDescriptorCache.put(bean.getClass(), props); } return props; } catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); } }
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
private Element getRootElement() { if (rootElement != null) return rootElement; Node node = getAdapterFactory().adaptNode( this, getPropertyName(), getPropertyValue()); if (node instanceof Element) rootElement = (Element) node; else throw new StrutsException( "Document adapter expected to wrap an Element type. Node is not an element:" + node); return rootElement; }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
private Node constructAdapterInstance(Class adapterClass, AdapterNode parent, String propertyName, Object propertyValue) { // Check to see if the class has a no-args constructor try { adapterClass.getConstructor(new Class []{}); } catch (NoSuchMethodException e1) { throw new StrutsException("Adapter class: " + adapterClass + " does not have a no-args consructor."); } try { AdapterNode adapterNode = (AdapterNode) adapterClass.newInstance(); adapterNode.setAdapterFactory(this); adapterNode.setParent(parent); adapterNode.setPropertyName(propertyName); adapterNode.setPropertyValue(propertyValue); return adapterNode; } catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); } catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
protected VelocityEngine newVelocityEngine(ServletContext context) { if (context == null) { String gripe = "Error attempting to create a new VelocityEngine from a null ServletContext!"; LOG.error(gripe); throw new IllegalArgumentException(gripe); } Properties p = loadConfiguration(context); VelocityEngine velocityEngine = new VelocityEngine(); // Set the velocity attribute for the servlet context // if this is not set the webapp loader WILL NOT WORK velocityEngine.setApplicationAttribute(ServletContext.class.getName(), context); try { velocityEngine.init(p); } catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); } return velocityEngine; }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void init() { if (configurationManager == null) { configurationManager = createConfigurationManager(BeanSelectionProvider.DEFAULT_BEAN_NAME); } try { init_DefaultProperties(); // [1] init_TraditionalXmlConfigurations(); // [2] init_LegacyStrutsProperties(); // [3] init_CustomConfigurationProviders(); // [5] init_FilterInitParameters() ; // [6] init_AliasStandardObjects() ; // [7] Container container = init_PreloadConfiguration(); container.inject(this); init_CheckConfigurationReloading(container); init_CheckWebLogicWorkaround(container); if (!dispatcherListeners.isEmpty()) { for (DispatcherListener l : dispatcherListeners) { l.dispatcherInitialized(this); } } } catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
public void cleanupDispatcher() { if (dispatcher == null) { throw new StrutsException("Something is seriously wrong, Dispatcher is not initialized (null) "); } else { try { dispatcher.cleanup(); } finally { ActionContext.setContext(null); } } }
14
              
// in java/org/apache/struts2/config/PropertiesSettings.java
catch (IOException e) { throw new StrutsException("Could not load " + name + ".properties:" + e, e); }
// in java/org/apache/struts2/components/I18n.java
catch (Exception e) { String msg = "Could not find the bundle " + name; throw new StrutsException(msg, e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Component.java
catch (IOException e) { throw new StrutsException("IOError while writing the body: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Debug.java
catch (Exception e) { throw new StrutsException("Caught an exception while getting the property values of " + o, e); }
// in java/org/apache/struts2/components/UIBean.java
catch (Exception e) { throw new StrutsException(e); }
// in java/org/apache/struts2/components/ActionComponent.java
catch (Exception e) { String message = "Could not execute action: " + namespace + "/" + actualName; LOG.error(message, e); if (rethrowException) { throw new StrutsException(message, e); } }
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (NoSuchMethodException e1) { throw new StrutsException("Adapter class: " + adapterClass + " does not have a no-args consructor."); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); }
1
              
// in java/org/apache/struts2/components/I18n.java
public boolean end(Writer writer, String body) throws StrutsException { if (pushed) { Object o = getStack().pop(); if ((o == null) || (!o.equals(textProvider))) { LOG.error("A closing i18n tag attempted to pop its own TextProvider from the top of the ValueStack but popped an unexpected object ("+(o != null ? o.getClass() : "null")+"). " + "Refactor the page within the i18n tags to ensure no objects are pushed onto the ValueStack without popping them prior to the closing tag. " + "If you see this message it's likely that the i18n's TextProvider is still on the stack and will continue to provide message resources after the closing tag."); throw new StrutsException("A closing i18n tag attempted to pop its TextProvider from the top of the ValueStack but popped an unexpected object ("+(o != null ? o.getClass() : "null")+")"); } } return super.end(writer, body); }
(Lib) ConfigurationException 14
              
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { Settings defaultSettings = null; try { defaultSettings = new PropertiesSettings("org/apache/struts2/default"); } catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); } loadSettings(props, defaultSettings); }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
void alias(Class type, String key, ContainerBuilder builder, Properties props, Scope scope) { if (!builder.contains(type)) { String foundName = props.getProperty(key, DEFAULT_BEAN_NAME); if (builder.contains(type, foundName)) { if (LOG.isInfoEnabled()) { LOG.info("Choosing bean (#0) for (#1)", foundName, type.getName()); } builder.alias(type, foundName, Container.DEFAULT_NAME); } else { try { Class cls = ClassLoaderUtil.loadClass(foundName, this.getClass()); if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1)", cls.getName(), type.getName()); } builder.factory(type, cls, scope); } catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } } } } else { if (LOG.isWarnEnabled()) { LOG.warn("Unable to alias bean type (#0), default mapping already assigned.", type.getName()); } } }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
public Object create(Context context) throws Exception { ObjectFactory objFactory = context.getContainer().getInstance(ObjectFactory.class); try { return objFactory.buildBean(name, null, true); } catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); } }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map refParams) throws ConfigurationException { String className = interceptorConfig.getClassName(); Map<String, String> params = new HashMap<String, String>(); Map typeParams = interceptorConfig.getParams(); if (typeParams != null && !typeParams.isEmpty()) params.putAll(typeParams); if (refParams != null && !refParams.isEmpty()) params.putAll(refParams); try { // interceptor instances are long-lived and used across user sessions, so don't try to pass in any extra // context Object o = buildBean(className, null); reflectionProvider.setProperties(params, o); if (o instanceof Interceptor) { Interceptor interceptor = (Interceptor) o; interceptor.init(); return interceptor; } // This is for the new API: // if (o instanceof org.apache.struts2.spi.Interceptor) // return new InterceptorAdapter((org.apache.struts2.spi.Interceptor) o); throw new ConfigurationException( "Class [" + className + "] does not implement Interceptor", interceptorConfig); } catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); } catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); } catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); } catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); } }
// in java/org/apache/struts2/components/template/TemplateEngineManager.java
public TemplateEngine create() { TemplateEngine engine = container.getInstance(TemplateEngine.class, name); if (engine == null) { throw new ConfigurationException("Unable to locate template engine: "+name); } return engine; }
// in java/org/apache/struts2/components/UIBean.java
protected void mergeTemplate(Writer writer, Template template) throws Exception { final TemplateEngine engine = templateEngineManager.getTemplateEngine(template, templateSuffix); if (engine == null) { throw new ConfigurationException("Unable to find a TemplateEngine for template " + template); } if (LOG.isDebugEnabled()) { LOG.debug("Rendering template " + template); } final TemplateRenderingContext context = new TemplateRenderingContext(template, writer, getStack(), getParameters(), this); engine.renderTemplate(context); }
// in java/org/apache/struts2/views/jsp/TagUtils.java
public static ValueStack getStack(PageContext pageContext) { HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); ValueStack stack = (ValueStack) req.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY); if (stack == null) { HttpServletResponse res = (HttpServletResponse) pageContext.getResponse(); Dispatcher du = Dispatcher.getInstance(); if (du == null) { throw new ConfigurationException("The Struts dispatcher cannot be found. This is usually caused by "+ "using Struts tags without the associated filter. Struts tags are only usable when the request "+ "has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag."); } stack = du.getContainer().getInstance(ValueStackFactory.class).createValueStack(); Map<String, Object> extraContext = du.createContextMap(new RequestMap(req), req.getParameterMap(), new SessionMap(req), new ApplicationMap(pageContext.getServletContext()), req, res, pageContext.getServletContext()); extraContext.put(ServletActionContext.PAGE_CONTEXT, pageContext); stack.getContext().putAll(extraContext); req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); // also tie this stack/context to the ThreadLocal ActionContext.setContext(new ActionContext(stack.getContext())); } else { // let's make sure that the current page context is in the action context Map<String, Object> context = stack.getContext(); context.put(ServletActionContext.PAGE_CONTEXT, pageContext); AttributeMap attrMap = new AttributeMap(context); context.put("attr", attrMap); } return stack; }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
private void init_CustomConfigurationProviders() { String configProvs = initParams.get("configProviders"); if (configProvs != null) { String[] classes = configProvs.split("\\s*[,]\\s*"); for (String cname : classes) { try { Class cls = ClassLoaderUtil.loadClass(cname, this.getClass()); ConfigurationProvider prov = (ConfigurationProvider)cls.newInstance(); configurationManager.addContainerProvider(prov); } catch (InstantiationException e) { throw new ConfigurationException("Unable to instantiate provider: "+cname, e); } catch (IllegalAccessException e) { throw new ConfigurationException("Unable to access provider: "+cname, e); } catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to locate provider class: "+cname, e); } } } }
10
              
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (InstantiationException e) { throw new ConfigurationException("Unable to instantiate provider: "+cname, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IllegalAccessException e) { throw new ConfigurationException("Unable to access provider: "+cname, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to locate provider class: "+cname, e); }
12
              
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
public void init(Configuration configuration) throws ConfigurationException { }
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { Settings defaultSettings = null; try { defaultSettings = new PropertiesSettings("org/apache/struts2/default"); } catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); } loadSettings(props, defaultSettings); }
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
Override public void register(ContainerBuilder containerBuilder, LocatableProperties props) throws ConfigurationException { if (servletContext != null && !containerBuilder.contains(ServletContext.class)) { containerBuilder.factory(ServletContext.class, new Factory<ServletContext>() { public ServletContext create(Context context) throws Exception { return servletContext; } }); }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
public void loadPackages() throws ConfigurationException { // NO-OP }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
public void init(Configuration configuration) throws ConfigurationException { // NO-OP }
// in java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java
public void init(Configuration configuration) throws ConfigurationException { Settings.reset(); }
// in java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java
public void loadPackages() throws ConfigurationException { }
// in java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { final Settings settings = Settings.getInstance(); loadSettings(props, settings); // Set default locale by lazily resolving the locale property as needed into a Locale object builder.factory(Locale.class, new Factory() { private Locale locale; public synchronized Object create(Context context) throws Exception { if (locale == null) { String loc = context.getContainer().getInstance(String.class, StrutsConstants.STRUTS_LOCALE); if (loc != null) { StringTokenizer localeTokens = new StringTokenizer(loc, "_"); String lang = null; String country = null; if (localeTokens.hasMoreTokens()) { lang = localeTokens.nextToken(); } if (localeTokens.hasMoreTokens()) { country = localeTokens.nextToken(); } locale = new Locale(lang, country); } else { if (LOG.isInfoEnabled()) { LOG.info("No locale define, substituting the default VM locale"); } locale = Locale.getDefault(); } } return locale; } }); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map refParams) throws ConfigurationException { String className = interceptorConfig.getClassName(); Map<String, String> params = new HashMap<String, String>(); Map typeParams = interceptorConfig.getParams(); if (typeParams != null && !typeParams.isEmpty()) params.putAll(typeParams); if (refParams != null && !refParams.isEmpty()) params.putAll(refParams); try { // interceptor instances are long-lived and used across user sessions, so don't try to pass in any extra // context Object o = buildBean(className, null); reflectionProvider.setProperties(params, o); if (o instanceof Interceptor) { Interceptor interceptor = (Interceptor) o; interceptor.init(); return interceptor; } // This is for the new API: // if (o instanceof org.apache.struts2.spi.Interceptor) // return new InterceptorAdapter((org.apache.struts2.spi.Interceptor) o); throw new ConfigurationException( "Class [" + className + "] does not implement Interceptor", interceptorConfig); } catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); } catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); } catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); } catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); } }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
private void init_FilterInitParameters() { configurationManager.addContainerProvider(new ConfigurationProvider() { public void destroy() { } public void init(Configuration configuration) throws ConfigurationException { } public void loadPackages() throws ConfigurationException { } public boolean needsReload() { return false; } public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { props.putAll(initParams); } }); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void init(Configuration configuration) throws ConfigurationException { }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void loadPackages() throws ConfigurationException { }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { props.putAll(initParams); }
(Lib) IllegalArgumentException 14
              
// in java/org/apache/struts2/interceptor/ScopeInterceptor.java
public void setType(String type) { type = type.toLowerCase(); if ("start".equals(type) || "end".equals(type)) { this.type = type; } else { throw new IllegalArgumentException("Only start or end are allowed arguments for type"); } }
// in java/org/apache/struts2/config/PropertiesSettings.java
public String getImpl(String aName) throws IllegalArgumentException { String setting = settings.getProperty(aName); if (setting == null) { throw new IllegalArgumentException("No such setting:" + aName); } return setting; }
// in java/org/apache/struts2/config/PropertiesSettings.java
public Location getLocationImpl(String aName) throws IllegalArgumentException { Location loc = settings.getPropertyLocation(aName); if (loc == null) { if (!settings.containsKey(aName)) { throw new IllegalArgumentException("No such setting:" + aName); } } return loc; }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
public Properties loadConfiguration(ServletContext context) { if (context == null) { String gripe = "Error attempting to create a loadConfiguration from a null ServletContext!"; LOG.error(gripe); throw new IllegalArgumentException(gripe); } Properties properties = new Properties(); // now apply our systemic defaults, then allow user to override applyDefaultConfiguration(context, properties); String defaultUserDirective = properties.getProperty("userdirective"); /** * if the user has specified an external velocity configuration file, we'll want to search for it in the * following order * * 1. relative to the context path * 2. relative to /WEB-INF * 3. in the class path */ String configfile; if (customConfigFile != null) { configfile = customConfigFile; } else { configfile = "velocity.properties"; } configfile = configfile.trim(); InputStream in = null; String resourceLocation = null; try { if (context.getRealPath(configfile) != null) { // 1. relative to context path, i.e. /velocity.properties String filename = context.getRealPath(configfile); if (filename != null) { File file = new File(filename); if (file.isFile()) { resourceLocation = file.getCanonicalPath() + " from file system"; in = new FileInputStream(file); } // 2. if nothing was found relative to the context path, search relative to the WEB-INF directory if (in == null) { file = new File(context.getRealPath("/WEB-INF/" + configfile)); if (file.isFile()) { resourceLocation = file.getCanonicalPath() + " from file system"; in = new FileInputStream(file); } } } } // 3. finally, if there's no physical file, how about something in our classpath if (in == null) { in = VelocityManager.class.getClassLoader().getResourceAsStream(configfile); if (in != null) { resourceLocation = configfile + " from classloader"; } } // if we've got something, load 'er up if (in != null) { if (LOG.isInfoEnabled()) { LOG.info("Initializing velocity using " + resourceLocation); } properties.load(in); } } catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to load velocity configuration " + resourceLocation, e); } } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } } // overide with programmatically set properties if (this.velocityProperties != null) { Iterator keys = this.velocityProperties.keySet().iterator(); while (keys.hasNext()) { String key = (String) keys.next(); properties.setProperty(key, this.velocityProperties.getProperty(key)); } } String userdirective = properties.getProperty("userdirective"); if ((userdirective == null) || userdirective.trim().equals("")) { userdirective = defaultUserDirective; } else { userdirective = userdirective.trim() + "," + defaultUserDirective; } properties.setProperty("userdirective", userdirective); // for debugging purposes, allows users to dump out the properties that have been configured if (LOG.isDebugEnabled()) { LOG.debug("Initializing Velocity with the following properties ..."); for (Iterator iter = properties.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); String value = properties.getProperty(key); if (LOG.isDebugEnabled()) { LOG.debug(" '" + key + "' = '" + value + "'"); } } } return properties; }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
protected VelocityEngine newVelocityEngine(ServletContext context) { if (context == null) { String gripe = "Error attempting to create a new VelocityEngine from a null ServletContext!"; LOG.error(gripe); throw new IllegalArgumentException(gripe); } Properties p = loadConfiguration(context); VelocityEngine velocityEngine = new VelocityEngine(); // Set the velocity attribute for the servlet context // if this is not set the webapp loader WILL NOT WORK velocityEngine.setApplicationAttribute(ServletContext.class.getName(), context); try { velocityEngine.init(p); } catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); } return velocityEngine; }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
private void init_TraditionalXmlConfigurations() { String configPaths = initParams.get("config"); if (configPaths == null) { configPaths = DEFAULT_CONFIGURATION_PATHS; } String[] files = configPaths.split("\\s*[,]\\s*"); for (String file : files) { if (file.endsWith(".xml")) { if ("xwork.xml".equals(file)) { configurationManager.addContainerProvider(createXmlConfigurationProvider(file, false)); } else { configurationManager.addContainerProvider(createStrutsXmlConfigurationProvider(file, false, servletContext)); } } else { throw new IllegalArgumentException("Invalid configuration file name"); } } }
// in java/org/apache/struts2/dispatcher/StreamResult.java
protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { // Override any parameters using values on the stack resolveParamsFromStack(invocation.getStack(), invocation); OutputStream oOutput = null; try { if (inputStream == null) { // Find the inputstream from the invocation variable stack inputStream = (InputStream) invocation.getStack().findValue(conditionalParse(inputName, invocation)); } if (inputStream == null) { String msg = ("Can not find a java.io.InputStream with the name [" + inputName + "] in the invocation stack. " + "Check the <param name=\"inputName\"> tag specified for this action."); LOG.error(msg); throw new IllegalArgumentException(msg); } // Find the Response in context HttpServletResponse oResponse = (HttpServletResponse) invocation.getInvocationContext().get(HTTP_RESPONSE); // Set the content type if (contentCharSet != null && ! contentCharSet.equals("")) { oResponse.setContentType(conditionalParse(contentType, invocation)+";charset="+contentCharSet); } else { oResponse.setContentType(conditionalParse(contentType, invocation)); } // Set the content length if (contentLength != null) { String _contentLength = conditionalParse(contentLength, invocation); int _contentLengthAsInt = -1; try { _contentLengthAsInt = Integer.parseInt(_contentLength); if (_contentLengthAsInt >= 0) { oResponse.setContentLength(_contentLengthAsInt); } } catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e); } } } // Set the content-disposition if (contentDisposition != null) { oResponse.addHeader("Content-Disposition", conditionalParse(contentDisposition, invocation)); } // Set the cache control headers if neccessary if (!allowCaching) { oResponse.addHeader("Pragma", "no-cache"); oResponse.addHeader("Cache-Control", "no-cache"); } // Get the outputstream oOutput = oResponse.getOutputStream(); if (LOG.isDebugEnabled()) { LOG.debug("Streaming result [" + inputName + "] type=[" + contentType + "] length=[" + contentLength + "] content-disposition=[" + contentDisposition + "] charset=[" + contentCharSet + "]"); } // Copy input to output if (LOG.isDebugEnabled()) { LOG.debug("Streaming to output buffer +++ START +++"); } byte[] oBuff = new byte[bufferSize]; int iSize; while (-1 != (iSize = inputStream.read(oBuff))) { oOutput.write(oBuff, 0, iSize); } if (LOG.isDebugEnabled()) { LOG.debug("Streaming to output buffer +++ END +++"); } // Flush oOutput.flush(); } finally { if (inputStream != null) inputStream.close(); if (oOutput != null) oOutput.close(); } }
// in java/org/apache/struts2/util/TokenHelper.java
public static String setToken(String tokenName) { Map session = ActionContext.getContext().getSession(); String token = generateGUID(); try { session.put(tokenName, token); } catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); } return token; }
// in java/org/apache/struts2/util/DateFormatter.java
public void setDate(String date) { try { this.date = parser.parse(date); } catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); } }
// in java/org/apache/struts2/util/PrefixTrie.java
public void put(String prefix, Object value) { Node current = root; for (int i = 0; i < prefix.length(); i++) { char c = prefix.charAt(i); if (c > SIZE) throw new IllegalArgumentException("'" + c + "' is too big."); if (current.next[c] == null) current.next[c] = new Node(); current = current.next[c]; } current.value = value; }
// in java/org/apache/struts2/util/RegexPatternMatcher.java
public RegexPatternMatcherExpression compilePattern(String data) { Map<Integer, String> params = new HashMap<Integer, String>(); Matcher matcher = PATTERN.matcher(data); int count = 0; while (matcher.find()) { String expression = matcher.group(1); //check if it is a regex int index = expression.indexOf(':'); if (index > 0) { String paramName = expression.substring(0, index); String regex = StringUtils.substring(expression, index + 1); if (StringUtils.isBlank(regex)) { throw new IllegalArgumentException("invalid expression [" + expression + "], named parameter regular exression " + "must be in the format {PARAM_NAME:REGEX}"); } params.put(++count, paramName); } else { params.put(++count, expression); } } //generate a new pattern used to match URIs //replace {X:B} by (B) String newPattern = data.replaceAll("(\\{[^\\}]*?:(.*?)\\})", "($2)"); //replace {X} by (.*?) newPattern = newPattern.replaceAll("(\\{.*?\\})", "(.*?)"); return new RegexPatternMatcherExpression(Pattern.compile(newPattern), params); }
// in java/org/apache/struts2/util/StrutsUtil.java
public String include(Object aName, HttpServletRequest aRequest, HttpServletResponse aResponse) throws Exception { try { RequestDispatcher dispatcher = aRequest.getRequestDispatcher(aName.toString()); if (dispatcher == null) { throw new IllegalArgumentException("Cannot find included file " + aName); } ResponseWrapper responseWrapper = new ResponseWrapper(aResponse); dispatcher.include(aRequest, responseWrapper); return responseWrapper.getData(); } catch (Exception e) { e.printStackTrace(); throw e; } }
2
              
// in java/org/apache/struts2/util/TokenHelper.java
catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); }
// in java/org/apache/struts2/util/DateFormatter.java
catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); }
12
              
// in java/org/apache/struts2/config/DefaultSettings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { delegate.setImpl(name, value); }
// in java/org/apache/struts2/config/DefaultSettings.java
public String getImpl(String aName) throws IllegalArgumentException { return delegate.getImpl(aName); }
// in java/org/apache/struts2/config/Settings.java
public static String get(String name) throws IllegalArgumentException { return getInstance().getImpl(name); }
// in java/org/apache/struts2/config/Settings.java
public static Location getLocation(String name) throws IllegalArgumentException { return getInstance().getLocationImpl(name); }
// in java/org/apache/struts2/config/Settings.java
public static void set(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { getInstance().setImpl(name, value); }
// in java/org/apache/struts2/config/Settings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { throw new UnsupportedOperationException("Settings: This implementation does not support setting a value."); }
// in java/org/apache/struts2/config/Settings.java
public String getImpl(String name) throws IllegalArgumentException { return null; }
// in java/org/apache/struts2/config/Settings.java
public Location getLocationImpl(String name) throws IllegalArgumentException { return null; }
// in java/org/apache/struts2/config/PropertiesSettings.java
public String getImpl(String aName) throws IllegalArgumentException { String setting = settings.getProperty(aName); if (setting == null) { throw new IllegalArgumentException("No such setting:" + aName); } return setting; }
// in java/org/apache/struts2/config/PropertiesSettings.java
public Location getLocationImpl(String aName) throws IllegalArgumentException { Location loc = settings.getPropertyLocation(aName); if (loc == null) { if (!settings.containsKey(aName)) { throw new IllegalArgumentException("No such setting:" + aName); } } return loc; }
// in java/org/apache/struts2/config/DelegatingSettings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { IllegalArgumentException e = null; for (Settings delegate : delegates) { try { delegate.getImpl(name); // Throws exception if not found delegate.setImpl(name, value); // Found it return; // Done } catch (IllegalArgumentException ex) { e = ex; // Try next delegate } } throw e; }
// in java/org/apache/struts2/config/DelegatingSettings.java
public String getImpl(String name) throws IllegalArgumentException { IllegalArgumentException e = null; for (Settings delegate : delegates) { try { return delegate.getImpl(name); // Throws exception if not found } catch (IllegalArgumentException ex) { e = ex; // Try next delegate } } throw e; }
(Lib) IllegalStateException 7
              
// in java/org/apache/struts2/config/NullResult.java
public void execute(ActionInvocation invocation) throws Exception { throw new IllegalStateException("Shouldn't be called"); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public Container getContainer() { ConfigurationManager mgr = getConfigurationManager(); if (mgr == null) { throw new IllegalStateException("The configuration manager shouldn't be null"); } else { Configuration config = mgr.getConfiguration(); if (config == null) { throw new IllegalStateException("Unable to load configuration"); } else { return config.getContainer(); } } }
// in java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java
public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) { if (!isSlashesInActionNames()) { throw new IllegalStateException("This action mapper requires the setting 'slashesInActionNames' to be set to 'true'"); } ActionMapping mapping = super.getMapping(request, configManager); if (mapping == null) { return null; } String actionName = mapping.getName(); String id = null; // Only try something if the action name is specified if (actionName != null && actionName.length() > 0) { int lastSlashPos = actionName.lastIndexOf('/'); if (lastSlashPos > -1) { id = actionName.substring(lastSlashPos+1); } // If a method hasn't been explicitly named, try to guess using ReST-style patterns if (mapping.getMethod() == null) { if (lastSlashPos == actionName.length() -1) { // Index e.g. foo/ if (isGet(request)) { mapping.setMethod("index"); // Creating a new entry on POST e.g. foo/ } else if (isPost(request)) { mapping.setMethod("create"); } } else if (lastSlashPos > -1) { // Viewing the form to create a new item e.g. foo/new if (isGet(request) && "new".equals(id)) { mapping.setMethod("editNew"); // Viewing an item e.g. foo/1 } else if (isGet(request)) { mapping.setMethod("view"); // Removing an item e.g. foo/1 } else if (isDelete(request)) { mapping.setMethod("remove"); // Updating an item e.g. foo/1 } else if (isPut(request)) { mapping.setMethod("update"); } } if (idParameterName != null && lastSlashPos > -1) { actionName = actionName.substring(0, lastSlashPos); } } if (idParameterName != null && id != null) { if (mapping.getParams() == null) { mapping.setParams(new HashMap<String, Object>()); } mapping.getParams().put(idParameterName, id); } // Try to determine parameters from the url before the action name int actionSlashPos = actionName.lastIndexOf('/', lastSlashPos - 1); if (actionSlashPos > 0 && actionSlashPos < lastSlashPos) { String params = actionName.substring(0, actionSlashPos); HashMap<String,String> parameters = new HashMap<String,String>(); try { StringTokenizer st = new StringTokenizer(params, "/"); boolean isNameTok = true; String paramName = null; String paramValue; while (st.hasMoreTokens()) { if (isNameTok) { paramName = URLDecoder.decode(st.nextToken(), "UTF-8"); isNameTok = false; } else { paramValue = URLDecoder.decode(st.nextToken(), "UTF-8"); if ((paramName != null) && (paramName.length() > 0)) { parameters.put(paramName, paramValue); } isNameTok = true; } } if (parameters.size() > 0) { if (mapping.getParams() == null) { mapping.setParams(new HashMap<String, Object>()); } mapping.getParams().putAll(parameters); } } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to determine parameters from the url", e); } } mapping.setName(actionName.substring(actionSlashPos+1)); } } return mapping; }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
public Dispatcher findDispatcherOnThread() { Dispatcher dispatcher = Dispatcher.getInstance(); if (dispatcher == null) { throw new IllegalStateException("Must have the StrutsPrepareFilter execute before this one"); } return dispatcher; }
// in java/org/apache/struts2/util/InvocationSessionStore.java
static void setInvocationMap(Map invocationMap) { Map session = ActionContext.getContext().getSession(); if (session == null) { throw new IllegalStateException("Unable to access the session."); } session.put(INVOCATION_MAP_KEY, invocationMap); }
// in java/org/apache/struts2/util/InvocationSessionStore.java
static Map getInvocationMap() { Map session = ActionContext.getContext().getSession(); if (session == null) { throw new IllegalStateException("Unable to access the session."); } Map invocationMap = (Map) session.get(INVOCATION_MAP_KEY); if (invocationMap == null) { invocationMap = new HashMap(); setInvocationMap(invocationMap); } return invocationMap; }
0 1
              
// in java/org/apache/struts2/config/Settings.java
public static void setInstance(Settings config) throws IllegalStateException { settingsImpl = config; locale = null; }
(Lib) IOException 6
              
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
protected URL findInFileSystem(String fileName) throws IOException { URL url = null; File file = new File(fileName); if (LOG.isDebugEnabled()) { LOG.debug("Trying to load file " + file); } // Trying relative path to original file if (!file.exists()) { file = new File(baseDir, fileName); } if (file.exists()) { try { url = file.toURI().toURL(); } catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); } } return url; }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
protected void loadSettings(ServletContext servletContext) { InputStream in = null; try { in = fileManager.loadFile(ClassLoaderUtil.getResource("freemarker.properties", getClass())); if (in != null) { Properties p = new Properties(); p.load(in); for (Object o : p.keySet()) { String name = (String) o; String value = (String) p.get(name); if (name == null) { throw new IOException( "init-param without param-name. Maybe the freemarker.properties is not well-formed?"); } if (value == null) { throw new IOException( "init-param without param-value. Maybe the freemarker.properties is not well-formed?"); } addSetting(name, value); } } } catch (IOException e) { LOG.error("Error while loading freemarker settings from /freemarker.properties", e); } catch (TemplateException e) { LOG.error("Error while loading freemarker settings from /freemarker.properties", e); } finally { if (in != null) { try { in.close(); } catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } } } } }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
public InputStream getInputStream() throws IOException { InputStream in = req.getInputStream(); if (in == null) { throw new IOException("Missing content in the request"); } return req.getInputStream(); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(int datum) throws IOException { if (closed) { throw new IOException("Stream closed"); } if (index == blockSize) { addBuffer(); } buffer[index++] = (byte) datum; }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(byte data[], int offset, int length) throws IOException { if (data == null) { throw new NullPointerException(); } if (offset < 0 || offset + length > data.length || length < 0) { throw new IndexOutOfBoundsException(); } if (closed) { throw new IOException("Stream closed"); } if (index + length > blockSize) { do { if (index == blockSize) { addBuffer(); } int copyLength = blockSize - index; if (length < copyLength) { copyLength = length; } System.arraycopy(data, offset, buffer, index, copyLength); offset += copyLength; index += copyLength; length -= copyLength; } while (length > 0); } else { System.arraycopy(data, offset, buffer, index, length); index += length; } }
1
              
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); }
56
              
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
Override protected Iterator<URL> getConfigurationUrls(String fileName) throws IOException { URL url = null; if (baseDir != null) { url = findInFileSystem(fileName); if (url == null) { return super.getConfigurationUrls(fileName); } } if (url != null) { List<URL> list = new ArrayList<URL>(); list.add(url); return list.iterator(); } else { return super.getConfigurationUrls(fileName); } }
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
protected URL findInFileSystem(String fileName) throws IOException { URL url = null; File file = new File(fileName); if (LOG.isDebugEnabled()) { LOG.debug("Trying to load file " + file); } // Trying relative path to original file if (!file.exists()) { file = new File(baseDir, fileName); } if (file.exists()) { try { url = file.toURI().toURL(); } catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); } } return url; }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
public void renderTemplate(TemplateRenderingContext templateContext) throws Exception { // get the various items required from the stack ValueStack stack = templateContext.getStack(); Map context = stack.getContext(); ServletContext servletContext = (ServletContext) context.get(ServletActionContext.SERVLET_CONTEXT); HttpServletRequest req = (HttpServletRequest) context.get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) context.get(ServletActionContext.HTTP_RESPONSE); // prepare freemarker Configuration config = freemarkerManager.getConfiguration(servletContext); // get the list of templates we can use List<Template> templates = templateContext.getTemplate().getPossibleTemplates(this); // find the right template freemarker.template.Template template = null; String templateName = null; Exception exception = null; for (Template t : templates) { templateName = getFinalTemplateName(t); try { // try to load, and if it works, stop at the first one template = config.getTemplate(templateName); break; } catch (ParseException e) { // template was found but was invalid - always report this. exception = e; break; } catch (IOException e) { // FileNotFoundException is anticipated - report the first IOException if no template found if (exception == null) { exception = e; } } } if (template == null) { if (LOG.isErrorEnabled()) { LOG.error("Could not load the FreeMarker template named '" + templateContext.getTemplate().getName() +"':"); for (Template t : templates) { LOG.error("Attempted: " + getFinalTemplateName(t)); } LOG.error("The TemplateLoader provided by the FreeMarker Configuration was a: "+config.getTemplateLoader().getClass().getName()); } if (exception != null) { throw exception; } else { return; } } if (LOG.isDebugEnabled()) { LOG.debug("Rendering template " + templateName); } ActionInvocation ai = ActionContext.getContext().getActionInvocation(); Object action = (ai == null) ? null : ai.getAction(); SimpleHash model = freemarkerManager.buildTemplateModel(stack, action, servletContext, req, res, config.getObjectWrapper()); model.put("tag", templateContext.getTag()); model.put("themeProperties", getThemeProps(templateContext.getTemplate())); // the BodyContent JSP writer doesn't like it when FM flushes automatically -- // so let's just not do it (it will be flushed eventually anyway) Writer writer = templateContext.getWriter(); final Writer wrapped = writer; writer = new Writer() { public void write(char cbuf[], int off, int len) throws IOException { wrapped.write(cbuf, off, len); } public void flush() throws IOException { // nothing! } public void close() throws IOException { wrapped.close(); } }; try { stack.push(templateContext.getTag()); template.process(model, writer); } finally { stack.pop(); } }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
public void write(char cbuf[], int off, int len) throws IOException { wrapped.write(cbuf, off, len); }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
public void flush() throws IOException { // nothing! }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
public void close() throws IOException { wrapped.close(); }
// in java/org/apache/struts2/components/Include.java
public static void include( String relativePath, Writer writer, ServletRequest request, HttpServletResponse response ) throws ServletException, IOException { include(relativePath, writer, request, response, null); }
// in java/org/apache/struts2/components/Include.java
public static void include( String relativePath, Writer writer, ServletRequest request, HttpServletResponse response, String encoding ) throws ServletException, IOException { String resourcePath = getContextRelativePath(request, relativePath); RequestDispatcher rd = request.getRequestDispatcher(resourcePath); if (rd == null) { throw new ServletException("Not a valid resource path:" + resourcePath); } PageResponse pageResponse = new PageResponse(response); // Include the resource rd.include(request, pageResponse); if (encoding != null) { // Use given encoding pageResponse.getContent().writeTo(writer, encoding); } else { //use the platform specific encoding pageResponse.getContent().writeTo(writer, systemEncoding); } }
// in java/org/apache/struts2/components/Include.java
public FastByteArrayOutputStream getBuffer() throws IOException { flush(); return buffer; }
// in java/org/apache/struts2/components/Include.java
public void close() throws IOException { buffer.close(); }
// in java/org/apache/struts2/components/Include.java
public void flush() throws IOException { buffer.flush(); }
// in java/org/apache/struts2/components/Include.java
public void write(byte[] b, int o, int l) throws IOException { buffer.write(b, o, l); }
// in java/org/apache/struts2/components/Include.java
public void write(int i) throws IOException { buffer.write(i); }
// in java/org/apache/struts2/components/Include.java
public void write(byte[] b) throws IOException { buffer.write(b); }
// in java/org/apache/struts2/components/Include.java
public FastByteArrayOutputStream getContent() throws IOException { //if we are using a writer, we need to flush the //data to the underlying outputstream. //most containers do this - but it seems Jetty 4.0.5 doesn't if (pagePrintWriter != null) { pagePrintWriter.flush(); } return ((PageOutputStream) getOutputStream()).getBuffer(); }
// in java/org/apache/struts2/components/Include.java
public ServletOutputStream getOutputStream() throws IOException { if (pageOutputStream == null) { pageOutputStream = new PageOutputStream(); } return pageOutputStream; }
// in java/org/apache/struts2/components/Include.java
public PrintWriter getWriter() throws IOException { if (pagePrintWriter == null) { pagePrintWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), getCharacterEncoding())); } return pagePrintWriter; }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public void close() throws IOException { if (bean.usesBody()) { body.close(); } }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public void flush() throws IOException { writer.flush(); if (bean.usesBody()) { body.flush(); } }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public void write(char cbuf[], int off, int len) throws IOException { if (bean.usesBody() && !afterBody) { body.write(cbuf, off, len); } else { writer.write(cbuf, off, len); } }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public int onStart() throws TemplateModelException, IOException { boolean result = bean.start(this); if (result) { return EVALUATE_BODY; } else { return SKIP_BODY; } }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public int afterBody() throws TemplateModelException, IOException { afterBody = true; boolean result = bean.end(this, bean.usesBody() ? body.toString() : ""); if (result) { return REPEAT_EVALUATION; } else { return END_EVALUATION; } }
// in java/org/apache/struts2/views/freemarker/tags/TagModel.java
public Writer getWriter(Writer writer, Map params) throws TemplateModelException, IOException { Component bean = getBean(); Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); Map unwrappedParameters = unwrapParameters(params); bean.copyParams(unwrappedParameters); return new CallbackWriter(bean, writer); }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
public void doExecute(String locationArg, ActionInvocation invocation) throws IOException, TemplateException { this.location = locationArg; this.invocation = invocation; this.configuration = getConfiguration(); this.wrapper = getObjectWrapper(); ActionContext ctx = invocation.getInvocationContext(); HttpServletRequest req = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST); if (!locationArg.startsWith("/")) { String base = ResourceUtil.getResourceBase(req); locationArg = base + "/" + locationArg; } Template template = configuration.getTemplate(locationArg, deduceLocale()); TemplateModel model = createModel(); // Give subclasses a chance to hook into preprocessing if (preTemplateProcess(template, model)) { try { // Process the template Writer writer = getWriter(); if (isWriteIfCompleted() || configuration.getTemplateExceptionHandler() == TemplateExceptionHandler.RETHROW_HANDLER) { CharArrayWriter parentCharArrayWriter = (CharArrayWriter) req.getAttribute(PARENT_TEMPLATE_WRITER); boolean isTopTemplate = false; if (isTopTemplate = (parentCharArrayWriter == null)) { //this is the top template parentCharArrayWriter = new CharArrayWriter(); //set it in the request because when the "action" tag is used a new VS and ActionContext is created req.setAttribute(PARENT_TEMPLATE_WRITER, parentCharArrayWriter); } try { template.process(model, parentCharArrayWriter); if (isTopTemplate) { parentCharArrayWriter.flush(); parentCharArrayWriter.writeTo(writer); } } finally { if (isTopTemplate && parentCharArrayWriter != null) { req.removeAttribute(PARENT_TEMPLATE_WRITER); parentCharArrayWriter.close(); } } } else { template.process(model, writer); } } finally { // Give subclasses a chance to hook into postprocessing postTemplateProcess(template, model); } } }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
protected Writer getWriter() throws IOException { if(writer != null) { return writer; } return ServletActionContext.getResponse().getWriter(); }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
protected void postTemplateProcess(Template template, TemplateModel data) throws IOException { }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
protected boolean preTemplateProcess(Template template, TemplateModel model) throws IOException { Object attrContentType = template.getCustomAttribute("content_type"); HttpServletResponse response = ServletActionContext.getResponse(); if (response.getContentType() == null) { if (attrContentType != null) { response.setContentType(attrContentType.toString()); } else { String contentType = getContentType(); if (contentType == null) { contentType = "text/html"; } String encoding = template.getEncoding(); if (encoding != null) { contentType = contentType + "; charset=" + encoding; } response.setContentType(contentType); } } else if(isInsideActionTag()){ //trigger com.opensymphony.module.sitemesh.filter.PageResponseWrapper.deactivateSiteMesh() response.setContentType(response.getContentType()); } return true; }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
protected Templates getTemplates(String path) throws TransformerException, IOException { String pathFromRequest = ServletActionContext.getRequest().getParameter("xslt.location"); if (pathFromRequest != null) path = pathFromRequest; if (path == null) throw new TransformerException("Stylesheet path is null"); Templates templates = templatesCache.get(path); if (noCache || (templates == null)) { synchronized (templatesCache) { URL resource = ServletActionContext.getServletContext().getResource(path); if (resource == null) { throw new TransformerException("Stylesheet " + path + " not found in resources."); } if (LOG.isDebugEnabled()) { LOG.debug("Preparing XSLT stylesheet templates: " + path); } TransformerFactory factory = TransformerFactory.newInstance(); factory.setURIResolver(getURIResolver()); templates = factory.newTemplates(new StreamSource(resource.openStream())); templatesCache.put(path, templates); } } return templates; }
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { // get the bean ValueStack stack = (ValueStack) ctx.get("stack"); HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE); Component bean = getBean(stack, req, res); Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); // get the parameters Map params = createPropertyMap(ctx, node); bean.copyParams(params); //bean.addAllParameters(params); bean.start(writer); if (getType() == BLOCK) { Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1); body.render(ctx, writer); } bean.end(writer, ""); return true; }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
private RequestContext createRequestContext(final HttpServletRequest req) { return new RequestContext() { public String getCharacterEncoding() { return req.getCharacterEncoding(); } public String getContentType() { return req.getContentType(); } public int getContentLength() { return req.getContentLength(); } public InputStream getInputStream() throws IOException { InputStream in = req.getInputStream(); if (in == null) { throw new IOException("Missing content in the request"); } return req.getInputStream(); } }; }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
public InputStream getInputStream() throws IOException { InputStream in = req.getInputStream(); if (in == null) { throw new IOException("Missing content in the request"); } return req.getInputStream(); }
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String timerKey = "ActionContextCleanUp_doFilter: "; try { UtilTimerStack.push(timerKey); try { Integer count = (Integer)request.getAttribute(COUNTER); if (count == null) { count = Integer.valueOf(1); } else { count = Integer.valueOf(count.intValue()+1); } request.setAttribute(COUNTER, count); //LOG.debug("filtering counter="+count); chain.doFilter(request, response); } finally { int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue(); counterVal -= 1; request.setAttribute(COUNTER, Integer.valueOf(counterVal)); cleanUp(request); } } finally { UtilTimerStack.pop(timerKey); } }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException { // don't wrap more than once if (request instanceof StrutsRequestWrapper) { return request; } String content_type = request.getContentType(); if (content_type != null && content_type.contains("multipart/form-data")) { MultiPartRequest mpr = null; //check for alternate implementations of MultiPartRequest Set<String> multiNames = getContainer().getInstanceNames(MultiPartRequest.class); if (multiNames != null) { for (String multiName : multiNames) { if (multiName.equals(multipartHandlerName)) { mpr = getContainer().getInstance(MultiPartRequest.class, multiName); } } } if (mpr == null ) { mpr = getContainer().getInstance(MultiPartRequest.class); } request = new MultiPartRequestWrapper(mpr, request, getSaveDir(servletContext)); } else { request = new StrutsRequestWrapper(request); } return request; }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void cleanUpRequest(HttpServletRequest request) throws IOException { if (!(request instanceof MultiPartRequestWrapper)) { return; } MultiPartRequestWrapper multiWrapper = (MultiPartRequestWrapper) request; Enumeration fileParameterNames = multiWrapper.getFileParameterNames(); while (fileParameterNames != null && fileParameterNames.hasMoreElements()) { String inputValue = (String) fileParameterNames.nextElement(); File[] files = multiWrapper.getFiles(inputValue); for (File currentFile : files) { if (LOG.isInfoEnabled()) { String msg = LocalizedTextUtil.findText(this.getClass(), "struts.messages.removing.file", Locale.ENGLISH, "no.message.found", new Object[]{inputValue, currentFile}); LOG.info(msg); } if ((currentFile != null) && currentFile.isFile()) { if (!currentFile.delete()) { if (LOG.isWarnEnabled()) { LOG.warn("Resource Leaking: Could not remove uploaded file '" + currentFile.getCanonicalPath() + "'."); } } } } } }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
public void findStaticResource(String path, HttpServletRequest request, HttpServletResponse response) throws IOException { String name = cleanupPath(path); for (String pathPrefix : pathPrefixes) { URL resourceUrl = findResource(buildPath(name, pathPrefix)); if (resourceUrl != null) { InputStream is = null; try { //check that the resource path is under the pathPrefix path String pathEnding = buildPath(name, pathPrefix); if (resourceUrl.getFile().endsWith(pathEnding)) is = resourceUrl.openStream(); } catch (IOException ex) { // just ignore it continue; } //not inside the try block, as this could throw IOExceptions also if (is != null) { process(is, path, request, response); return; } } } response.sendError(HttpServletResponse.SC_NOT_FOUND); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
protected void process(InputStream is, String path, HttpServletRequest request, HttpServletResponse response) throws IOException { if (is != null) { Calendar cal = Calendar.getInstance(); // check for if-modified-since, prior to any other headers long ifModifiedSince = 0; try { ifModifiedSince = request.getDateHeader("If-Modified-Since"); } catch (Exception e) { log.warn("Invalid If-Modified-Since header value: '" + request.getHeader("If-Modified-Since") + "', ignoring"); } long lastModifiedMillis = lastModifiedCal.getTimeInMillis(); long now = cal.getTimeInMillis(); cal.add(Calendar.DAY_OF_MONTH, 1); long expires = cal.getTimeInMillis(); if (ifModifiedSince > 0 && ifModifiedSince <= lastModifiedMillis) { // not modified, content is not sent - only basic // headers and status SC_NOT_MODIFIED response.setDateHeader("Expires", expires); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); is.close(); return; } // set the content-type header String contentType = getContentType(path); if (contentType != null) { response.setContentType(contentType); } if (serveStaticBrowserCache) { // set heading information for caching static content response.setDateHeader("Date", now); response.setDateHeader("Expires", expires); response.setDateHeader("Retry-After", expires); response.setHeader("Cache-Control", "public"); response.setDateHeader("Last-Modified", lastModifiedMillis); } else { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setHeader("Expires", "-1"); } try { copy(is, response.getOutputStream()); } finally { is.close(); } return; } }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
protected URL findResource(String path) throws IOException { return ClassLoaderUtil.getResource(path, getClass()); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
protected void copy(InputStream input, OutputStream output) throws IOException { final byte[] buffer = new byte[4096]; int n; while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); } output.flush(); }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; if (excludeUrl(request)) { chain.doFilter(request, response); return; } // This is necessary since we need the dispatcher instance, which was created by the prepare filter if (execute == null) { lazyInit(); } ActionMapping mapping = prepare.findActionMapping(request, response); //if recusrion counter is > 1, it means we are in a "forward", in that case a mapping will still be //in the request, if we handle it, it will lead to an infinte loop, see WW-3077 Integer recursionCounter = (Integer) request.getAttribute(PrepareOperations.CLEANUP_RECURSION_COUNTER); if (mapping == null || recursionCounter > 1) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) { chain.doFilter(request, response); } } else { execute.executeAction(request, response, mapping); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; try { prepare.setEncodingAndLocale(request, response); prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); if ( excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) { chain.doFilter(request, response); } else { request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response, true); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) { chain.doFilter(request, response); } } else { execute.executeAction(request, response, mapping); } } } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; try { prepare.setEncodingAndLocale(request, response); prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); if ( excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) { request.setAttribute(REQUEST_EXCLUDED_FROM_ACTION_MAPPING, new Object()); } else { request = prepare.wrapRequest(request); prepare.findActionMapping(request, response); } chain.doFilter(request, response); } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); prepare.setEncodingAndLocale(request, response); request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) throw new ServletException("Resource loading not supported, use the StrutsPrepareAndExecuteFilter instead."); } else { execute.executeAction(request, response, mapping); } } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/ExecuteOperations.java
public boolean executeStaticResourceRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // there is no action in this request, should we look for a static resource? String resourcePath = RequestUtils.getServletPath(request); if ("".equals(resourcePath) && null != request.getPathInfo()) { resourcePath = request.getPathInfo(); } StaticContentLoader staticResourceLoader = dispatcher.getContainer().getInstance(StaticContentLoader.class); if (staticResourceLoader.canHandle(resourcePath)) { staticResourceLoader.findStaticResource(resourcePath, request, response); // The framework did its job here return true; } else { // this is a normal request, let it pass through return false; } }
// in java/org/apache/struts2/dispatcher/PlainTextResult.java
protected void sendStream(PrintWriter writer, InputStreamReader reader) throws IOException { char[] buffer = new char[BUFFER_SIZE]; int charRead; while((charRead = reader.read(buffer)) != -1) { writer.write(buffer, 0, charRead); } }
// in java/org/apache/struts2/dispatcher/ServletRedirectResult.java
protected void sendRedirect(HttpServletResponse response, String finalLocation) throws IOException { if (SC_FOUND == statusCode) { response.sendRedirect(finalLocation); } else { response.setStatus(statusCode); response.setHeader("Location", finalLocation); response.getWriter().write(finalLocation); response.getWriter().close(); } }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; ServletContext servletContext = getServletContext(); String timerKey = "FilterDispatcher_doFilter: "; try { // FIXME: this should be refactored better to not duplicate work with the action invocation ValueStack stack = dispatcher.getContainer().getInstance(ValueStackFactory.class).createValueStack(); ActionContext ctx = new ActionContext(stack.getContext()); ActionContext.setContext(ctx); UtilTimerStack.push(timerKey); request = prepareDispatcherAndWrapRequest(request, response); ActionMapping mapping; try { mapping = actionMapper.getMapping(request, dispatcher.getConfigurationManager()); } catch (Exception ex) { log.error("error getting ActionMapping", ex); dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); return; } if (mapping == null) { // there is no action in this request, should we look for a static resource? String resourcePath = RequestUtils.getServletPath(request); if ("".equals(resourcePath) && null != request.getPathInfo()) { resourcePath = request.getPathInfo(); } if (staticResourceLoader.canHandle(resourcePath)) { staticResourceLoader.findStaticResource(resourcePath, request, response); } else { // this is a normal request, let it pass through chain.doFilter(request, response); } // The framework did its job here return; } dispatcher.serviceAction(request, response, servletContext, mapping); } finally { dispatcher.cleanUpRequest(request); try { ActionContextCleanUp.cleanUp(req); } finally { UtilTimerStack.pop(timerKey); } devModeOverride.remove(); } }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void writeTo(OutputStream out) throws IOException { if (buffers != null) { for (byte[] bytes : buffers) { out.write(bytes, 0, blockSize); } } out.write(buffer, 0, index); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void writeTo(RandomAccessFile out) throws IOException { if (buffers != null) { for (byte[] bytes : buffers) { out.write(bytes, 0, blockSize); } } out.write(buffer, 0, index); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void writeTo(Writer out, String encoding) throws IOException { if (encoding != null) { CharsetDecoder decoder = getDecoder(encoding); // Create buffer for characters decoding CharBuffer charBuffer = CharBuffer.allocate(buffer.length); // Create buffer for bytes float bytesPerChar = decoder.charset().newEncoder().maxBytesPerChar(); ByteBuffer byteBuffer = ByteBuffer.allocate((int) (buffer.length + bytesPerChar)); if (buffers != null) { for (byte[] bytes : buffers) { decodeAndWriteOut(out, bytes, bytes.length, byteBuffer, charBuffer, decoder, false); } } decodeAndWriteOut(out, buffer, index, byteBuffer, charBuffer, decoder, true); } else { if (buffers != null) { for (byte[] bytes : buffers) { writeOut(out, bytes, bytes.length); } } writeOut(out, buffer, index); } }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void writeTo(JspWriter out, String encoding) throws IOException { try { writeTo((Writer) out, encoding); } catch (IOException e) { writeToFile(); throw e; } catch (Throwable e) { writeToFile(); throw new RuntimeException(e); } }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
private void writeOut(Writer out, byte[] bytes, int length) throws IOException { out.write(new String(bytes, 0, length)); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
private static void decodeAndWriteOut(Writer writer, byte[] bytes, int length, ByteBuffer in, CharBuffer out, CharsetDecoder decoder, boolean endOfInput) throws IOException { // Append bytes to current buffer // Previous data maybe partially decoded, this part will appended to previous in.put(bytes, 0, length); // To begin of data in.flip(); decodeAndWriteBuffered(writer, in, out, decoder, endOfInput); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
private static void decodeAndWriteBuffered(Writer writer, ByteBuffer in, CharBuffer out, CharsetDecoder decoder, boolean endOfInput) throws IOException { // Decode CoderResult result; do { result = decodeAndWrite(writer, in, out, decoder, endOfInput); // Check that all data are decoded if (in.hasRemaining()) { // Move remaining to top of buffer in.compact(); if (result.isOverflow() && !result.isError() && !result.isMalformed()) { // Not all buffer chars decoded, spin it again // Set to begin in.flip(); } } else { // Clean up buffer in.clear(); } } while (in.hasRemaining() && result.isOverflow() && !result.isError() && !result.isMalformed()); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
private static CoderResult decodeAndWrite(Writer writer, ByteBuffer in, CharBuffer out, CharsetDecoder decoder, boolean endOfInput) throws IOException { CoderResult result = decoder.decode(in, out, endOfInput); // To begin of decoded data out.flip(); // Output writer.write(out.toString()); return result; }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(int datum) throws IOException { if (closed) { throw new IOException("Stream closed"); } if (index == blockSize) { addBuffer(); } buffer[index++] = (byte) datum; }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(byte data[], int offset, int length) throws IOException { if (data == null) { throw new NullPointerException(); } if (offset < 0 || offset + length > data.length || length < 0) { throw new IndexOutOfBoundsException(); } if (closed) { throw new IOException("Stream closed"); } if (index + length > blockSize) { do { if (index == blockSize) { addBuffer(); } int copyLength = blockSize - index; if (length < copyLength) { copyLength = length; } System.arraycopy(data, offset, buffer, index, copyLength); offset += copyLength; index += copyLength; length -= copyLength; } while (length > 0); } else { System.arraycopy(data, offset, buffer, index, length); index += length; } }
// in java/org/apache/struts2/util/VelocityStrutsUtil.java
public String evaluate(String expression) throws IOException, ResourceNotFoundException, MethodInvocationException, ParseErrorException { CharArrayWriter writer = new CharArrayWriter(); velocityEngine.evaluate(ctx, writer, "Error parsing " + expression, expression); return writer.toString(); }
// in java/org/apache/struts2/util/StrutsUtil.java
public PrintWriter getWriter() throws IOException { return writer; }
(Lib) JspException 4
              
// in java/org/apache/struts2/views/jsp/IteratorTag.java
public int doAfterBody() throws JspException { boolean again = component.end(pageContext.getOut(), getBody()); if (again) { return EVAL_BODY_AGAIN; } else { if (bodyContent != null) { try { bodyContent.writeOut(bodyContent.getEnclosingWriter()); } catch (Exception e) { throw new JspException(e.getMessage()); } } return SKIP_BODY; } }
1
              
// in java/org/apache/struts2/views/jsp/IteratorTag.java
catch (Exception e) { throw new JspException(e.getMessage()); }
8
              
// in java/org/apache/struts2/views/jsp/ui/AbstractUITag.java
public void setDynamicAttribute(String uri, String localName, Object value) throws JspException { if (value != null && value instanceof String) { dynamicAttributes.put(localName, String.valueOf(ObjectUtils.defaultIfNull(findValue(value.toString()), value))); } else { dynamicAttributes.put(localName, value); } }
// in java/org/apache/struts2/views/jsp/IteratorTag.java
public int doEndTag() throws JspException { component = null; return EVAL_PAGE; }
// in java/org/apache/struts2/views/jsp/IteratorTag.java
public int doAfterBody() throws JspException { boolean again = component.end(pageContext.getOut(), getBody()); if (again) { return EVAL_BODY_AGAIN; } else { if (bodyContent != null) { try { bodyContent.writeOut(bodyContent.getEnclosingWriter()); } catch (Exception e) { throw new JspException(e.getMessage()); } } return SKIP_BODY; } }
// in java/org/apache/struts2/views/jsp/ComponentTagSupport.java
public int doEndTag() throws JspException { component.end(pageContext.getOut(), getBody()); component = null; return EVAL_PAGE; }
// in java/org/apache/struts2/views/jsp/ComponentTagSupport.java
public int doStartTag() throws JspException { component = getBean(getStack(), (HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse()); Container container = Dispatcher.getInstance().getContainer(); container.inject(component); populateParams(); boolean evalBody = component.start(pageContext.getOut()); if (evalBody) { return component.usesBody() ? EVAL_BODY_BUFFERED : EVAL_BODY_INCLUDE; } else { return SKIP_BODY; } }
// in java/org/apache/struts2/views/jsp/iterator/IteratorGeneratorTag.java
public int doEndTag() throws JspException { // pop resulting iterator from stack at end tag getStack().pop(); iteratorGenerator = null; // clean up return EVAL_PAGE; }
// in java/org/apache/struts2/views/jsp/iterator/SortIteratorTag.java
public int doEndTag() throws JspException { int returnVal = super.doEndTag(); // pop sorted list from stack at the end of tag getStack().pop(); sortIteratorFilter = null; return returnVal; }
// in java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java
public int doEndTag() throws JspException { getStack().pop(); subsetIteratorFilter = null; return EVAL_PAGE; }
(Lib) ServletException 4
              
// in java/org/apache/struts2/components/Include.java
public static void include( String relativePath, Writer writer, ServletRequest request, HttpServletResponse response, String encoding ) throws ServletException, IOException { String resourcePath = getContextRelativePath(request, relativePath); RequestDispatcher rd = request.getRequestDispatcher(resourcePath); if (rd == null) { throw new ServletException("Not a valid resource path:" + resourcePath); } PageResponse pageResponse = new PageResponse(response); // Include the resource rd.include(request, pageResponse); if (encoding != null) { // Use given encoding pageResponse.getContent().writeTo(writer, encoding); } else { //use the platform specific encoding pageResponse.getContent().writeTo(writer, systemEncoding); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
public HttpServletRequest wrapRequest(HttpServletRequest oldRequest) throws ServletException { HttpServletRequest request = oldRequest; try { // Wrap request first, just in case it is multipart/form-data // parameters might not be accessible through before encoding (ww-1278) request = dispatcher.wrapRequest(request, servletContext); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); } return request; }
// in java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); prepare.setEncodingAndLocale(request, response); request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) throw new ServletException("Resource loading not supported, use the StrutsPrepareAndExecuteFilter instead."); } else { execute.executeAction(request, response, mapping); } } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
protected HttpServletRequest prepareDispatcherAndWrapRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException { Dispatcher du = Dispatcher.getInstance(); // Prepare and wrap the request if the cleanup filter hasn't already, cleanup filter should be // configured first before struts2 dispatcher filter, hence when its cleanup filter's turn, // static instance of Dispatcher should be null. if (du == null) { Dispatcher.setInstance(dispatcher); // prepare the request no matter what - this ensures that the proper character encoding // is used before invoking the mapper (see WW-9127) dispatcher.prepare(request, response); } else { dispatcher = du; } try { // Wrap request first, just in case it is multipart/form-data // parameters might not be accessible through before encoding (ww-1278) request = dispatcher.wrapRequest(request, getServletContext()); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); } return request; }
2
              
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); }
20
              
// in java/org/apache/struts2/components/Include.java
public static void include( String relativePath, Writer writer, ServletRequest request, HttpServletResponse response ) throws ServletException, IOException { include(relativePath, writer, request, response, null); }
// in java/org/apache/struts2/components/Include.java
public static void include( String relativePath, Writer writer, ServletRequest request, HttpServletResponse response, String encoding ) throws ServletException, IOException { String resourcePath = getContextRelativePath(request, relativePath); RequestDispatcher rd = request.getRequestDispatcher(resourcePath); if (rd == null) { throw new ServletException("Not a valid resource path:" + resourcePath); } PageResponse pageResponse = new PageResponse(response); // Include the resource rd.include(request, pageResponse); if (encoding != null) { // Use given encoding pageResponse.getContent().writeTo(writer, encoding); } else { //use the platform specific encoding pageResponse.getContent().writeTo(writer, systemEncoding); } }
// in java/org/apache/struts2/views/JspSupportServlet.java
public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); jspSupportServlet = this; }
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String timerKey = "ActionContextCleanUp_doFilter: "; try { UtilTimerStack.push(timerKey); try { Integer count = (Integer)request.getAttribute(COUNTER); if (count == null) { count = Integer.valueOf(1); } else { count = Integer.valueOf(count.intValue()+1); } request.setAttribute(COUNTER, count); //LOG.debug("filtering counter="+count); chain.doFilter(request, response); } finally { int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue(); counterVal -= 1; request.setAttribute(COUNTER, Integer.valueOf(counterVal)); cleanUp(request); } } finally { UtilTimerStack.pop(timerKey); } }
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
public void init(FilterConfig arg0) throws ServletException { }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException { Map<String, Object> extraContext = createContextMap(request, response, mapping, context); // If there was a previous value stack, then create a new copy and pass it in to be used by the new Action ValueStack stack = (ValueStack) request.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY); boolean nullStack = stack == null; if (nullStack) { ActionContext ctx = ActionContext.getContext(); if (ctx != null) { stack = ctx.getValueStack(); } } if (stack != null) { extraContext.put(ActionContext.VALUE_STACK, valueStackFactory.createValueStack(stack)); } String timerKey = "Handling request from Dispatcher"; try { UtilTimerStack.push(timerKey); String namespace = mapping.getNamespace(); String name = mapping.getName(); String method = mapping.getMethod(); Configuration config = configurationManager.getConfiguration(); ActionProxy proxy = config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy( namespace, name, method, extraContext, true, false); request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack()); // if the ActionMapping says to go straight to a result, do it! if (mapping.getResult() != null) { Result result = mapping.getResult(); result.execute(proxy.getInvocation()); } else { proxy.execute(); } // If there was a previous value stack then set it back onto the request if (!nullStack) { request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); } } catch (ConfigurationException e) { // WW-2874 Only log error if in devMode if(devMode) { String reqStr = request.getRequestURI(); if (request.getQueryString() != null) { reqStr = reqStr + "?" + request.getQueryString(); } LOG.error("Could not find action or result\n" + reqStr, e); } else { if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); } catch (Exception e) { sendError(request, response, context, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e); } finally { UtilTimerStack.pop(timerKey); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
public HttpServletRequest wrapRequest(HttpServletRequest oldRequest) throws ServletException { HttpServletRequest request = oldRequest; try { // Wrap request first, just in case it is multipart/form-data // parameters might not be accessible through before encoding (ww-1278) request = dispatcher.wrapRequest(request, servletContext); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); } return request; }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; if (excludeUrl(request)) { chain.doFilter(request, response); return; } // This is necessary since we need the dispatcher instance, which was created by the prepare filter if (execute == null) { lazyInit(); } ActionMapping mapping = prepare.findActionMapping(request, response); //if recusrion counter is > 1, it means we are in a "forward", in that case a mapping will still be //in the request, if we handle it, it will lead to an infinte loop, see WW-3077 Integer recursionCounter = (Integer) request.getAttribute(PrepareOperations.CLEANUP_RECURSION_COUNTER); if (mapping == null || recursionCounter > 1) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) { chain.doFilter(request, response); } } else { execute.executeAction(request, response, mapping); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
public void init(FilterConfig filterConfig) throws ServletException { InitOperations init = new InitOperations(); try { FilterHostConfig config = new FilterHostConfig(filterConfig); init.initLogging(config); Dispatcher dispatcher = init.initDispatcher(config); init.initStaticContentLoader(config, dispatcher); prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher); execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher); this.excludedPatterns = init.buildExcludedPatternsList(dispatcher); postInit(dispatcher, filterConfig); } finally { init.cleanup(); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; try { prepare.setEncodingAndLocale(request, response); prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); if ( excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) { chain.doFilter(request, response); } else { request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response, true); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) { chain.doFilter(request, response); } } else { execute.executeAction(request, response, mapping); } } } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
public void init(FilterConfig filterConfig) throws ServletException { InitOperations init = new InitOperations(); try { FilterHostConfig config = new FilterHostConfig(filterConfig); init.initLogging(config); Dispatcher dispatcher = init.initDispatcher(config); prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher); this.excludedPatterns = init.buildExcludedPatternsList(dispatcher); postInit(dispatcher, filterConfig); } finally { init.cleanup(); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; try { prepare.setEncodingAndLocale(request, response); prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); if ( excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) { request.setAttribute(REQUEST_EXCLUDED_FROM_ACTION_MAPPING, new Object()); } else { request = prepare.wrapRequest(request); prepare.findActionMapping(request, response); } chain.doFilter(request, response); } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
Override public void init(ServletConfig filterConfig) throws ServletException { InitOperations init = new InitOperations(); try { ServletHostConfig config = new ServletHostConfig(filterConfig); init.initLogging(config); Dispatcher dispatcher = init.initDispatcher(config); init.initStaticContentLoader(config, dispatcher); prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher); execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher); } finally { init.cleanup(); } }
// in java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); prepare.setEncodingAndLocale(request, response); request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) throw new ServletException("Resource loading not supported, use the StrutsPrepareAndExecuteFilter instead."); } else { execute.executeAction(request, response, mapping); } } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/ExecuteOperations.java
public boolean executeStaticResourceRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // there is no action in this request, should we look for a static resource? String resourcePath = RequestUtils.getServletPath(request); if ("".equals(resourcePath) && null != request.getPathInfo()) { resourcePath = request.getPathInfo(); } StaticContentLoader staticResourceLoader = dispatcher.getContainer().getInstance(StaticContentLoader.class); if (staticResourceLoader.canHandle(resourcePath)) { staticResourceLoader.findStaticResource(resourcePath, request, response); // The framework did its job here return true; } else { // this is a normal request, let it pass through return false; } }
// in java/org/apache/struts2/dispatcher/ng/ExecuteOperations.java
public void executeAction(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws ServletException { dispatcher.serviceAction(request, response, servletContext, mapping); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
public void init(FilterConfig filterConfig) throws ServletException { try { this.filterConfig = filterConfig; initLogging(); dispatcher = createDispatcher(filterConfig); dispatcher.init(); dispatcher.getContainer().inject(this); staticResourceLoader.setHostConfig(new FilterHostConfig(filterConfig)); } finally { ActionContext.setContext(null); } }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
protected HttpServletRequest prepareDispatcherAndWrapRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException { Dispatcher du = Dispatcher.getInstance(); // Prepare and wrap the request if the cleanup filter hasn't already, cleanup filter should be // configured first before struts2 dispatcher filter, hence when its cleanup filter's turn, // static instance of Dispatcher should be null. if (du == null) { Dispatcher.setInstance(dispatcher); // prepare the request no matter what - this ensures that the proper character encoding // is used before invoking the mapper (see WW-9127) dispatcher.prepare(request, response); } else { dispatcher = du; } try { // Wrap request first, just in case it is multipart/form-data // parameters might not be accessible through before encoding (ww-1278) request = dispatcher.wrapRequest(request, getServletContext()); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); } return request; }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; ServletContext servletContext = getServletContext(); String timerKey = "FilterDispatcher_doFilter: "; try { // FIXME: this should be refactored better to not duplicate work with the action invocation ValueStack stack = dispatcher.getContainer().getInstance(ValueStackFactory.class).createValueStack(); ActionContext ctx = new ActionContext(stack.getContext()); ActionContext.setContext(ctx); UtilTimerStack.push(timerKey); request = prepareDispatcherAndWrapRequest(request, response); ActionMapping mapping; try { mapping = actionMapper.getMapping(request, dispatcher.getConfigurationManager()); } catch (Exception ex) { log.error("error getting ActionMapping", ex); dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); return; } if (mapping == null) { // there is no action in this request, should we look for a static resource? String resourcePath = RequestUtils.getServletPath(request); if ("".equals(resourcePath) && null != request.getPathInfo()) { resourcePath = request.getPathInfo(); } if (staticResourceLoader.canHandle(resourcePath)) { staticResourceLoader.findStaticResource(resourcePath, request, response); } else { // this is a normal request, let it pass through chain.doFilter(request, response); } // The framework did its job here return; } dispatcher.serviceAction(request, response, servletContext, mapping); } finally { dispatcher.cleanUpRequest(request); try { ActionContextCleanUp.cleanUp(req); } finally { UtilTimerStack.pop(timerKey); } devModeOverride.remove(); } }
(Lib) TransformerException 4
              
// in java/org/apache/struts2/views/xslt/XSLTResult.java
protected Templates getTemplates(String path) throws TransformerException, IOException { String pathFromRequest = ServletActionContext.getRequest().getParameter("xslt.location"); if (pathFromRequest != null) path = pathFromRequest; if (path == null) throw new TransformerException("Stylesheet path is null"); Templates templates = templatesCache.get(path); if (noCache || (templates == null)) { synchronized (templatesCache) { URL resource = ServletActionContext.getServletContext().getResource(path); if (resource == null) { throw new TransformerException("Stylesheet " + path + " not found in resources."); } if (LOG.isDebugEnabled()) { LOG.debug("Preparing XSLT stylesheet templates: " + path); } TransformerFactory factory = TransformerFactory.newInstance(); factory.setURIResolver(getURIResolver()); templates = factory.newTemplates(new StreamSource(resource.openStream())); templatesCache.put(path, templates); } } return templates; }
// in java/org/apache/struts2/views/xslt/ServletURIResolver.java
public Source resolve(String href, String base) throws TransformerException { log.debug("ServletURIResolver resolve(): href=" + href + ", base=" + base); if (href.startsWith(PROTOCOL)) { String res = href.substring(PROTOCOL.length()); log.debug("Resolving resource <" + res + ">"); InputStream is = sc.getResourceAsStream(res); if (is == null) { throw new TransformerException( "Resource " + res + " not found in resources."); } return new StreamSource(is); } throw new TransformerException( "Cannot handle procotol of resource " + href); }
0 5
              
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void execute(ActionInvocation invocation) throws Exception { long startTime = System.currentTimeMillis(); String location = getStylesheetLocation(); if (parse) { ValueStack stack = ActionContext.getContext().getValueStack(); location = TextParseUtil.translateVariables(location, stack); } try { HttpServletResponse response = ServletActionContext.getResponse(); PrintWriter writer = response.getWriter(); // Create a transformer for the stylesheet. Templates templates = null; Transformer transformer; if (location != null) { templates = getTemplates(location); transformer = templates.newTransformer(); } else transformer = TransformerFactory.newInstance().newTransformer(); transformer.setURIResolver(getURIResolver()); transformer.setErrorListener(new ErrorListener() { public void error(TransformerException exception) throws TransformerException { throw new StrutsException("Error transforming result", exception); } public void fatalError(TransformerException exception) throws TransformerException { throw new StrutsException("Fatal error transforming result", exception); } public void warning(TransformerException exception) throws TransformerException { if (LOG.isWarnEnabled()) { LOG.warn(exception.getMessage(), exception); } } }); String mimeType; if (templates == null) mimeType = "text/xml"; // no stylesheet, raw xml else mimeType = templates.getOutputProperties().getProperty(OutputKeys.MEDIA_TYPE); if (mimeType == null) { // guess (this is a servlet, so text/html might be the best guess) mimeType = "text/html"; } response.setContentType(mimeType); Object result = invocation.getAction(); if (exposedValue != null) { ValueStack stack = invocation.getStack(); result = stack.findValue(exposedValue); } Source xmlSource = getDOMSourceForStack(result); // Transform the source XML to System.out. if (LOG.isDebugEnabled()) { LOG.debug("xmlSource = " + xmlSource); } transformer.transform(xmlSource, new StreamResult(writer)); writer.flush(); // ...and flush... if (LOG.isDebugEnabled()) { LOG.debug("Time:" + (System.currentTimeMillis() - startTime) + "ms"); } } catch (Exception e) { LOG.error("Unable to render XSLT Template, '" + location + "'", e); throw e; } }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void error(TransformerException exception) throws TransformerException { throw new StrutsException("Error transforming result", exception); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void fatalError(TransformerException exception) throws TransformerException { throw new StrutsException("Fatal error transforming result", exception); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void warning(TransformerException exception) throws TransformerException { if (LOG.isWarnEnabled()) { LOG.warn(exception.getMessage(), exception); } }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
protected Templates getTemplates(String path) throws TransformerException, IOException { String pathFromRequest = ServletActionContext.getRequest().getParameter("xslt.location"); if (pathFromRequest != null) path = pathFromRequest; if (path == null) throw new TransformerException("Stylesheet path is null"); Templates templates = templatesCache.get(path); if (noCache || (templates == null)) { synchronized (templatesCache) { URL resource = ServletActionContext.getServletContext().getResource(path); if (resource == null) { throw new TransformerException("Stylesheet " + path + " not found in resources."); } if (LOG.isDebugEnabled()) { LOG.debug("Preparing XSLT stylesheet templates: " + path); } TransformerFactory factory = TransformerFactory.newInstance(); factory.setURIResolver(getURIResolver()); templates = factory.newTemplates(new StreamSource(resource.openStream())); templatesCache.put(path, templates); } } return templates; }
// in java/org/apache/struts2/views/xslt/ServletURIResolver.java
public Source resolve(String href, String base) throws TransformerException { log.debug("ServletURIResolver resolve(): href=" + href + ", base=" + base); if (href.startsWith(PROTOCOL)) { String res = href.substring(PROTOCOL.length()); log.debug("Resolving resource <" + res + ">"); InputStream is = sc.getResourceAsStream(res); if (is == null) { throw new TransformerException( "Resource " + res + " not found in resources."); } return new StreamSource(is); } throw new TransformerException( "Cannot handle procotol of resource " + href); }
(Lib) IndexOutOfBoundsException 2
              
// in java/org/apache/struts2/components/IteratorComponent.java
public Object next() { if (hasNext()) { int nextIndex = peekNextIndex(); currentIndex += step; return value != null ? values.get(nextIndex) : nextIndex; } else { throw new IndexOutOfBoundsException("Index " + ( currentIndex + step) + " must be less than or equal to " + end); } }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(byte data[], int offset, int length) throws IOException { if (data == null) { throw new NullPointerException(); } if (offset < 0 || offset + length > data.length || length < 0) { throw new IndexOutOfBoundsException(); } if (closed) { throw new IOException("Stream closed"); } if (index + length > blockSize) { do { if (index == blockSize) { addBuffer(); } int copyLength = blockSize - index; if (length < copyLength) { copyLength = length; } System.arraycopy(data, offset, buffer, index, copyLength); offset += copyLength; index += copyLength; length -= copyLength; } while (length > 0); } else { System.arraycopy(data, offset, buffer, index, length); index += length; } }
0 0
(Lib) ResourceNotFoundException 2
              
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
public synchronized InputStream getResourceStream(String name) throws ResourceNotFoundException { if ((name == null) || (name.length() == 0)) { throw new ResourceNotFoundException("No template name provided"); } if (name.startsWith("/")) { name = name.substring(1); } try { return ClassLoaderUtil.getResourceAsStream(name, StrutsResourceLoader.class); } catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); } }
1
              
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); }
3
              
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { // get the bean ValueStack stack = (ValueStack) ctx.get("stack"); HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE); Component bean = getBean(stack, req, res); Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); // get the parameters Map params = createPropertyMap(ctx, node); bean.copyParams(params); //bean.addAllParameters(params); bean.start(writer); if (getType() == BLOCK) { Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1); body.render(ctx, writer); } bean.end(writer, ""); return true; }
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
public synchronized InputStream getResourceStream(String name) throws ResourceNotFoundException { if ((name == null) || (name.length() == 0)) { throw new ResourceNotFoundException("No template name provided"); } if (name.startsWith("/")) { name = name.substring(1); } try { return ClassLoaderUtil.getResourceAsStream(name, StrutsResourceLoader.class); } catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); } }
// in java/org/apache/struts2/util/VelocityStrutsUtil.java
public String evaluate(String expression) throws IOException, ResourceNotFoundException, MethodInvocationException, ParseErrorException { CharArrayWriter writer = new CharArrayWriter(); velocityEngine.evaluate(ctx, writer, "Error parsing " + expression, expression); return writer.toString(); }
(Lib) NullPointerException 1
              
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(byte data[], int offset, int length) throws IOException { if (data == null) { throw new NullPointerException(); } if (offset < 0 || offset + length > data.length || length < 0) { throw new IndexOutOfBoundsException(); } if (closed) { throw new IOException("Stream closed"); } if (index + length > blockSize) { do { if (index == blockSize) { addBuffer(); } int copyLength = blockSize - index; if (length < copyLength) { copyLength = length; } System.arraycopy(data, offset, buffer, index, copyLength); offset += copyLength; index += copyLength; length -= copyLength; } while (length > 0); } else { System.arraycopy(data, offset, buffer, index, length); index += length; } }
0 0
(Lib) ParseErrorException 1
              
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
protected void putProperty(Map propertyMap, InternalContextAdapter contextAdapter, Node node) throws ParseErrorException, MethodInvocationException { // node.value uses the StrutsValueStack to evaluate the directive's value parameter String param = node.value(contextAdapter).toString(); int idx = param.indexOf("="); if (idx != -1) { String property = param.substring(0, idx); String value = param.substring(idx + 1); propertyMap.put(property, value); } else { throw new ParseErrorException("#" + this.getName() + " arguments must include an assignment operator! For example #tag( Component \"template=mytemplate\" ). #tag( TextField \"mytemplate\" ) is illegal!"); } }
0 4
              
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { // get the bean ValueStack stack = (ValueStack) ctx.get("stack"); HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE); Component bean = getBean(stack, req, res); Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); // get the parameters Map params = createPropertyMap(ctx, node); bean.copyParams(params); //bean.addAllParameters(params); bean.start(writer); if (getType() == BLOCK) { Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1); body.render(ctx, writer); } bean.end(writer, ""); return true; }
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
protected Map createPropertyMap(InternalContextAdapter contextAdapter, Node node) throws ParseErrorException, MethodInvocationException { Map propertyMap; int children = node.jjtGetNumChildren(); if (getType() == BLOCK) { children--; } // Velocity supports an on-the-fly Map-definition syntax that leads // to more readable and faster code: // // #url({'id':'url', 'action':'MyAction'}) // // We support this syntax by checking for a single Map argument // to any directive and using that as the property map instead // of building one from individual name-value pair strings. Node firstChild = null; Object firstValue = null; if(children == 1 && null != (firstChild = node.jjtGetChild(0)) && null != (firstValue = firstChild.value(contextAdapter)) && firstValue instanceof Map) { propertyMap = (Map)firstValue; } else { propertyMap = new HashMap(); for (int index = 0, length = children; index < length; index++) { this.putProperty(propertyMap, contextAdapter, node.jjtGetChild(index)); } } return propertyMap; }
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
protected void putProperty(Map propertyMap, InternalContextAdapter contextAdapter, Node node) throws ParseErrorException, MethodInvocationException { // node.value uses the StrutsValueStack to evaluate the directive's value parameter String param = node.value(contextAdapter).toString(); int idx = param.indexOf("="); if (idx != -1) { String property = param.substring(0, idx); String value = param.substring(idx + 1); propertyMap.put(property, value); } else { throw new ParseErrorException("#" + this.getName() + " arguments must include an assignment operator! For example #tag( Component \"template=mytemplate\" ). #tag( TextField \"mytemplate\" ) is illegal!"); } }
// in java/org/apache/struts2/util/VelocityStrutsUtil.java
public String evaluate(String expression) throws IOException, ResourceNotFoundException, MethodInvocationException, ParseErrorException { CharArrayWriter writer = new CharArrayWriter(); velocityEngine.evaluate(ctx, writer, "Error parsing " + expression, expression); return writer.toString(); }
(Lib) RuntimeException 1
              
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void writeTo(JspWriter out, String encoding) throws IOException { try { writeTo((Writer) out, encoding); } catch (IOException e) { writeToFile(); throw e; } catch (Throwable e) { writeToFile(); throw new RuntimeException(e); } }
1
              
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (Throwable e) { writeToFile(); throw new RuntimeException(e); }
0
Explicit thrown (throw new...): 122/199
Explicit thrown ratio: 61.3%
Builder thrown ratio: 33.2%
Variable thrown ratio: 6%
Checked Runtime Total
Domain 0 0 0
Lib 6 55 61
Total 6 55

Caught Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be caught, and it happens that the catch block contains a throw (e.g. for wrapping a low-level exception). Hovering over a number triggers showing code snippets from the application code.

Type Exception Caught
(directly)
Caught
with Thrown
(Lib) Exception 51
            
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (Exception ex) { LOG.error("Unable to create debugging console", ex); }
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (Exception ex) { LOG.error("Unable to create debugging console", ex); }
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (Exception e) { LOG.error(e.toString(), e); }
// in java/org/apache/struts2/interceptor/debugging/ObjectToHTMLWriter.java
catch (Exception e) { return true; }
// in java/org/apache/struts2/interceptor/debugging/ObjectToHTMLWriter.java
catch (Exception e) { return true; }
// in java/org/apache/struts2/interceptor/BackgroundProcess.java
catch (Exception e) { exception = e; }
// in java/org/apache/struts2/interceptor/BackgroundProcess.java
catch (Exception e) { exception = e; }
// in java/org/apache/struts2/config/DefaultSettings.java
catch (Exception e) { log.warn("DefaultSettings: Could not find or error in struts.properties", e); }
// in java/org/apache/struts2/config/DefaultSettings.java
catch (Exception e) { log.error("DefaultSettings: Could not find " + name + ".properties. Skipping."); }
// in java/org/apache/struts2/config/Settings.java
catch (Exception e) { LOG.error("Settings: Could not instantiate the struts.configuration object, substituting the default implementation.", e); }
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (Exception e) { LOG.error("Could not find messages file " + name + ".properties. Skipping"); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); }
// in java/org/apache/struts2/components/I18n.java
catch (Exception e) { String msg = "Could not find the bundle " + name; throw new StrutsException(msg, e); }
// in java/org/apache/struts2/components/Date.java
catch (Exception e) { LOG.error("Could not convert object with key '" + name + "' to a java.util.Date instance"); // bad date, return a blank instead ? msg = ""; }
// in java/org/apache/struts2/components/template/JspTemplateEngine.java
catch (Exception e) { if (exception == null) { exception = e; } }
// in java/org/apache/struts2/components/Anchor.java
catch (Exception e) { LOG.error("error when rendering", e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to put request parameters (" + urlComponent.getHttpServletRequest().getQueryString() + ") into parameter map.", e); } }
// in java/org/apache/struts2/components/Number.java
catch (Exception e) { LOG.error("Could not convert object with key [" + name + "] to a java.lang.Number instance"); }
// in java/org/apache/struts2/components/Number.java
catch (Exception e) { LOG.error("Could not find [" + NUMBERTAG_PROPERTY + "] on the stack!", e); }
// in java/org/apache/struts2/components/Component.java
catch (Exception e) { problem = e; }
// in java/org/apache/struts2/components/Debug.java
catch (Exception e) { throw new StrutsException("Caught an exception while getting the property values of " + o, e); }
// in java/org/apache/struts2/components/UIBean.java
catch (Exception e) { throw new StrutsException(e); }
// in java/org/apache/struts2/components/Bean.java
catch (Exception e) { LOG.error("Could not instantiate bean", e); return false;
// in java/org/apache/struts2/components/ClosingUIBean.java
catch (Exception e) { LOG.error("Could not open template", e); e.printStackTrace(); }
// in java/org/apache/struts2/components/Include.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to url-encode "+values.get(i).toString()+", it will be ignored");
// in java/org/apache/struts2/components/Include.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Exception thrown during include of " + result, e); } }
// in java/org/apache/struts2/components/ActionComponent.java
catch (Exception e) { String message = "Could not execute action: " + namespace + "/" + actualName; LOG.error(message, e); if (rethrowException) { throw new StrutsException(message, e); } }
// in java/org/apache/struts2/components/Submit.java
catch (Exception e) { LOG.error("error when rendering", e); }
// in java/org/apache/struts2/views/jsp/IteratorTag.java
catch (Exception e) { throw new JspException(e.getMessage()); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
catch (Exception e) { LOG.error("Unable to render XSLT Template, '" + location + "'", e); throw e; }
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (Exception e) { if (e instanceof InvocationTargetException) e = (Exception) ((InvocationTargetException) e).getTargetException(); log.error("Cannot access bean property: "+propertyName, e); continue; }
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (Exception ex) { // Could not encode the URL for some reason // Use it unchanged result = link.toString(); }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Warning. " + e.getClass().getName() + " caught while attempting to instantiate a chained VelocityContext, " + className + " -- skipping"); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); }
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch(Exception e) { // catch any exception that may occurred during destroy() and log it LOG.error("exception occurred while destroying ObjectFactory ["+objectFactory+"]", e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception e) { sendError(request, response, context, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception e) { LOG.error("Error setting character encoding to '" + encoding + "' - ignoring.", e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception exp) { try { response.sendError(code, "Unable to show problem report: " + exp); } catch (IOException ex) { // we're already sending an error, not much else we can do if more stuff breaks } }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (Exception e) { log.warn("Invalid If-Modified-Since header value: '" + request.getHeader("If-Modified-Since") + "', ignoring"); }
// in java/org/apache/struts2/dispatcher/VelocityResult.java
catch (Exception e) { LOG.error("Unable to render Velocity Template, '" + finalLocation + "'", e); throw e; }
// in java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to determine parameters from the url", e); } }
// in java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Cannot determine url parameters", e); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (Exception ex) { dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (Exception ex) { log.error("error getting ActionMapping", ex); dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); return; }
// in java/org/apache/struts2/util/IteratorGenerator.java
catch(Exception e) { // make sure things, goes on, we just ignore the bad ones if (LOG.isWarnEnabled()) { LOG.warn("unable to convert ["+token+"], skipping this token, it will not appear in the generated iterator", e); } }
// in java/org/apache/struts2/util/SortIteratorFilter.java
catch (Exception e) { LoggerFactory.getLogger(SortIteratorFilter.class.getName()).warn("Error creating sort iterator.", e); return ERROR; }
// in java/org/apache/struts2/util/StrutsUtil.java
catch (Exception e) { e.printStackTrace(); throw e; }
// in java/org/apache/struts2/util/SubsetIteratorFilter.java
catch(Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("decider ["+decider+"] encountered an error while decide adding element ["+element+"], element will be ignored, it will not appeared in subseted iterator", e); } return false; }
13
            
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); }
// in java/org/apache/struts2/components/I18n.java
catch (Exception e) { String msg = "Could not find the bundle " + name; throw new StrutsException(msg, e); }
// in java/org/apache/struts2/components/Debug.java
catch (Exception e) { throw new StrutsException("Caught an exception while getting the property values of " + o, e); }
// in java/org/apache/struts2/components/UIBean.java
catch (Exception e) { throw new StrutsException(e); }
// in java/org/apache/struts2/components/ActionComponent.java
catch (Exception e) { String message = "Could not execute action: " + namespace + "/" + actualName; LOG.error(message, e); if (rethrowException) { throw new StrutsException(message, e); } }
// in java/org/apache/struts2/views/jsp/IteratorTag.java
catch (Exception e) { throw new JspException(e.getMessage()); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
catch (Exception e) { LOG.error("Unable to render XSLT Template, '" + location + "'", e); throw e; }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); }
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); }
// in java/org/apache/struts2/dispatcher/VelocityResult.java
catch (Exception e) { LOG.error("Unable to render Velocity Template, '" + finalLocation + "'", e); throw e; }
// in java/org/apache/struts2/util/StrutsUtil.java
catch (Exception e) { e.printStackTrace(); throw e; }
(Lib) IOException 33
            
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (IOException ex) { ex.printStackTrace(); }
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (IOException ex) { ex.printStackTrace(); }
// in java/org/apache/struts2/config/PropertiesSettings.java
catch (IOException e) { throw new StrutsException("Could not load " + name + ".properties:" + e, e); }
// in java/org/apache/struts2/config/PropertiesSettings.java
catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/components/Date.java
catch (IOException e) { LOG.error("Could not write out Date tag", e); }
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (IOException e) { LOG.error("Could not load " + propName, e); }
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/components/template/VelocityTemplateEngine.java
catch (IOException e) { if (exception == null) { exception = e; } }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
catch (IOException e) { // FileNotFoundException is anticipated - report the first IOException if no template found if (exception == null) { exception = e; } }
// in java/org/apache/struts2/components/Text.java
catch (IOException e) { LOG.error("Could not write out Text tag", e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Number.java
catch (IOException e) { LOG.error("Could not write out Number tag", e); }
// in java/org/apache/struts2/components/Component.java
catch (IOException e) { throw new StrutsException("IOError while writing the body: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Property.java
catch (IOException e) { if (LOG.isInfoEnabled()) { LOG.info("Could not print out value '" + value + "'", e); } }
// in java/org/apache/struts2/components/ActionComponent.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("error while trying to flush writer ", e);
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (IOException e) { LOG.error("Invalid template path specified: " + e.getMessage(), e); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (IOException e) { LOG.error("Error while loading freemarker settings from /freemarker.properties", e); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to load velocity configuration " + resourceLocation, e); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (IOException e) { }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (IOException e) { if(LOG.isErrorEnabled()){ LOG.error("Cannot write uploaded empty file to disk: " + storeLocation.getAbsolutePath(),e); } }
// in java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
catch (IOException e) { addError("Cannot parse request: "+e.toString()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IOException e) { logMessage = "Could not find create multipart save directory '"+multipartSaveDir.toString()+"'."; }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception exp) { try { response.sendError(code, "Unable to show problem report: " + exp); } catch (IOException ex) { // we're already sending an error, not much else we can do if more stuff breaks } }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IOException ex) { // we're already sending an error, not much else we can do if more stuff breaks }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IOException e1) { // we're already sending an error, not much else we can do if more stuff breaks }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (IOException ex) { // just ignore it continue; }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("Cannot clean up the request, some files can still remain in #0 after upload!", e, StrutsConstants.STRUTS_MULTIPART_SAVEDIR); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (IOException e) { writeToFile(); throw e; }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (IOException e) { // Ignore }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (IOException e) { // Ignore }
7
            
// in java/org/apache/struts2/config/PropertiesSettings.java
catch (IOException e) { throw new StrutsException("Could not load " + name + ".properties:" + e, e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Component.java
catch (IOException e) { throw new StrutsException("IOError while writing the body: " + e.getMessage(), e); }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (IOException e) { writeToFile(); throw e; }
(Lib) ClassNotFoundException 8
            
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
catch (ClassNotFoundException e) { // this is OK -- this just means JSP isn't even being used here, which is perfectly fine. // we need this class in environments that use JSP to know when to wrap the writer // and ignore flush() calls. In JSP, it is illegal for a BodyContent writer to be flushed(), // so we have to take caution here. }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (ClassNotFoundException e) { // this is OK, we'll just move on }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to locate provider class: "+cname, e); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (ClassNotFoundException e) { System.err.println("Unable to locate logger factory class: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( ClassNotFoundException e ) { System.err.println("Unable to locate logger factory class: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (ClassNotFoundException e) { System.err.println("Unable to locate logger factory class: " + factoryName + ", using default"); e.printStackTrace(); }
3
            
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to locate provider class: "+cname, e); }
(Lib) IllegalAccessException 6
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IllegalAccessException e) { throw new ConfigurationException("Unable to access provider: "+cname, e); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (IllegalAccessException e) { System.err.println("Unable to access logger factory: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( IllegalAccessException e ) { System.err.println("Unable to access logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IllegalAccessException e) { System.err.println("Unable to access logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
3
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IllegalAccessException e) { throw new ConfigurationException("Unable to access provider: "+cname, e); }
(Lib) InstantiationException 6
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (InstantiationException e) { throw new ConfigurationException("Unable to instantiate provider: "+cname, e); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (InstantiationException e) { System.err.println("Unable to instantiate logger factory: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( InstantiationException e ) { System.err.println("Unable to instantiate logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (InstantiationException e) { System.err.println("Unable to instantiate logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
3
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (InstantiationException e) { throw new ConfigurationException("Unable to instantiate provider: "+cname, e); }
(Lib) IllegalArgumentException 5
            
// in java/org/apache/struts2/config/DefaultSettings.java
catch (IllegalArgumentException e) { // Assume it's OK, since IllegalArgumentException is thrown // when Settings is unable to find a certain setting, // like the struts.custom.properties, which is commented out }
// in java/org/apache/struts2/config/Settings.java
catch (IllegalArgumentException ex) { // ignore }
// in java/org/apache/struts2/config/DelegatingSettings.java
catch (IllegalArgumentException ex) { e = ex; // Try next delegate }
// in java/org/apache/struts2/config/DelegatingSettings.java
catch (IllegalArgumentException ex) { e = ex; // Try next delegate }
// in java/org/apache/struts2/components/Number.java
catch (IllegalArgumentException iae) { LOG.error("Could not recognise a currency of [" + currency + "]"); }
0
(Lib) NumberFormatException 4
            
// in java/org/apache/struts2/views/jsp/iterator/IteratorGeneratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+startObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/dispatcher/StreamResult.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e); } }
0
(Lib) UnsupportedEncodingException 4
            
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); } return translatedInput; }
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); } return translatedInput; }
// in java/org/apache/struts2/dispatcher/StrutsResultSupport.java
catch(UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("error while trying to encode ["+parsedValue+"]", e); } }
// in java/org/apache/struts2/util/StrutsUtil.java
catch (UnsupportedEncodingException e) { return s; }
0
(Lib) NoSuchMethodException 3
            
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e) { // hmm -- OK, try doXxx instead try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1); method = actionClass.getMethod(altMethodName, new Class[0]); } catch (NoSuchMethodException e1) { // throw the original one throw e; } }
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e1) { // throw the original one throw e; }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (NoSuchMethodException e1) { throw new StrutsException("Adapter class: " + adapterClass + " does not have a no-args consructor."); }
2
            
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e) { // hmm -- OK, try doXxx instead try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1); method = actionClass.getMethod(altMethodName, new Class[0]); } catch (NoSuchMethodException e1) { // throw the original one throw e; } }
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e1) { // throw the original one throw e; }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (NoSuchMethodException e1) { throw new StrutsException("Adapter class: " + adapterClass + " does not have a no-args consructor."); }
(Lib) NullPointerException 2
            
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (NullPointerException npe) { // in case this was used outside the lifecycle of struts servlet LOG.debug("internal toolbox context ignored"); }
// in java/org/apache/struts2/util/AttributeMap.java
catch (NullPointerException npe){ return null; }
0
(Lib) ParseException 2
            
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
catch (ParseException e) { // template was found but was invalid - always report this. exception = e; break; }
// in java/org/apache/struts2/util/DateFormatter.java
catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); }
1
            
// in java/org/apache/struts2/util/DateFormatter.java
catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); }
(Lib) TemplateException 2
            
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (TemplateException e) { LOG.error("Cannot load freemarker configuration: ",e); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (TemplateException e) { LOG.error("Error while loading freemarker settings from /freemarker.properties", e); }
0
(Lib) TemplateModelException 2
            
// in java/org/apache/struts2/views/freemarker/tags/TagModel.java
catch (TemplateModelException e) { LOG.error("failed to unwrap [" + value + "] it will be ignored", e); }
// in java/org/apache/struts2/views/freemarker/tags/TagModel.java
catch (TemplateModelException e) { LOG.error("There was a problem converting a SimpleSequence to a list", e); }
0
(Lib) CloneNotSupportedException 1
            
// in java/org/apache/struts2/components/template/Template.java
catch (CloneNotSupportedException e) { // do nothing }
0
(Lib) ConfigurationException 1
            
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ConfigurationException e) { // WW-2874 Only log error if in devMode if(devMode) { String reqStr = request.getRequestURI(); if (request.getQueryString() != null) { reqStr = reqStr + "?" + request.getQueryString(); } LOG.error("Could not find action or result\n" + reqStr, e); } else { if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); }
0
(Lib) FileNotFoundException 1
            
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (FileNotFoundException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to find file in filesystem [" + propFile.getAbsolutePath() + "]"); } return null; }
0
(Lib) FileUploadException 1
            
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (FileUploadException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to parse request", e); } errors.add(e.getMessage()); }
0
(Lib) IllegalStateException 1
            
// in java/org/apache/struts2/util/TokenHelper.java
catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); }
1
            
// in java/org/apache/struts2/util/TokenHelper.java
catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); }
(Lib) IntrospectionException 1
            
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); }
1
            
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); }
(Lib) MalformedURLException 1
            
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); }
1
            
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); }
(Lib) NoClassDefFoundError 1
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); }
1
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); }
(Lib) OgnlException 1
            
// in java/org/apache/struts2/views/jsp/ui/OgnlTool.java
catch (OgnlException e) { return null; }
0
(Lib) ServletException 1
            
// in java/org/apache/struts2/dispatcher/FilterDispatcherCompatWeblogic61.java
catch (ServletException se) { LOG.error("Couldn't set the filter configuration in this filter", se); }
0
(Lib) Throwable 1
            
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (Throwable e) { writeToFile(); throw new RuntimeException(e); }
1
            
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (Throwable e) { writeToFile(); throw new RuntimeException(e); }
(Lib) UnsupportedOperationException 1
            
// in java/org/apache/struts2/config/DelegatingSettings.java
catch (UnsupportedOperationException ex) { e = ex; // Try next delegate }
0

Exception Recast Summary

There is a common practice of throwing exceptions from within a catch block (e.g. for wrapping a low-level exception). The following table summarizes the usage of this practice in the application. The last column gives the number of times it happens for a pair of exceptions. The graph below the table graphically renders the same information. For a given node, its color represents its origin (blue means library exception, orange means domain exception); the left-most number is the number of times it is thrown, the right-most is the number of times it is caught.

Catch Throw
(Lib) Exception
(Lib) ConfigurationException
(Domain) StrutsException
(Lib) JspException
(Lib) ResourceNotFoundException
Unknown
2
                    
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); }
6
                    
// in java/org/apache/struts2/components/I18n.java
catch (Exception e) { String msg = "Could not find the bundle " + name; throw new StrutsException(msg, e); }
// in java/org/apache/struts2/components/Debug.java
catch (Exception e) { throw new StrutsException("Caught an exception while getting the property values of " + o, e); }
// in java/org/apache/struts2/components/UIBean.java
catch (Exception e) { throw new StrutsException(e); }
// in java/org/apache/struts2/components/ActionComponent.java
catch (Exception e) { String message = "Could not execute action: " + namespace + "/" + actualName; LOG.error(message, e); if (rethrowException) { throw new StrutsException(message, e); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); }
1
                    
// in java/org/apache/struts2/views/jsp/IteratorTag.java
catch (Exception e) { throw new JspException(e.getMessage()); }
1
                    
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); }
3
                    
// in java/org/apache/struts2/views/xslt/XSLTResult.java
catch (Exception e) { LOG.error("Unable to render XSLT Template, '" + location + "'", e); throw e; }
// in java/org/apache/struts2/dispatcher/VelocityResult.java
catch (Exception e) { LOG.error("Unable to render Velocity Template, '" + finalLocation + "'", e); throw e; }
// in java/org/apache/struts2/util/StrutsUtil.java
catch (Exception e) { e.printStackTrace(); throw e; }
(Lib) IOException
(Domain) StrutsException
(Lib) ServletException
Unknown
4
                    
// in java/org/apache/struts2/config/PropertiesSettings.java
catch (IOException e) { throw new StrutsException("Could not load " + name + ".properties:" + e, e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Component.java
catch (IOException e) { throw new StrutsException("IOError while writing the body: " + e.getMessage(), e); }
2
                    
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); }
1
                    
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (IOException e) { writeToFile(); throw e; }
(Lib) NoSuchMethodException
(Domain) StrutsException
Unknown
1
                    
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (NoSuchMethodException e1) { throw new StrutsException("Adapter class: " + adapterClass + " does not have a no-args consructor."); }
1
                    
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e) { // hmm -- OK, try doXxx instead try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1); method = actionClass.getMethod(altMethodName, new Class[0]); } catch (NoSuchMethodException e1) { // throw the original one throw e; } }
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e1) { // throw the original one throw e; }
(Lib) MalformedURLException
(Lib) IOException
1
                    
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); }
(Lib) ClassNotFoundException
(Lib) ConfigurationException
3
                    
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to locate provider class: "+cname, e); }
(Lib) IllegalStateException
(Lib) IllegalArgumentException
1
                    
// in java/org/apache/struts2/util/TokenHelper.java
catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); }
(Lib) InstantiationException
(Lib) ConfigurationException
(Domain) StrutsException
2
                    
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (InstantiationException e) { throw new ConfigurationException("Unable to instantiate provider: "+cname, e); }
1
                    
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
(Lib) IllegalAccessException
(Lib) ConfigurationException
(Domain) StrutsException
2
                    
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IllegalAccessException e) { throw new ConfigurationException("Unable to access provider: "+cname, e); }
1
                    
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
(Lib) NoClassDefFoundError
(Lib) ConfigurationException
1
                    
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); }
(Lib) ParseException
(Lib) IllegalArgumentException
1
                    
// in java/org/apache/struts2/util/DateFormatter.java
catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); }
(Lib) IntrospectionException
(Domain) StrutsException
1
                    
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); }
(Lib) Throwable
(Lib) RuntimeException
1
                    
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (Throwable e) { writeToFile(); throw new RuntimeException(e); }

Caught / Thrown Exception

Not all exceptions are thrown AND caught in the same project. The following table gives the exceptions types with respect to this. The lower left hand side sell lists all exceptions thrown but not caught (prevalent for libraries), the upper right-hand side lists all exceptions caught but not thrown (usually coming from external dependencies).

Thrown Not Thrown
Caught
Type Name
(Lib) IOException
(Lib) IllegalArgumentException
(Lib) UnsupportedOperationException
(Lib) ConfigurationException
(Lib) IllegalStateException
(Lib) ServletException
(Lib) NullPointerException
Type Name
(Lib) Exception
(Lib) NoSuchMethodException
(Lib) MalformedURLException
(Lib) ClassNotFoundException
(Lib) InstantiationException
(Lib) IllegalAccessException
(Lib) NoClassDefFoundError
(Lib) FileNotFoundException
(Lib) CloneNotSupportedException
(Lib) ParseException
(Lib) OgnlException
(Lib) NumberFormatException
(Lib) TemplateModelException
(Lib) TemplateException
(Lib) IntrospectionException
(Lib) UnsupportedEncodingException
(Lib) FileUploadException
(Lib) Throwable
Not caught
Type Name
(Domain) StrutsException
(Lib) IndexOutOfBoundsException
(Lib) JspException
(Lib) TransformerException
(Lib) ParseErrorException
(Lib) ResourceNotFoundException
(Lib) RuntimeException

Methods called in Catch and Finally Blocks

The following shows the methods that are called inside catch blocks (first column) and finally blocks (second column). For each method, we give the number of times it is called in a catch block (second sub-column), and the total number of calls (third sub-column). If the method name is red, it means that it is only called from catch/finally blocks. Hovering over a number triggers showing code snippets from the application code.

Catch Finally
Method Nbr Nbr total
error 37
                  
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (Exception ex) { LOG.error("Unable to create debugging console", ex); }
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (Exception ex) { LOG.error("Unable to create debugging console", ex); }
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (Exception e) { LOG.error(e.toString(), e); }
// in java/org/apache/struts2/config/DefaultSettings.java
catch (Exception e) { log.error("DefaultSettings: Could not find " + name + ".properties. Skipping."); }
// in java/org/apache/struts2/config/Settings.java
catch (Exception e) { LOG.error("Settings: Could not instantiate the struts.configuration object, substituting the default implementation.", e); }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (Exception e) { LOG.error("Could not find messages file " + name + ".properties. Skipping"); }
// in java/org/apache/struts2/components/Date.java
catch (Exception e) { LOG.error("Could not convert object with key '" + name + "' to a java.util.Date instance"); // bad date, return a blank instead ? msg = ""; }
// in java/org/apache/struts2/components/Date.java
catch (IOException e) { LOG.error("Could not write out Date tag", e); }
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (IOException e) { LOG.error("Could not load " + propName, e); }
// in java/org/apache/struts2/components/Text.java
catch (IOException e) { LOG.error("Could not write out Text tag", e); }
// in java/org/apache/struts2/components/Anchor.java
catch (Exception e) { LOG.error("error when rendering", e); }
// in java/org/apache/struts2/components/Number.java
catch (IOException e) { LOG.error("Could not write out Number tag", e); }
// in java/org/apache/struts2/components/Number.java
catch (IllegalArgumentException iae) { LOG.error("Could not recognise a currency of [" + currency + "]"); }
// in java/org/apache/struts2/components/Number.java
catch (Exception e) { LOG.error("Could not convert object with key [" + name + "] to a java.lang.Number instance"); }
// in java/org/apache/struts2/components/Number.java
catch (Exception e) { LOG.error("Could not find [" + NUMBERTAG_PROPERTY + "] on the stack!", e); }
// in java/org/apache/struts2/components/Bean.java
catch (Exception e) { LOG.error("Could not instantiate bean", e); return false;
// in java/org/apache/struts2/components/ClosingUIBean.java
catch (Exception e) { LOG.error("Could not open template", e); e.printStackTrace(); }
// in java/org/apache/struts2/components/ActionComponent.java
catch (Exception e) { String message = "Could not execute action: " + namespace + "/" + actualName; LOG.error(message, e); if (rethrowException) { throw new StrutsException(message, e); } }
// in java/org/apache/struts2/components/Submit.java
catch (Exception e) { LOG.error("error when rendering", e); }
// in java/org/apache/struts2/views/freemarker/tags/TagModel.java
catch (TemplateModelException e) { LOG.error("failed to unwrap [" + value + "] it will be ignored", e); }
// in java/org/apache/struts2/views/freemarker/tags/TagModel.java
catch (TemplateModelException e) { LOG.error("There was a problem converting a SimpleSequence to a list", e); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (TemplateException e) { LOG.error("Cannot load freemarker configuration: ",e); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (IOException e) { LOG.error("Invalid template path specified: " + e.getMessage(), e); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (IOException e) { LOG.error("Error while loading freemarker settings from /freemarker.properties", e); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (TemplateException e) { LOG.error("Error while loading freemarker settings from /freemarker.properties", e); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
catch (Exception e) { LOG.error("Unable to render XSLT Template, '" + location + "'", e); throw e; }
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (Exception e) { if (e instanceof InvocationTargetException) e = (Exception) ((InvocationTargetException) e).getTargetException(); log.error("Cannot access bean property: "+propertyName, e); continue; }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (IOException e) { if(LOG.isErrorEnabled()){ LOG.error("Cannot write uploaded empty file to disk: " + storeLocation.getAbsolutePath(),e); } }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch(Exception e) { // catch any exception that may occurred during destroy() and log it LOG.error("exception occurred while destroying ObjectFactory ["+objectFactory+"]", e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ConfigurationException e) { // WW-2874 Only log error if in devMode if(devMode) { String reqStr = request.getRequestURI(); if (request.getQueryString() != null) { reqStr = reqStr + "?" + request.getQueryString(); } LOG.error("Could not find action or result\n" + reqStr, e); } else { if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception e) { LOG.error("Error setting character encoding to '" + encoding + "' - ignoring.", e); }
// in java/org/apache/struts2/dispatcher/VelocityResult.java
catch (Exception e) { LOG.error("Unable to render Velocity Template, '" + finalLocation + "'", e); throw e; }
// in java/org/apache/struts2/dispatcher/FilterDispatcherCompatWeblogic61.java
catch (ServletException se) { LOG.error("Couldn't set the filter configuration in this filter", se); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (Exception ex) { log.error("error getting ActionMapping", ex); dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); return; }
// in java/org/apache/struts2/util/TokenHelper.java
catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); }
51
warn 27
                  
// in java/org/apache/struts2/config/DefaultSettings.java
catch (Exception e) { log.warn("DefaultSettings: Could not find or error in struts.properties", e); }
// in java/org/apache/struts2/config/PropertiesSettings.java
catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (FileNotFoundException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to find file in filesystem [" + propFile.getAbsolutePath() + "]"); } return null; }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to put request parameters (" + urlComponent.getHttpServletRequest().getQueryString() + ") into parameter map.", e); } }
// in java/org/apache/struts2/components/Include.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to url-encode "+values.get(i).toString()+", it will be ignored");
// in java/org/apache/struts2/components/Include.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Exception thrown during include of " + result, e); } }
// in java/org/apache/struts2/components/ActionComponent.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("error while trying to flush writer ", e);
// in java/org/apache/struts2/views/jsp/iterator/IteratorGeneratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+startObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); } return translatedInput; }
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); } return translatedInput; }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Warning. " + e.getClass().getName() + " caught while attempting to instantiate a chained VelocityContext, " + className + " -- skipping"); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to load velocity configuration " + resourceLocation, e); } }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (FileUploadException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to parse request", e); } errors.add(e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ConfigurationException e) { // WW-2874 Only log error if in devMode if(devMode) { String reqStr = request.getRequestURI(); if (request.getQueryString() != null) { reqStr = reqStr + "?" + request.getQueryString(); } LOG.error("Could not find action or result\n" + reqStr, e); } else { if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (Exception e) { log.warn("Invalid If-Modified-Since header value: '" + request.getHeader("If-Modified-Since") + "', ignoring"); }
// in java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to determine parameters from the url", e); } }
// in java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Cannot determine url parameters", e); } }
// in java/org/apache/struts2/dispatcher/StreamResult.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("Cannot clean up the request, some files can still remain in #0 after upload!", e, StrutsConstants.STRUTS_MULTIPART_SAVEDIR); } }
// in java/org/apache/struts2/dispatcher/StrutsResultSupport.java
catch(UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("error while trying to encode ["+parsedValue+"]", e); } }
// in java/org/apache/struts2/util/IteratorGenerator.java
catch(Exception e) { // make sure things, goes on, we just ignore the bad ones if (LOG.isWarnEnabled()) { LOG.warn("unable to convert ["+token+"], skipping this token, it will not appear in the generated iterator", e); } }
// in java/org/apache/struts2/util/SortIteratorFilter.java
catch (Exception e) { LoggerFactory.getLogger(SortIteratorFilter.class.getName()).warn("Error creating sort iterator.", e); return ERROR; }
// in java/org/apache/struts2/util/SubsetIteratorFilter.java
catch(Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("decider ["+decider+"] encountered an error while decide adding element ["+element+"], element will be ignored, it will not appeared in subseted iterator", e); } return false; }
67
isWarnEnabled 24
                  
// in java/org/apache/struts2/config/PropertiesSettings.java
catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (FileNotFoundException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to find file in filesystem [" + propFile.getAbsolutePath() + "]"); } return null; }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to put request parameters (" + urlComponent.getHttpServletRequest().getQueryString() + ") into parameter map.", e); } }
// in java/org/apache/struts2/components/Include.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to url-encode "+values.get(i).toString()+", it will be ignored");
// in java/org/apache/struts2/components/Include.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Exception thrown during include of " + result, e); } }
// in java/org/apache/struts2/components/ActionComponent.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("error while trying to flush writer ", e);
// in java/org/apache/struts2/views/jsp/iterator/IteratorGeneratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+startObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); } return translatedInput; }
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); } return translatedInput; }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Warning. " + e.getClass().getName() + " caught while attempting to instantiate a chained VelocityContext, " + className + " -- skipping"); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to load velocity configuration " + resourceLocation, e); } }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (FileUploadException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to parse request", e); } errors.add(e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ConfigurationException e) { // WW-2874 Only log error if in devMode if(devMode) { String reqStr = request.getRequestURI(); if (request.getQueryString() != null) { reqStr = reqStr + "?" + request.getQueryString(); } LOG.error("Could not find action or result\n" + reqStr, e); } else { if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); }
// in java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to determine parameters from the url", e); } }
// in java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Cannot determine url parameters", e); } }
// in java/org/apache/struts2/dispatcher/StreamResult.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("Cannot clean up the request, some files can still remain in #0 after upload!", e, StrutsConstants.STRUTS_MULTIPART_SAVEDIR); } }
// in java/org/apache/struts2/dispatcher/StrutsResultSupport.java
catch(UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("error while trying to encode ["+parsedValue+"]", e); } }
// in java/org/apache/struts2/util/IteratorGenerator.java
catch(Exception e) { // make sure things, goes on, we just ignore the bad ones if (LOG.isWarnEnabled()) { LOG.warn("unable to convert ["+token+"], skipping this token, it will not appear in the generated iterator", e); } }
// in java/org/apache/struts2/util/SubsetIteratorFilter.java
catch(Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("decider ["+decider+"] encountered an error while decide adding element ["+element+"], element will be ignored, it will not appeared in subseted iterator", e); } return false; }
56
printStackTrace 16
                  
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (IOException ex) { ex.printStackTrace(); }
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (IOException ex) { ex.printStackTrace(); }
// in java/org/apache/struts2/components/ClosingUIBean.java
catch (Exception e) { LOG.error("Could not open template", e); e.printStackTrace(); }
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (InstantiationException e) { System.err.println("Unable to instantiate logger factory: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (IllegalAccessException e) { System.err.println("Unable to access logger factory: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (ClassNotFoundException e) { System.err.println("Unable to locate logger factory class: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( InstantiationException e ) { System.err.println("Unable to instantiate logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( IllegalAccessException e ) { System.err.println("Unable to access logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( ClassNotFoundException e ) { System.err.println("Unable to locate logger factory class: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (InstantiationException e) { System.err.println("Unable to instantiate logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IllegalAccessException e) { System.err.println("Unable to access logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (ClassNotFoundException e) { System.err.println("Unable to locate logger factory class: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/util/StrutsUtil.java
catch (Exception e) { e.printStackTrace(); throw e; }
18
getMessage 12
                  
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Component.java
catch (IOException e) { throw new StrutsException("IOError while writing the body: " + e.getMessage(), e); }
// in java/org/apache/struts2/views/jsp/IteratorTag.java
catch (Exception e) { throw new JspException(e.getMessage()); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (IOException e) { LOG.error("Invalid template path specified: " + e.getMessage(), e); }
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (FileUploadException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to parse request", e); } errors.add(e.getMessage()); }
// in java/org/apache/struts2/util/TokenHelper.java
catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); }
// in java/org/apache/struts2/util/DateFormatter.java
catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); }
15
println
9
                  
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (InstantiationException e) { System.err.println("Unable to instantiate logger factory: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (IllegalAccessException e) { System.err.println("Unable to access logger factory: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (ClassNotFoundException e) { System.err.println("Unable to locate logger factory class: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( InstantiationException e ) { System.err.println("Unable to instantiate logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( IllegalAccessException e ) { System.err.println("Unable to access logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( ClassNotFoundException e ) { System.err.println("Unable to locate logger factory class: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (InstantiationException e) { System.err.println("Unable to instantiate logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IllegalAccessException e) { System.err.println("Unable to access logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (ClassNotFoundException e) { System.err.println("Unable to locate logger factory class: " + factoryName + ", using default"); e.printStackTrace(); }
9
sendError 5
                  
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ConfigurationException e) { // WW-2874 Only log error if in devMode if(devMode) { String reqStr = request.getRequestURI(); if (request.getQueryString() != null) { reqStr = reqStr + "?" + request.getQueryString(); } LOG.error("Could not find action or result\n" + reqStr, e); } else { if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception e) { sendError(request, response, context, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception exp) { try { response.sendError(code, "Unable to show problem report: " + exp); } catch (IOException ex) { // we're already sending an error, not much else we can do if more stuff breaks } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (Exception ex) { dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (Exception ex) { log.error("error getting ActionMapping", ex); dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); return; }
11
toString 5
                  
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (Exception e) { LOG.error(e.toString(), e); }
// in java/org/apache/struts2/components/Include.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to url-encode "+values.get(i).toString()+", it will be ignored");
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (Exception ex) { // Could not encode the URL for some reason // Use it unchanged result = link.toString(); }
// in java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
catch (IOException e) { addError("Cannot parse request: "+e.toString()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IOException e) { logMessage = "Could not find create multipart save directory '"+multipartSaveDir.toString()+"'."; }
93
getName 4
                  
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Warning. " + e.getClass().getName() + " caught while attempting to instantiate a chained VelocityContext, " + className + " -- skipping"); } }
// in java/org/apache/struts2/util/SortIteratorFilter.java
catch (Exception e) { LoggerFactory.getLogger(SortIteratorFilter.class.getName()).warn("Error creating sort iterator.", e); return ERROR; }
58
getQueryString 3
                  
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to put request parameters (" + urlComponent.getHttpServletRequest().getQueryString() + ") into parameter map.", e); } }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ConfigurationException e) { // WW-2874 Only log error if in devMode if(devMode) { String reqStr = request.getRequestURI(); if (request.getQueryString() != null) { reqStr = reqStr + "?" + request.getQueryString(); } LOG.error("Could not find action or result\n" + reqStr, e); } else { if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); }
4
debug 2
                  
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (NullPointerException npe) { // in case this was used outside the lifecycle of struts servlet LOG.debug("internal toolbox context ignored"); }
100
getAbsolutePath
2
                  
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (FileNotFoundException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to find file in filesystem [" + propFile.getAbsolutePath() + "]"); } return null; }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (IOException e) { if(LOG.isErrorEnabled()){ LOG.error("Cannot write uploaded empty file to disk: " + storeLocation.getAbsolutePath(),e); } }
2
isErrorEnabled 2
                  
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (IOException e) { if(LOG.isErrorEnabled()){ LOG.error("Cannot write uploaded empty file to disk: " + storeLocation.getAbsolutePath(),e); } }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); }
3
substring 2
                  
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e) { // hmm -- OK, try doXxx instead try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1); method = actionClass.getMethod(altMethodName, new Class[0]); } catch (NoSuchMethodException e1) { // throw the original one throw e; } }
63
writeToFile
2
                  
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (IOException e) { writeToFile(); throw e; }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (Throwable e) { writeToFile(); throw new RuntimeException(e); }
2
ObjectFactoryDelegateFactory
1
                  
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
1
add 1
                  
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (FileUploadException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to parse request", e); } errors.add(e.getMessage()); }
94
addError 1
                  
// in java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
catch (IOException e) { addError("Cannot parse request: "+e.toString()); }
2
equals 1
                  
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
127
factory 1
                  
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
6
get 1
                  
// in java/org/apache/struts2/components/Include.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to url-encode "+values.get(i).toString()+", it will be ignored");
197
getClass 1
                  
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Warning. " + e.getClass().getName() + " caught while attempting to instantiate a chained VelocityContext, " + className + " -- skipping"); } }
70
getHeader 1
                  
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (Exception e) { log.warn("Invalid If-Modified-Since header value: '" + request.getHeader("If-Modified-Since") + "', ignoring"); }
2
getHttpServletRequest 1
                  
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to put request parameters (" + urlComponent.getHttpServletRequest().getQueryString() + ") into parameter map.", e); } }
9
getLogger 1
                  
// in java/org/apache/struts2/util/SortIteratorFilter.java
catch (Exception e) { LoggerFactory.getLogger(SortIteratorFilter.class.getName()).warn("Error creating sort iterator.", e); return ERROR; }
86
getMethod 1
                  
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e) { // hmm -- OK, try doXxx instead try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1); method = actionClass.getMethod(altMethodName, new Class[0]); } catch (NoSuchMethodException e1) { // throw the original one throw e; } }
18
getRequestURI 1
                  
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ConfigurationException e) { // WW-2874 Only log error if in devMode if(devMode) { String reqStr = request.getRequestURI(); if (request.getQueryString() != null) { reqStr = reqStr + "?" + request.getQueryString(); } LOG.error("Could not find action or result\n" + reqStr, e); } else { if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); }
8
getTargetException
1
                  
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (Exception e) { if (e instanceof InvocationTargetException) e = (Exception) ((InvocationTargetException) e).getTargetException(); log.error("Cannot access bean property: "+propertyName, e); continue; }
1
info 1
                  
// in java/org/apache/struts2/components/Property.java
catch (IOException e) { if (LOG.isInfoEnabled()) { LOG.info("Could not print out value '" + value + "'", e); } }
12
isDebugEnabled 1
                  
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
75
isInfoEnabled 1
                  
// in java/org/apache/struts2/components/Property.java
catch (IOException e) { if (LOG.isInfoEnabled()) { LOG.info("Could not print out value '" + value + "'", e); } }
9
toUpperCase 1
                  
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e) { // hmm -- OK, try doXxx instead try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1); method = actionClass.getMethod(altMethodName, new Class[0]); } catch (NoSuchMethodException e1) { // throw the original one throw e; } }
2
Method Nbr Nbr total
close 10
                  
// in java/org/apache/struts2/config/PropertiesSettings.java
finally { if(in != null) { try { in.close(); } catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } } } }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
finally { if (isTopTemplate && parentCharArrayWriter != null) { req.removeAttribute(PARENT_TEMPLATE_WRITER); parentCharArrayWriter.close(); } }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
finally { if (in != null) { try { in.close(); } catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } } } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
finally { if (in != null) { try { in.close(); } catch (IOException e) { } } }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
finally { is.close(); }
// in java/org/apache/struts2/dispatcher/StreamResult.java
finally { if (inputStream != null) inputStream.close(); if (oOutput != null) oOutput.close(); }
// in java/org/apache/struts2/dispatcher/PlainTextResult.java
finally { if (reader != null) reader.close(); if (writer != null) { writer.flush(); writer.close(); } }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
finally { if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e) { // Ignore } } }
23
pop 7
                  
// in java/org/apache/struts2/interceptor/StrutsConversionErrorInterceptor.java
finally { stack.pop(); }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
finally { stack.pop(); }
// in java/org/apache/struts2/components/Component.java
finally { stack.pop(); stack.pop(); }
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
finally { UtilTimerStack.pop(timerKey); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
finally { UtilTimerStack.pop(timerKey); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
finally { dispatcher.cleanUpRequest(request); try { ActionContextCleanUp.cleanUp(req); } finally { UtilTimerStack.pop(timerKey); } devModeOverride.remove(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
finally { UtilTimerStack.pop(timerKey); }
19
setContext 5
                  
// in java/org/apache/struts2/impl/StrutsActionProxy.java
finally { if (cleanupContext) ActionContext.setContext(previous); }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
finally { ActionContext.setContext(null); Dispatcher.setInstance(null); }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
finally { ActionContext.setContext(null); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
finally { ActionContext.setContext(null); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
finally { ActionContext.setContext(null); }
23
cleanup 4
                  
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
finally { init.cleanup(); }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
finally { init.cleanup(); }
// in java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
finally { init.cleanup(); }
// in java/org/apache/struts2/dispatcher/ng/listener/StrutsListener.java
finally { init.cleanup(); }
7
popComponentStack 4
                  
// in java/org/apache/struts2/components/Anchor.java
finally { popComponentStack(); }
// in java/org/apache/struts2/components/UIBean.java
finally { popComponentStack(); }
// in java/org/apache/struts2/components/ActionComponent.java
finally { popComponentStack(); }
// in java/org/apache/struts2/components/Submit.java
finally { popComponentStack(); }
5
cleanupRequest
3
                  
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
finally { prepare.cleanupRequest(request); }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
finally { prepare.cleanupRequest(request); }
// in java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
finally { prepare.cleanupRequest(request); }
3
cleanUp
2
                  
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
finally { int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue(); counterVal -= 1; request.setAttribute(COUNTER, Integer.valueOf(counterVal)); cleanUp(request); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
finally { dispatcher.cleanUpRequest(request); try { ActionContextCleanUp.cleanUp(req); } finally { UtilTimerStack.pop(timerKey); } devModeOverride.remove(); }
2
get 2
                  
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
finally { if (devMode && consoleEnabled) { final ActionContext ctx = ActionContext.getContext(); ctx.getSession().put(SESSION_KEY, ctx.get(ActionContext.VALUE_STACK)); } }
// in java/org/apache/struts2/util/AppendIteratorFilter.java
finally { if (iterators.size() > 0) { if (!((Iterator) iterators.get(0)).hasNext()) { iterators.remove(0); } } }
197
getContext 2
                  
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
finally { if (devMode && consoleEnabled) { final ActionContext ctx = ActionContext.getContext(); ctx.getSession().put(SESSION_KEY, ctx.get(ActionContext.VALUE_STACK)); } }
// in java/org/apache/struts2/components/ActionComponent.java
finally { req.removeAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION); // set the old stack back on the request req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); if (inv != null) { ActionContext.getContext().setActionInvocation(inv); } }
114
isWarnEnabled 2
                  
// in java/org/apache/struts2/config/PropertiesSettings.java
finally { if(in != null) { try { in.close(); } catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } } } }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
finally { if (in != null) { try { in.close(); } catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } } } }
56
put 2
                  
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
finally { if (devMode && consoleEnabled) { final ActionContext ctx = ActionContext.getContext(); ctx.getSession().put(SESSION_KEY, ctx.get(ActionContext.VALUE_STACK)); } }
// in java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java
finally { ctx.put("__requestWrapper.getAttribute", Boolean.FALSE); }
166
remove 2
                  
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
finally { dispatcher.cleanUpRequest(request); try { ActionContextCleanUp.cleanUp(req); } finally { UtilTimerStack.pop(timerKey); } devModeOverride.remove(); }
// in java/org/apache/struts2/util/AppendIteratorFilter.java
finally { if (iterators.size() > 0) { if (!((Iterator) iterators.get(0)).hasNext()) { iterators.remove(0); } } }
23
removeAttribute 2
                  
// in java/org/apache/struts2/components/ActionComponent.java
finally { req.removeAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION); // set the old stack back on the request req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); if (inv != null) { ActionContext.getContext().setActionInvocation(inv); } }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
finally { if (isTopTemplate && parentCharArrayWriter != null) { req.removeAttribute(PARENT_TEMPLATE_WRITER); parentCharArrayWriter.close(); } }
8
setAttribute 2
                  
// in java/org/apache/struts2/components/ActionComponent.java
finally { req.removeAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION); // set the old stack back on the request req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); if (inv != null) { ActionContext.getContext().setActionInvocation(inv); } }
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
finally { int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue(); counterVal -= 1; request.setAttribute(COUNTER, Integer.valueOf(counterVal)); cleanUp(request); }
40
size 2
                  
// in java/org/apache/struts2/util/AppendIteratorFilter.java
finally { if (iterators.size() > 0) { if (!((Iterator) iterators.get(0)).hasNext()) { iterators.remove(0); } } }
// in java/org/apache/struts2/util/MergeIteratorFilter.java
finally { idx = (idx + 1) % iterators.size(); }
59
warn 2
                  
// in java/org/apache/struts2/config/PropertiesSettings.java
finally { if(in != null) { try { in.close(); } catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } } } }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
finally { if (in != null) { try { in.close(); } catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } } } }
67
cleanUpRequest 1
                  
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
finally { dispatcher.cleanUpRequest(request); try { ActionContextCleanUp.cleanUp(req); } finally { UtilTimerStack.pop(timerKey); } devModeOverride.remove(); }
2
flush 1
                  
// in java/org/apache/struts2/dispatcher/PlainTextResult.java
finally { if (reader != null) reader.close(); if (writer != null) { writer.flush(); writer.close(); } }
16
getAttribute 1
                  
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
finally { int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue(); counterVal -= 1; request.setAttribute(COUNTER, Integer.valueOf(counterVal)); cleanUp(request); }
42
getSession 1
                  
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
finally { if (devMode && consoleEnabled) { final ActionContext ctx = ActionContext.getContext(); ctx.getSession().put(SESSION_KEY, ctx.get(ActionContext.VALUE_STACK)); } }
25
hasNext 1
                  
// in java/org/apache/struts2/util/AppendIteratorFilter.java
finally { if (iterators.size() > 0) { if (!((Iterator) iterators.get(0)).hasNext()) { iterators.remove(0); } } }
40
intValue 1
                  
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
finally { int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue(); counterVal -= 1; request.setAttribute(COUNTER, Integer.valueOf(counterVal)); cleanUp(request); }
9
postTemplateProcess
1
                  
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
finally { // Give subclasses a chance to hook into postprocessing postTemplateProcess(template, model); }
1
releasePageContext
1
                  
// in java/org/apache/struts2/dispatcher/VelocityResult.java
finally { if (usedJspFactory) { jspFactory.releasePageContext(pageContext); } }
1
setActionInvocation
1
                  
// in java/org/apache/struts2/components/ActionComponent.java
finally { req.removeAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION); // set the old stack back on the request req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); if (inv != null) { ActionContext.getContext().setActionInvocation(inv); } }
1
setInstance 1
                  
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
finally { ActionContext.setContext(null); Dispatcher.setInstance(null); }
6
tryCloseStream
1
                  
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
finally { tryCloseStream(is); }
1
unlock 1
                  
// in java/org/apache/struts2/interceptor/ScopeInterceptor.java
finally { if (ses != null) { unlock(ses); } }
3
valueOf 1
                  
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
finally { int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue(); counterVal -= 1; request.setAttribute(COUNTER, Integer.valueOf(counterVal)); cleanUp(request); }
38

Reference Table

This table concatenates the results of the previous tables.

Checked/Runtime Type Exception Thrown Thrown from Catch Declared Caught directly Caught
with Thrown
Caught
with Thrown Runtime
unknown (Lib) ClassNotFoundException 0 0 1
            
// in java/org/apache/struts2/util/StrutsUtil.java
public Object findValue(String expression, String className) throws ClassNotFoundException { return stack.findValue(expression, Class.forName(className)); }
8
            
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
catch (ClassNotFoundException e) { // this is OK -- this just means JSP isn't even being used here, which is perfectly fine. // we need this class in environments that use JSP to know when to wrap the writer // and ignore flush() calls. In JSP, it is illegal for a BodyContent writer to be flushed(), // so we have to take caution here. }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (ClassNotFoundException e) { // this is OK, we'll just move on }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to locate provider class: "+cname, e); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (ClassNotFoundException e) { System.err.println("Unable to locate logger factory class: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( ClassNotFoundException e ) { System.err.println("Unable to locate logger factory class: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (ClassNotFoundException e) { System.err.println("Unable to locate logger factory class: " + factoryName + ", using default"); e.printStackTrace(); }
3
            
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to locate provider class: "+cname, e); }
0
unknown (Lib) CloneNotSupportedException 0 0 1
            
// in java/org/apache/struts2/components/template/Template.java
protected Object clone() throws CloneNotSupportedException { return super.clone(); }
1
            
// in java/org/apache/struts2/components/template/Template.java
catch (CloneNotSupportedException e) { // do nothing }
0 0
unknown (Lib) ConfigurationException 14
            
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { Settings defaultSettings = null; try { defaultSettings = new PropertiesSettings("org/apache/struts2/default"); } catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); } loadSettings(props, defaultSettings); }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
void alias(Class type, String key, ContainerBuilder builder, Properties props, Scope scope) { if (!builder.contains(type)) { String foundName = props.getProperty(key, DEFAULT_BEAN_NAME); if (builder.contains(type, foundName)) { if (LOG.isInfoEnabled()) { LOG.info("Choosing bean (#0) for (#1)", foundName, type.getName()); } builder.alias(type, foundName, Container.DEFAULT_NAME); } else { try { Class cls = ClassLoaderUtil.loadClass(foundName, this.getClass()); if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1)", cls.getName(), type.getName()); } builder.factory(type, cls, scope); } catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } } } } else { if (LOG.isWarnEnabled()) { LOG.warn("Unable to alias bean type (#0), default mapping already assigned.", type.getName()); } } }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
public Object create(Context context) throws Exception { ObjectFactory objFactory = context.getContainer().getInstance(ObjectFactory.class); try { return objFactory.buildBean(name, null, true); } catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); } }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map refParams) throws ConfigurationException { String className = interceptorConfig.getClassName(); Map<String, String> params = new HashMap<String, String>(); Map typeParams = interceptorConfig.getParams(); if (typeParams != null && !typeParams.isEmpty()) params.putAll(typeParams); if (refParams != null && !refParams.isEmpty()) params.putAll(refParams); try { // interceptor instances are long-lived and used across user sessions, so don't try to pass in any extra // context Object o = buildBean(className, null); reflectionProvider.setProperties(params, o); if (o instanceof Interceptor) { Interceptor interceptor = (Interceptor) o; interceptor.init(); return interceptor; } // This is for the new API: // if (o instanceof org.apache.struts2.spi.Interceptor) // return new InterceptorAdapter((org.apache.struts2.spi.Interceptor) o); throw new ConfigurationException( "Class [" + className + "] does not implement Interceptor", interceptorConfig); } catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); } catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); } catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); } catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); } }
// in java/org/apache/struts2/components/template/TemplateEngineManager.java
public TemplateEngine create() { TemplateEngine engine = container.getInstance(TemplateEngine.class, name); if (engine == null) { throw new ConfigurationException("Unable to locate template engine: "+name); } return engine; }
// in java/org/apache/struts2/components/UIBean.java
protected void mergeTemplate(Writer writer, Template template) throws Exception { final TemplateEngine engine = templateEngineManager.getTemplateEngine(template, templateSuffix); if (engine == null) { throw new ConfigurationException("Unable to find a TemplateEngine for template " + template); } if (LOG.isDebugEnabled()) { LOG.debug("Rendering template " + template); } final TemplateRenderingContext context = new TemplateRenderingContext(template, writer, getStack(), getParameters(), this); engine.renderTemplate(context); }
// in java/org/apache/struts2/views/jsp/TagUtils.java
public static ValueStack getStack(PageContext pageContext) { HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); ValueStack stack = (ValueStack) req.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY); if (stack == null) { HttpServletResponse res = (HttpServletResponse) pageContext.getResponse(); Dispatcher du = Dispatcher.getInstance(); if (du == null) { throw new ConfigurationException("The Struts dispatcher cannot be found. This is usually caused by "+ "using Struts tags without the associated filter. Struts tags are only usable when the request "+ "has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag."); } stack = du.getContainer().getInstance(ValueStackFactory.class).createValueStack(); Map<String, Object> extraContext = du.createContextMap(new RequestMap(req), req.getParameterMap(), new SessionMap(req), new ApplicationMap(pageContext.getServletContext()), req, res, pageContext.getServletContext()); extraContext.put(ServletActionContext.PAGE_CONTEXT, pageContext); stack.getContext().putAll(extraContext); req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); // also tie this stack/context to the ThreadLocal ActionContext.setContext(new ActionContext(stack.getContext())); } else { // let's make sure that the current page context is in the action context Map<String, Object> context = stack.getContext(); context.put(ServletActionContext.PAGE_CONTEXT, pageContext); AttributeMap attrMap = new AttributeMap(context); context.put("attr", attrMap); } return stack; }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
private void init_CustomConfigurationProviders() { String configProvs = initParams.get("configProviders"); if (configProvs != null) { String[] classes = configProvs.split("\\s*[,]\\s*"); for (String cname : classes) { try { Class cls = ClassLoaderUtil.loadClass(cname, this.getClass()); ConfigurationProvider prov = (ConfigurationProvider)cls.newInstance(); configurationManager.addContainerProvider(prov); } catch (InstantiationException e) { throw new ConfigurationException("Unable to instantiate provider: "+cname, e); } catch (IllegalAccessException e) { throw new ConfigurationException("Unable to access provider: "+cname, e); } catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to locate provider class: "+cname, e); } } } }
10
            
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { // Perhaps a spring bean id, so we'll delegate to the object factory at runtime if (LOG.isDebugEnabled()) { LOG.debug("Choosing bean (#0) for (#1) to be loaded from the ObjectFactory", foundName, type.getName()); } if (DEFAULT_BEAN_NAME.equals(foundName)) { // Probably an optional bean, will ignore } else { if (ObjectFactory.class != type) { builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope); } else { throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName); } } }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (InstantiationException e) { throw new ConfigurationException("Unable to instantiate provider: "+cname, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IllegalAccessException e) { throw new ConfigurationException("Unable to access provider: "+cname, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to locate provider class: "+cname, e); }
12
            
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
public void init(Configuration configuration) throws ConfigurationException { }
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { Settings defaultSettings = null; try { defaultSettings = new PropertiesSettings("org/apache/struts2/default"); } catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); } loadSettings(props, defaultSettings); }
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
Override public void register(ContainerBuilder containerBuilder, LocatableProperties props) throws ConfigurationException { if (servletContext != null && !containerBuilder.contains(ServletContext.class)) { containerBuilder.factory(ServletContext.class, new Factory<ServletContext>() { public ServletContext create(Context context) throws Exception { return servletContext; } }); }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
public void loadPackages() throws ConfigurationException { // NO-OP }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
public void init(Configuration configuration) throws ConfigurationException { // NO-OP }
// in java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java
public void init(Configuration configuration) throws ConfigurationException { Settings.reset(); }
// in java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java
public void loadPackages() throws ConfigurationException { }
// in java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { final Settings settings = Settings.getInstance(); loadSettings(props, settings); // Set default locale by lazily resolving the locale property as needed into a Locale object builder.factory(Locale.class, new Factory() { private Locale locale; public synchronized Object create(Context context) throws Exception { if (locale == null) { String loc = context.getContainer().getInstance(String.class, StrutsConstants.STRUTS_LOCALE); if (loc != null) { StringTokenizer localeTokens = new StringTokenizer(loc, "_"); String lang = null; String country = null; if (localeTokens.hasMoreTokens()) { lang = localeTokens.nextToken(); } if (localeTokens.hasMoreTokens()) { country = localeTokens.nextToken(); } locale = new Locale(lang, country); } else { if (LOG.isInfoEnabled()) { LOG.info("No locale define, substituting the default VM locale"); } locale = Locale.getDefault(); } } return locale; } }); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map refParams) throws ConfigurationException { String className = interceptorConfig.getClassName(); Map<String, String> params = new HashMap<String, String>(); Map typeParams = interceptorConfig.getParams(); if (typeParams != null && !typeParams.isEmpty()) params.putAll(typeParams); if (refParams != null && !refParams.isEmpty()) params.putAll(refParams); try { // interceptor instances are long-lived and used across user sessions, so don't try to pass in any extra // context Object o = buildBean(className, null); reflectionProvider.setProperties(params, o); if (o instanceof Interceptor) { Interceptor interceptor = (Interceptor) o; interceptor.init(); return interceptor; } // This is for the new API: // if (o instanceof org.apache.struts2.spi.Interceptor) // return new InterceptorAdapter((org.apache.struts2.spi.Interceptor) o); throw new ConfigurationException( "Class [" + className + "] does not implement Interceptor", interceptorConfig); } catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); } catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); } catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); } catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); } }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
private void init_FilterInitParameters() { configurationManager.addContainerProvider(new ConfigurationProvider() { public void destroy() { } public void init(Configuration configuration) throws ConfigurationException { } public void loadPackages() throws ConfigurationException { } public boolean needsReload() { return false; } public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { props.putAll(initParams); } }); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void init(Configuration configuration) throws ConfigurationException { }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void loadPackages() throws ConfigurationException { }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { props.putAll(initParams); }
1
            
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (ConfigurationException e) { // WW-2874 Only log error if in devMode if(devMode) { String reqStr = request.getRequestURI(); if (request.getQueryString() != null) { reqStr = reqStr + "?" + request.getQueryString(); } LOG.error("Could not find action or result\n" + reqStr, e); } else { if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); }
0 0
checked (Lib) Exception 0 0 49
            
// in java/org/apache/struts2/interceptor/ClearSessionInterceptor.java
public String intercept(ActionInvocation invocation) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("Clearing HttpSession"); } ActionContext ac = invocation.getInvocationContext(); Map session = ac.getSession(); if (null != session) { session.clear(); } return invocation.invoke(); }
// in java/org/apache/struts2/interceptor/CreateSessionInterceptor.java
public String intercept(ActionInvocation invocation) throws Exception { HttpSession httpSession = ServletActionContext.getRequest().getSession(false); if (httpSession == null) { if (LOG.isDebugEnabled()) { LOG.debug("Creating new HttpSession and new SessionMap in ServletActionContext"); } ServletActionContext.getRequest().getSession(true); ServletActionContext.getContext().setSession(new SessionMap<String, Object>(ServletActionContext.getRequest())); } return invocation.invoke(); }
// in java/org/apache/struts2/interceptor/RolesInterceptor.java
public String intercept(ActionInvocation invocation) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); String result = null; if (!isAllowed(request, invocation.getAction())) { result = handleRejection(invocation, response); } else { result = invocation.invoke(); } return result; }
// in java/org/apache/struts2/interceptor/RolesInterceptor.java
protected String handleRejection(ActionInvocation invocation, HttpServletResponse response) throws Exception { response.sendError(HttpServletResponse.SC_FORBIDDEN); return null; }
// in java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java
protected String handleInvalidToken(ActionInvocation invocation) throws Exception { ActionContext ac = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST); HttpServletResponse response = (HttpServletResponse) ac.get(ServletActionContext.HTTP_RESPONSE); String tokenName = TokenHelper.getTokenName(); String token = TokenHelper.getToken(tokenName); if ((tokenName != null) && (token != null)) { Map params = ac.getParameters(); params.remove(tokenName); params.remove(TokenHelper.TOKEN_NAME_FIELD); ActionInvocation savedInvocation = InvocationSessionStore.loadInvocation(tokenName, token); if (savedInvocation != null) { // set the valuestack to the request scope ValueStack stack = savedInvocation.getStack(); Map context = stack.getContext(); request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); ActionContext savedContext = savedInvocation.getInvocationContext(); savedContext.getContextMap().put(ServletActionContext.HTTP_REQUEST, request); savedContext.getContextMap().put(ServletActionContext.HTTP_RESPONSE, response); Result result = savedInvocation.getResult(); if ((result != null) && (savedInvocation.getProxy().getExecuteResult())) { synchronized (context) { result.execute(savedInvocation); } } // turn off execution of this invocations result invocation.getProxy().setExecuteResult(false); return savedInvocation.getResultCode(); } } return INVALID_TOKEN_CODE; }
// in java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java
protected String handleValidToken(ActionInvocation invocation) throws Exception { // we know the token name and token must be there String key = TokenHelper.getTokenName(); String token = TokenHelper.getToken(key); InvocationSessionStore.storeInvocation(key, token, invocation); return invocation.invoke(); }
// in java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java
protected String doIntercept(ActionInvocation actionInvocation) throws Exception { ActionProxy proxy = actionInvocation.getProxy(); String name = getBackgroundProcessName(proxy); ActionContext context = actionInvocation.getInvocationContext(); Map session = context.getSession(); HttpSession httpSession = ServletActionContext.getRequest().getSession(true); Boolean secondTime = true; if (executeAfterValidationPass) { secondTime = (Boolean) context.get(KEY); if (secondTime == null) { context.put(KEY, true); secondTime = false; } else { secondTime = true; context.put(KEY, null); } } //sync on the real HttpSession as the session from the context is a wrap that is created //on every request synchronized (httpSession) { BackgroundProcess bp = (BackgroundProcess) session.get(KEY + name); if ((!executeAfterValidationPass || secondTime) && bp == null) { bp = getNewBackgroundProcess(name, actionInvocation, threadPriority); session.put(KEY + name, bp); performInitialDelay(bp); // first time let some time pass before showing wait page secondTime = false; } if ((!executeAfterValidationPass || !secondTime) && bp != null && !bp.isDone()) { actionInvocation.getStack().push(bp.getAction()); if (TokenHelper.getToken() != null) { session.put(TokenHelper.getTokenName(), TokenHelper.getToken()); } Map results = proxy.getConfig().getResults(); if (!results.containsKey(WAIT)) { if (LOG.isWarnEnabled()) { LOG.warn("ExecuteAndWait interceptor has detected that no result named 'wait' is available. " + "Defaulting to a plain built-in wait page. It is highly recommend you " + "provide an action-specific or global result named '" + WAIT + "'."); } // no wait result? hmm -- let's try to do dynamically put it in for you! //we used to add a fake "wait" result here, since the configuration is unmodifiable, that is no longer //an option, see WW-3068 FreemarkerResult waitResult = new FreemarkerResult(); container.inject(waitResult); waitResult.setLocation("/org/apache/struts2/interceptor/wait.ftl"); waitResult.execute(actionInvocation); return Action.NONE; } return WAIT; } else if ((!executeAfterValidationPass || !secondTime) && bp != null && bp.isDone()) { session.remove(KEY + name); actionInvocation.getStack().push(bp.getAction()); // if an exception occured during action execution, throw it here if (bp.getException() != null) { throw bp.getException(); } return bp.getResult(); } else { // this is the first instance of the interceptor and there is no existing action // already run in the background, so let's just let this pass through. We assume // the action invocation will be run in the background on the subsequent pass through // this interceptor return actionInvocation.invoke(); } } }
// in java/org/apache/struts2/interceptor/CheckboxInterceptor.java
public String intercept(ActionInvocation ai) throws Exception { Map parameters = ai.getInvocationContext().getParameters(); Map<String, String[]> newParams = new HashMap<String, String[]>(); Set<Map.Entry> entries = parameters.entrySet(); for (Iterator<Map.Entry> iterator = entries.iterator(); iterator.hasNext();) { Map.Entry entry = iterator.next(); String key = (String)entry.getKey(); if (key.startsWith("__checkbox_")) { String name = key.substring("__checkbox_".length()); Object values = entry.getValue(); iterator.remove(); if (values != null && values instanceof String[] && ((String[])values).length > 1) { if (LOG.isDebugEnabled()) { LOG.debug("Bypassing automatic checkbox detection due to multiple checkboxes of the same name: #0", name); } continue; } // is this checkbox checked/submitted? if (!parameters.containsKey(name)) { // if not, let's be sure to default the value to false newParams.put(name, new String[]{uncheckedValue}); } } } parameters.putAll(newParams); return ai.invoke(); }
// in java/org/apache/struts2/interceptor/FileUploadInterceptor.java
public String intercept(ActionInvocation invocation) throws Exception { ActionContext ac = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST); if (!(request instanceof MultiPartRequestWrapper)) { if (LOG.isDebugEnabled()) { ActionProxy proxy = invocation.getProxy(); LOG.debug(getTextMessage("struts.messages.bypass.request", new Object[]{proxy.getNamespace(), proxy.getActionName()}, ac.getLocale())); } return invocation.invoke(); } ValidationAware validation = null; Object action = invocation.getAction(); if (action instanceof ValidationAware) { validation = (ValidationAware) action; } MultiPartRequestWrapper multiWrapper = (MultiPartRequestWrapper) request; if (multiWrapper.hasErrors()) { for (String error : multiWrapper.getErrors()) { if (validation != null) { validation.addActionError(error); } if (LOG.isWarnEnabled()) { LOG.warn(error); } } } // bind allowed Files Enumeration fileParameterNames = multiWrapper.getFileParameterNames(); while (fileParameterNames != null && fileParameterNames.hasMoreElements()) { // get the value of this input tag String inputName = (String) fileParameterNames.nextElement(); // get the content type String[] contentType = multiWrapper.getContentTypes(inputName); if (isNonEmpty(contentType)) { // get the name of the file from the input tag String[] fileName = multiWrapper.getFileNames(inputName); if (isNonEmpty(fileName)) { // get a File object for the uploaded File File[] files = multiWrapper.getFiles(inputName); if (files != null && files.length > 0) { List<File> acceptedFiles = new ArrayList<File>(files.length); List<String> acceptedContentTypes = new ArrayList<String>(files.length); List<String> acceptedFileNames = new ArrayList<String>(files.length); String contentTypeName = inputName + "ContentType"; String fileNameName = inputName + "FileName"; for (int index = 0; index < files.length; index++) { if (acceptFile(action, files[index], fileName[index], contentType[index], inputName, validation, ac.getLocale())) { acceptedFiles.add(files[index]); acceptedContentTypes.add(contentType[index]); acceptedFileNames.add(fileName[index]); } } if (!acceptedFiles.isEmpty()) { Map<String, Object> params = ac.getParameters(); params.put(inputName, acceptedFiles.toArray(new File[acceptedFiles.size()])); params.put(contentTypeName, acceptedContentTypes.toArray(new String[acceptedContentTypes.size()])); params.put(fileNameName, acceptedFileNames.toArray(new String[acceptedFileNames.size()])); } } } else { if (LOG.isWarnEnabled()) { LOG.warn(getTextMessage(action, "struts.messages.invalid.file", new Object[]{inputName}, ac.getLocale())); } } } else { if (LOG.isWarnEnabled()) { LOG.warn(getTextMessage(action, "struts.messages.invalid.content.type", new Object[]{inputName}, ac.getLocale())); } } } // invoke action return invocation.invoke(); }
// in java/org/apache/struts2/interceptor/MultiselectInterceptor.java
public String intercept(ActionInvocation actionInvocation) throws Exception { Map parameters = actionInvocation.getInvocationContext().getParameters(); Map<String, Object> newParams = new HashMap<String, Object>(); Set<String> keys = parameters.keySet(); for (Iterator<String> iterator = keys.iterator(); iterator.hasNext();) { String key = iterator.next(); if (key.startsWith("__multiselect_")) { String name = key.substring("__multiselect_".length()); iterator.remove(); // is this multi-select box submitted? if (!parameters.containsKey(name)) { // if not, let's be sure to default the value to an empty string array newParams.put(name, new String[0]); } } } parameters.putAll(newParams); return actionInvocation.invoke(); }
// in java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
public String intercept(ActionInvocation invocation) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("entering MessageStoreInterceptor ..."); } before(invocation); String result = invocation.invoke(); after(invocation, result); if (LOG.isDebugEnabled()) { LOG.debug("exit executing MessageStoreInterceptor"); } return result; }
// in java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
protected void before(ActionInvocation invocation) throws Exception { String reqOperationMode = getRequestOperationMode(invocation); if (RETRIEVE_MODE.equalsIgnoreCase(reqOperationMode) || RETRIEVE_MODE.equalsIgnoreCase(operationMode) || AUTOMATIC_MODE.equalsIgnoreCase(operationMode)) { Object action = invocation.getAction(); if (action instanceof ValidationAware) { // retrieve error / message from session Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION); ValidationAware validationAwareAction = (ValidationAware) action; if (LOG.isDebugEnabled()) { LOG.debug("retrieve error / message from session to populate into action ["+action+"]"); } Collection actionErrors = (Collection) session.get(actionErrorsSessionKey); Collection actionMessages = (Collection) session.get(actionMessagesSessionKey); Map fieldErrors = (Map) session.get(fieldErrorsSessionKey); if (actionErrors != null && actionErrors.size() > 0) { Collection mergedActionErrors = mergeCollection(validationAwareAction.getActionErrors(), actionErrors); validationAwareAction.setActionErrors(mergedActionErrors); } if (actionMessages != null && actionMessages.size() > 0) { Collection mergedActionMessages = mergeCollection(validationAwareAction.getActionMessages(), actionMessages); validationAwareAction.setActionMessages(mergedActionMessages); } if (fieldErrors != null && fieldErrors.size() > 0) { Map mergedFieldErrors = mergeMap(validationAwareAction.getFieldErrors(), fieldErrors); validationAwareAction.setFieldErrors(mergedFieldErrors); } session.remove(actionErrorsSessionKey); session.remove(actionMessagesSessionKey); session.remove(fieldErrorsSessionKey); } } }
// in java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
protected void after(ActionInvocation invocation, String result) throws Exception { String reqOperationMode = getRequestOperationMode(invocation); boolean isRedirect = invocation.getResult() instanceof ServletRedirectResult; if (STORE_MODE.equalsIgnoreCase(reqOperationMode) || STORE_MODE.equalsIgnoreCase(operationMode) || (AUTOMATIC_MODE.equalsIgnoreCase(operationMode) && isRedirect)) { Object action = invocation.getAction(); if (action instanceof ValidationAware) { // store error / messages into session Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION); if (LOG.isDebugEnabled()) { LOG.debug("store action ["+action+"] error/messages into session "); } ValidationAware validationAwareAction = (ValidationAware) action; session.put(actionErrorsSessionKey, validationAwareAction.getActionErrors()); session.put(actionMessagesSessionKey, validationAwareAction.getActionMessages()); session.put(fieldErrorsSessionKey, validationAwareAction.getFieldErrors()); } else if(LOG.isDebugEnabled()) { LOG.debug("Action ["+action+"] is not ValidationAware, no message / error that are storeable"); } } }
// in java/org/apache/struts2/interceptor/BackgroundProcess.java
protected void beforeInvocation() throws Exception { }
// in java/org/apache/struts2/interceptor/BackgroundProcess.java
protected void afterInvocation() throws Exception { }
// in java/org/apache/struts2/interceptor/CookieInterceptor.java
public String intercept(ActionInvocation invocation) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("start interception"); } // contains selected cookies final Map<String, String> cookiesMap = new LinkedHashMap<String, String>(); Cookie[] cookies = ServletActionContext.getRequest().getCookies(); if (cookies != null) { final ValueStack stack = ActionContext.getContext().getValueStack(); for (Cookie cookie : cookies) { String name = cookie.getName(); String value = cookie.getValue(); if (acceptedPattern.matcher(name).matches()) { if (cookiesNameSet.contains("*")) { if (LOG.isDebugEnabled()) { LOG.debug("contains cookie name [*] in configured cookies name set, cookie with name [" + name + "] with value [" + value + "] will be injected"); } populateCookieValueIntoStack(name, value, cookiesMap, stack); } else if (cookiesNameSet.contains(cookie.getName())) { populateCookieValueIntoStack(name, value, cookiesMap, stack); } } else { LOG.warn("Cookie name [" + name + "] does not match accepted cookie names pattern [" + acceptedPattern + "]"); } } } // inject the cookiesMap, even if we don't have any cookies injectIntoCookiesAwareAction(invocation.getAction(), cookiesMap); return invocation.invoke(); }
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
protected String doIntercept(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); if (action != null) { Method method = getActionMethod(action.getClass(), invocation.getProxy().getMethod()); Collection<Method> annotatedMethods = AnnotationUtils.getAnnotatedMethods(action.getClass(), SkipValidation.class); if (annotatedMethods.contains(method)) return invocation.invoke(); //check if method overwites an annotated method Class clazz = action.getClass().getSuperclass(); while (clazz != null) { annotatedMethods = AnnotationUtils.getAnnotatedMethods(clazz, SkipValidation.class); if (annotatedMethods != null) { for (Method annotatedMethod : annotatedMethods) { if (annotatedMethod.getName().equals(method.getName()) && Arrays.equals(annotatedMethod.getParameterTypes(), method.getParameterTypes()) && Arrays.equals(annotatedMethod.getExceptionTypes(), method.getExceptionTypes())) return invocation.invoke(); } } clazz = clazz.getSuperclass(); } } return super.doIntercept(invocation); }
// in java/org/apache/struts2/interceptor/ScopeInterceptor.java
static final void lock(Object o, ActionInvocation invocation) throws Exception { synchronized (o) { int count = 3; Object previous = null; while ((previous = locks.get(o)) != null) { if (previous == invocation) { return; } if (count-- <= 0) { locks.remove(o); o.notify(); throw new StrutsException("Deadlock in session lock"); } o.wait(10000); } ; locks.put(o, invocation); } }
// in java/org/apache/struts2/interceptor/ScopeInterceptor.java
protected void after(ActionInvocation invocation, String result) throws Exception { Map ses = ActionContext.getContext().getSession(); if ( ses != null) { unlock(ses); } }
// in java/org/apache/struts2/interceptor/ScopeInterceptor.java
protected void before(ActionInvocation invocation) throws Exception { invocation.addPreResultListener(this); Map ses = ActionContext.getContext().getSession(); if (ses == null && autoCreateSession) { ses = new SessionMap(ServletActionContext.getRequest()); ActionContext.getContext().setSession(ses); } if ( ses != null) { lock(ses, invocation); } String key = getKey(invocation); Map app = ActionContext.getContext().getApplication(); final ValueStack stack = ActionContext.getContext().getValueStack(); if (LOG.isDebugEnabled()) { LOG.debug("scope interceptor before"); } if (application != null) for (int i = 0; i < application.length; i++) { String string = application[i]; Object attribute = app.get(key + string); if (attribute != null) { if (LOG.isDebugEnabled()) { LOG.debug("application scoped variable set " + string + " = " + String.valueOf(attribute)); } stack.setValue(string, nullConvert(attribute)); } } if (ActionContext.getContext().getParameters().get(sessionReset) != null) { return; } if (reset) { return; } if (ses == null) { LOG.debug("No HttpSession created... Cannot set session scoped variables"); return; } if (session != null && (!"start".equals(type))) { for (int i = 0; i < session.length; i++) { String string = session[i]; Object attribute = ses.get(key + string); if (attribute != null) { if (LOG.isDebugEnabled()) { LOG.debug("session scoped variable set " + string + " = " + String.valueOf(attribute)); } stack.setValue(string, nullConvert(attribute)); } } } }
// in java/org/apache/struts2/interceptor/ScopeInterceptor.java
public String intercept(ActionInvocation invocation) throws Exception { String result = null; Map ses = ActionContext.getContext().getSession(); before(invocation); try { result = invocation.invoke(); after(invocation, result); } finally { if (ses != null) { unlock(ses); } } return result; }
// in java/org/apache/struts2/interceptor/ServletConfigInterceptor.java
public String intercept(ActionInvocation invocation) throws Exception { final Object action = invocation.getAction(); final ActionContext context = invocation.getInvocationContext(); if (action instanceof ServletRequestAware) { HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST); ((ServletRequestAware) action).setServletRequest(request); } if (action instanceof ServletResponseAware) { HttpServletResponse response = (HttpServletResponse) context.get(HTTP_RESPONSE); ((ServletResponseAware) action).setServletResponse(response); } if (action instanceof ParameterAware) { ((ParameterAware) action).setParameters((Map)context.getParameters()); } if (action instanceof ApplicationAware) { ((ApplicationAware) action).setApplication(context.getApplication()); } if (action instanceof SessionAware) { ((SessionAware) action).setSession(context.getSession()); } if (action instanceof RequestAware) { ((RequestAware) action).setRequest((Map) context.get("request")); } if (action instanceof PrincipalAware) { HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST); if(request != null) { // We are in servtlet environment, so principal information resides in HttpServletRequest ((PrincipalAware) action).setPrincipalProxy(new ServletPrincipalProxy(request)); } } if (action instanceof ServletContextAware) { ServletContext servletContext = (ServletContext) context.get(SERVLET_CONTEXT); ((ServletContextAware) action).setServletContext(servletContext); } return invocation.invoke(); }
// in java/org/apache/struts2/interceptor/TokenInterceptor.java
protected String doIntercept(ActionInvocation invocation) throws Exception { if (log.isDebugEnabled()) { log.debug("Intercepting invocation to check for valid transaction token."); } //see WW-2902: we need to use the real HttpSession here, as opposed to the map //that wraps the session, because a new wrap is created on every request HttpSession session = ServletActionContext.getRequest().getSession(true); synchronized (session) { if (!TokenHelper.validToken()) { return handleInvalidToken(invocation); } } return handleValidToken(invocation); }
// in java/org/apache/struts2/interceptor/TokenInterceptor.java
protected String handleInvalidToken(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); String errorMessage = LocalizedTextUtil.findText(this.getClass(), "struts.messages.invalid.token", invocation.getInvocationContext().getLocale(), "The form has already been processed or no token was supplied, please try again.", new Object[0]); if (action instanceof ValidationAware) { ((ValidationAware) action).addActionError(errorMessage); } else { log.warn(errorMessage); } return INVALID_TOKEN_CODE; }
// in java/org/apache/struts2/interceptor/TokenInterceptor.java
protected String handleValidToken(ActionInvocation invocation) throws Exception { return invocation.invoke(); }
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
Override public void register(ContainerBuilder containerBuilder, LocatableProperties props) throws ConfigurationException { if (servletContext != null && !containerBuilder.contains(ServletContext.class)) { containerBuilder.factory(ServletContext.class, new Factory<ServletContext>() { public ServletContext create(Context context) throws Exception { return servletContext; } }); }
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
public ServletContext create(Context context) throws Exception { return servletContext; }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
public Object create(Context context) throws Exception { ObjectFactory objFactory = context.getContainer().getInstance(ObjectFactory.class); try { return objFactory.buildBean(name, null, true); } catch (ClassNotFoundException ex) { throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")"); } }
// in java/org/apache/struts2/config/NullResult.java
public void execute(ActionInvocation invocation) throws Exception { throw new IllegalStateException("Shouldn't be called"); }
// in java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { final Settings settings = Settings.getInstance(); loadSettings(props, settings); // Set default locale by lazily resolving the locale property as needed into a Locale object builder.factory(Locale.class, new Factory() { private Locale locale; public synchronized Object create(Context context) throws Exception { if (locale == null) { String loc = context.getContainer().getInstance(String.class, StrutsConstants.STRUTS_LOCALE); if (loc != null) { StringTokenizer localeTokens = new StringTokenizer(loc, "_"); String lang = null; String country = null; if (localeTokens.hasMoreTokens()) { lang = localeTokens.nextToken(); } if (localeTokens.hasMoreTokens()) { country = localeTokens.nextToken(); } locale = new Locale(lang, country); } else { if (LOG.isInfoEnabled()) { LOG.info("No locale define, substituting the default VM locale"); } locale = Locale.getDefault(); } } return locale; } }); }
// in java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java
public synchronized Object create(Context context) throws Exception { if (locale == null) { String loc = context.getContainer().getInstance(String.class, StrutsConstants.STRUTS_LOCALE); if (loc != null) { StringTokenizer localeTokens = new StringTokenizer(loc, "_"); String lang = null; String country = null; if (localeTokens.hasMoreTokens()) { lang = localeTokens.nextToken(); } if (localeTokens.hasMoreTokens()) { country = localeTokens.nextToken(); } locale = new Locale(lang, country); } else { if (LOG.isInfoEnabled()) { LOG.info("No locale define, substituting the default VM locale"); } locale = Locale.getDefault(); } } return locale; }
// in java/org/apache/struts2/impl/StrutsActionProxy.java
public String execute() throws Exception { ActionContext previous = ActionContext.getContext(); ActionContext.setContext(invocation.getInvocationContext()); try { // This is for the new API: // return RequestContextImpl.callInContext(invocation, new Callable<String>() { // public String call() throws Exception { // return invocation.invoke(); // } // }); return invocation.invoke(); } finally { if (cleanupContext) ActionContext.setContext(previous); } }
// in java/org/apache/struts2/components/template/VelocityTemplateEngine.java
public void renderTemplate(TemplateRenderingContext templateContext) throws Exception { // get the various items required from the stack Map actionContext = templateContext.getStack().getContext(); ServletContext servletContext = (ServletContext) actionContext.get(ServletActionContext.SERVLET_CONTEXT); HttpServletRequest req = (HttpServletRequest) actionContext.get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) actionContext.get(ServletActionContext.HTTP_RESPONSE); // prepare velocity velocityManager.init(servletContext); VelocityEngine velocityEngine = velocityManager.getVelocityEngine(); // get the list of templates we can use List<Template> templates = templateContext.getTemplate().getPossibleTemplates(this); // find the right template org.apache.velocity.Template template = null; String templateName = null; Exception exception = null; for (Template t : templates) { templateName = getFinalTemplateName(t); try { // try to load, and if it works, stop at the first one template = velocityEngine.getTemplate(templateName); break; } catch (IOException e) { if (exception == null) { exception = e; } } } if (template == null) { LOG.error("Could not load template " + templateContext.getTemplate()); if (exception != null) { throw exception; } else { return; } } if (LOG.isDebugEnabled()) { LOG.debug("Rendering template " + templateName); } Context context = velocityManager.createContext(templateContext.getStack(), req, res); Writer outputWriter = templateContext.getWriter(); context.put("tag", templateContext.getTag()); context.put("parameters", templateContext.getParameters()); template.merge(context, outputWriter); }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
public void renderTemplate(TemplateRenderingContext templateContext) throws Exception { // get the various items required from the stack ValueStack stack = templateContext.getStack(); Map context = stack.getContext(); ServletContext servletContext = (ServletContext) context.get(ServletActionContext.SERVLET_CONTEXT); HttpServletRequest req = (HttpServletRequest) context.get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) context.get(ServletActionContext.HTTP_RESPONSE); // prepare freemarker Configuration config = freemarkerManager.getConfiguration(servletContext); // get the list of templates we can use List<Template> templates = templateContext.getTemplate().getPossibleTemplates(this); // find the right template freemarker.template.Template template = null; String templateName = null; Exception exception = null; for (Template t : templates) { templateName = getFinalTemplateName(t); try { // try to load, and if it works, stop at the first one template = config.getTemplate(templateName); break; } catch (ParseException e) { // template was found but was invalid - always report this. exception = e; break; } catch (IOException e) { // FileNotFoundException is anticipated - report the first IOException if no template found if (exception == null) { exception = e; } } } if (template == null) { if (LOG.isErrorEnabled()) { LOG.error("Could not load the FreeMarker template named '" + templateContext.getTemplate().getName() +"':"); for (Template t : templates) { LOG.error("Attempted: " + getFinalTemplateName(t)); } LOG.error("The TemplateLoader provided by the FreeMarker Configuration was a: "+config.getTemplateLoader().getClass().getName()); } if (exception != null) { throw exception; } else { return; } } if (LOG.isDebugEnabled()) { LOG.debug("Rendering template " + templateName); } ActionInvocation ai = ActionContext.getContext().getActionInvocation(); Object action = (ai == null) ? null : ai.getAction(); SimpleHash model = freemarkerManager.buildTemplateModel(stack, action, servletContext, req, res, config.getObjectWrapper()); model.put("tag", templateContext.getTag()); model.put("themeProperties", getThemeProps(templateContext.getTemplate())); // the BodyContent JSP writer doesn't like it when FM flushes automatically -- // so let's just not do it (it will be flushed eventually anyway) Writer writer = templateContext.getWriter(); final Writer wrapped = writer; writer = new Writer() { public void write(char cbuf[], int off, int len) throws IOException { wrapped.write(cbuf, off, len); } public void flush() throws IOException { // nothing! } public void close() throws IOException { wrapped.close(); } }; try { stack.push(templateContext.getTag()); template.process(model, writer); } finally { stack.pop(); } }
// in java/org/apache/struts2/components/UIBean.java
protected void mergeTemplate(Writer writer, Template template) throws Exception { final TemplateEngine engine = templateEngineManager.getTemplateEngine(template, templateSuffix); if (engine == null) { throw new ConfigurationException("Unable to find a TemplateEngine for template " + template); } if (LOG.isDebugEnabled()) { LOG.debug("Rendering template " + template); } final TemplateRenderingContext context = new TemplateRenderingContext(template, writer, getStack(), getParameters(), this); engine.renderTemplate(context); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void execute(ActionInvocation invocation) throws Exception { long startTime = System.currentTimeMillis(); String location = getStylesheetLocation(); if (parse) { ValueStack stack = ActionContext.getContext().getValueStack(); location = TextParseUtil.translateVariables(location, stack); } try { HttpServletResponse response = ServletActionContext.getResponse(); PrintWriter writer = response.getWriter(); // Create a transformer for the stylesheet. Templates templates = null; Transformer transformer; if (location != null) { templates = getTemplates(location); transformer = templates.newTransformer(); } else transformer = TransformerFactory.newInstance().newTransformer(); transformer.setURIResolver(getURIResolver()); transformer.setErrorListener(new ErrorListener() { public void error(TransformerException exception) throws TransformerException { throw new StrutsException("Error transforming result", exception); } public void fatalError(TransformerException exception) throws TransformerException { throw new StrutsException("Fatal error transforming result", exception); } public void warning(TransformerException exception) throws TransformerException { if (LOG.isWarnEnabled()) { LOG.warn(exception.getMessage(), exception); } } }); String mimeType; if (templates == null) mimeType = "text/xml"; // no stylesheet, raw xml else mimeType = templates.getOutputProperties().getProperty(OutputKeys.MEDIA_TYPE); if (mimeType == null) { // guess (this is a servlet, so text/html might be the best guess) mimeType = "text/html"; } response.setContentType(mimeType); Object result = invocation.getAction(); if (exposedValue != null) { ValueStack stack = invocation.getStack(); result = stack.findValue(exposedValue); } Source xmlSource = getDOMSourceForStack(result); // Transform the source XML to System.out. if (LOG.isDebugEnabled()) { LOG.debug("xmlSource = " + xmlSource); } transformer.transform(xmlSource, new StreamResult(writer)); writer.flush(); // ...and flush... if (LOG.isDebugEnabled()) { LOG.debug("Time:" + (System.currentTimeMillis() - startTime) + "ms"); } } catch (Exception e) { LOG.error("Unable to render XSLT Template, '" + location + "'", e); throw e; } }
// in java/org/apache/struts2/dispatcher/HttpHeaderResult.java
public void execute(ActionInvocation invocation) throws Exception { HttpServletResponse response = ServletActionContext.getResponse(); ValueStack stack = ActionContext.getContext().getValueStack(); if (status != -1) { response.setStatus(status); } else if (error != -1) { if (errorMessage != null) { String finalMessage = parse ? TextParseUtil.translateVariables( errorMessage, stack) : errorMessage; response.sendError(error, finalMessage); } else response.sendError(error); } if (headers != null) { for (Iterator iterator = headers.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); String value = (String) entry.getValue(); String finalValue = parse ? TextParseUtil.translateVariables(value, stack) : value; response.addHeader((String) entry.getKey(), finalValue); } } }
// in java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java
public void execute(ActionInvocation invocation) throws Exception { actionName = conditionalParse(actionName, invocation); if (namespace == null) { namespace = invocation.getProxy().getNamespace(); } else { namespace = conditionalParse(namespace, invocation); } if (method == null) { method = ""; } else { method = conditionalParse(method, invocation); } String tmpLocation = actionMapper.getUriFromActionMapping(new ActionMapping(actionName, namespace, method, null)); setLocation(tmpLocation); super.execute(invocation); }
// in java/org/apache/struts2/dispatcher/VelocityResult.java
protected Template getTemplate(ValueStack stack, VelocityEngine velocity, ActionInvocation invocation, String location, String encoding) throws Exception { if (!location.startsWith("/")) { location = invocation.getProxy().getNamespace() + "/" + location; } Template template = velocity.getTemplate(location, encoding); return template; }
// in java/org/apache/struts2/dispatcher/StreamResult.java
protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { // Override any parameters using values on the stack resolveParamsFromStack(invocation.getStack(), invocation); OutputStream oOutput = null; try { if (inputStream == null) { // Find the inputstream from the invocation variable stack inputStream = (InputStream) invocation.getStack().findValue(conditionalParse(inputName, invocation)); } if (inputStream == null) { String msg = ("Can not find a java.io.InputStream with the name [" + inputName + "] in the invocation stack. " + "Check the <param name=\"inputName\"> tag specified for this action."); LOG.error(msg); throw new IllegalArgumentException(msg); } // Find the Response in context HttpServletResponse oResponse = (HttpServletResponse) invocation.getInvocationContext().get(HTTP_RESPONSE); // Set the content type if (contentCharSet != null && ! contentCharSet.equals("")) { oResponse.setContentType(conditionalParse(contentType, invocation)+";charset="+contentCharSet); } else { oResponse.setContentType(conditionalParse(contentType, invocation)); } // Set the content length if (contentLength != null) { String _contentLength = conditionalParse(contentLength, invocation); int _contentLengthAsInt = -1; try { _contentLengthAsInt = Integer.parseInt(_contentLength); if (_contentLengthAsInt >= 0) { oResponse.setContentLength(_contentLengthAsInt); } } catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e); } } } // Set the content-disposition if (contentDisposition != null) { oResponse.addHeader("Content-Disposition", conditionalParse(contentDisposition, invocation)); } // Set the cache control headers if neccessary if (!allowCaching) { oResponse.addHeader("Pragma", "no-cache"); oResponse.addHeader("Cache-Control", "no-cache"); } // Get the outputstream oOutput = oResponse.getOutputStream(); if (LOG.isDebugEnabled()) { LOG.debug("Streaming result [" + inputName + "] type=[" + contentType + "] length=[" + contentLength + "] content-disposition=[" + contentDisposition + "] charset=[" + contentCharSet + "]"); } // Copy input to output if (LOG.isDebugEnabled()) { LOG.debug("Streaming to output buffer +++ START +++"); } byte[] oBuff = new byte[bufferSize]; int iSize; while (-1 != (iSize = inputStream.read(oBuff))) { oOutput.write(oBuff, 0, iSize); } if (LOG.isDebugEnabled()) { LOG.debug("Streaming to output buffer +++ END +++"); } // Flush oOutput.flush(); } finally { if (inputStream != null) inputStream.close(); if (oOutput != null) oOutput.close(); } }
// in java/org/apache/struts2/dispatcher/StrutsResultSupport.java
public void execute(ActionInvocation invocation) throws Exception { lastFinalLocation = conditionalParse(location, invocation); doExecute(lastFinalLocation, invocation); }
// in java/org/apache/struts2/dispatcher/ServletDispatcherResult.java
public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("Forwarding to location " + finalLocation); } PageContext pageContext = ServletActionContext.getPageContext(); if (pageContext != null) { pageContext.include(finalLocation); } else { HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); RequestDispatcher dispatcher = request.getRequestDispatcher(finalLocation); //add parameters passed on the location to #parameters // see WW-2120 if (StringUtils.isNotEmpty(finalLocation) && finalLocation.indexOf("?") > 0) { String queryString = finalLocation.substring(finalLocation.indexOf("?") + 1); Map<String, Object> parameters = getParameters(invocation); Map<String, Object> queryParams = urlHelper.parseQueryString(queryString, true); if (queryParams != null && !queryParams.isEmpty()) parameters.putAll(queryParams); } // if the view doesn't exist, let's do a 404 if (dispatcher == null) { response.sendError(404, "result '" + finalLocation + "' not found"); return; } //if we are inside an action tag, we always need to do an include Boolean insideActionTag = (Boolean) ObjectUtils.defaultIfNull(request.getAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION), Boolean.FALSE); // If we're included, then include the view // Otherwise do forward // This allow the page to, for example, set content type if (!insideActionTag && !response.isCommitted() && (request.getAttribute("javax.servlet.include.servlet_path") == null)) { request.setAttribute("struts.view_uri", finalLocation); request.setAttribute("struts.request_uri", request.getRequestURI()); dispatcher.forward(request, response); } else { dispatcher.include(request, response); } } }
// in java/org/apache/struts2/dispatcher/PlainTextResult.java
protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { // verify charset Charset charset = readCharset(); HttpServletResponse response = (HttpServletResponse) invocation.getInvocationContext().get(HTTP_RESPONSE); applyCharset(charset, response); applyAdditionalHeaders(response); String location = adjustLocation(finalLocation); PrintWriter writer = response.getWriter(); InputStreamReader reader = null; try { InputStream resourceAsStream = readStream(invocation, location); logWrongStream(finalLocation, resourceAsStream); if (charset != null) { reader = new InputStreamReader(resourceAsStream, charset); } else { reader = new InputStreamReader(resourceAsStream); } if (resourceAsStream != null) { sendStream(writer, reader); } } finally { if (reader != null) reader.close(); if (writer != null) { writer.flush(); writer.close(); } } }
// in java/org/apache/struts2/dispatcher/ServletRedirectResult.java
public void execute(ActionInvocation invocation) throws Exception { if (anchor != null) { anchor = conditionalParse(anchor, invocation); } super.execute(invocation); }
// in java/org/apache/struts2/dispatcher/ServletRedirectResult.java
protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { ActionContext ctx = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST); HttpServletResponse response = (HttpServletResponse) ctx.get(ServletActionContext.HTTP_RESPONSE); if (isPathUrl(finalLocation)) { if (!finalLocation.startsWith("/")) { ActionMapping mapping = actionMapper.getMapping(request, Dispatcher.getInstance().getConfigurationManager()); String namespace = null; if (mapping != null) { namespace = mapping.getNamespace(); } if ((namespace != null) && (namespace.length() > 0) && (!"/".equals(namespace))) { finalLocation = namespace + "/" + finalLocation; } else { finalLocation = "/" + finalLocation; } } // if the URL's are relative to the servlet context, append the servlet context path if (prependServletContext && (request.getContextPath() != null) && (request.getContextPath().length() > 0)) { finalLocation = request.getContextPath() + finalLocation; } ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode()); if (resultConfig != null) { Map<String, String> resultConfigParams = resultConfig.getParams(); for (Map.Entry<String, String> e : resultConfigParams.entrySet()) { if (!getProhibitedResultParams().contains(e.getKey())) { String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue(), invocation); if (!suppressEmptyParameters || ((potentialValue != null) && (potentialValue.length() > 0))) { requestParameters.put(e.getKey(), potentialValue); } } } } StringBuilder tmpLocation = new StringBuilder(finalLocation); urlHelper.buildParametersString(requestParameters, tmpLocation, "&"); // add the anchor if (anchor != null) { tmpLocation.append('#').append(anchor); } finalLocation = response.encodeRedirectURL(tmpLocation.toString()); } if (LOG.isDebugEnabled()) { LOG.debug("Redirecting to finalLocation " + finalLocation); } sendRedirect(response, finalLocation); }
// in java/org/apache/struts2/dispatcher/DefaultActionSupport.java
public String execute() throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); String requestedUrl = request.getPathInfo(); if (successResultValue == null) successResultValue = requestedUrl; return SUCCESS; }
// in java/org/apache/struts2/util/StrutsTestCaseHelper.java
public static void setUp() throws Exception { LocalizedTextUtil.clearDefaultResourceBundles(); }
// in java/org/apache/struts2/util/StrutsTestCaseHelper.java
public static void tearDown() throws Exception { Dispatcher.setInstance(null); ActionContext.setContext(null); }
// in java/org/apache/struts2/util/StrutsUtil.java
public Object bean(Object aName) throws Exception { String name = aName.toString(); Class c = classes.get(name); if (c == null) { c = ClassLoaderUtil.loadClass(name, StrutsUtil.class); classes.put(name, c); } return objectFactory.buildBean(c, stack.getContext()); }
// in java/org/apache/struts2/util/StrutsUtil.java
public String include(Object aName) throws Exception { return include(aName, request, response); }
// in java/org/apache/struts2/util/StrutsUtil.java
public String include(Object aName, HttpServletRequest aRequest, HttpServletResponse aResponse) throws Exception { try { RequestDispatcher dispatcher = aRequest.getRequestDispatcher(aName.toString()); if (dispatcher == null) { throw new IllegalArgumentException("Cannot find included file " + aName); } ResponseWrapper responseWrapper = new ResponseWrapper(aResponse); dispatcher.include(aRequest, responseWrapper); return responseWrapper.getData(); } catch (Exception e) { e.printStackTrace(); throw e; } }
51
            
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (Exception ex) { LOG.error("Unable to create debugging console", ex); }
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (Exception ex) { LOG.error("Unable to create debugging console", ex); }
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (Exception e) { LOG.error(e.toString(), e); }
// in java/org/apache/struts2/interceptor/debugging/ObjectToHTMLWriter.java
catch (Exception e) { return true; }
// in java/org/apache/struts2/interceptor/debugging/ObjectToHTMLWriter.java
catch (Exception e) { return true; }
// in java/org/apache/struts2/interceptor/BackgroundProcess.java
catch (Exception e) { exception = e; }
// in java/org/apache/struts2/interceptor/BackgroundProcess.java
catch (Exception e) { exception = e; }
// in java/org/apache/struts2/config/DefaultSettings.java
catch (Exception e) { log.warn("DefaultSettings: Could not find or error in struts.properties", e); }
// in java/org/apache/struts2/config/DefaultSettings.java
catch (Exception e) { log.error("DefaultSettings: Could not find " + name + ".properties. Skipping."); }
// in java/org/apache/struts2/config/Settings.java
catch (Exception e) { LOG.error("Settings: Could not instantiate the struts.configuration object, substituting the default implementation.", e); }
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); }
// in java/org/apache/struts2/config/BeanSelectionProvider.java
catch (Exception e) { LOG.error("Could not find messages file " + name + ".properties. Skipping"); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); }
// in java/org/apache/struts2/components/I18n.java
catch (Exception e) { String msg = "Could not find the bundle " + name; throw new StrutsException(msg, e); }
// in java/org/apache/struts2/components/Date.java
catch (Exception e) { LOG.error("Could not convert object with key '" + name + "' to a java.util.Date instance"); // bad date, return a blank instead ? msg = ""; }
// in java/org/apache/struts2/components/template/JspTemplateEngine.java
catch (Exception e) { if (exception == null) { exception = e; } }
// in java/org/apache/struts2/components/Anchor.java
catch (Exception e) { LOG.error("error when rendering", e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to put request parameters (" + urlComponent.getHttpServletRequest().getQueryString() + ") into parameter map.", e); } }
// in java/org/apache/struts2/components/Number.java
catch (Exception e) { LOG.error("Could not convert object with key [" + name + "] to a java.lang.Number instance"); }
// in java/org/apache/struts2/components/Number.java
catch (Exception e) { LOG.error("Could not find [" + NUMBERTAG_PROPERTY + "] on the stack!", e); }
// in java/org/apache/struts2/components/Component.java
catch (Exception e) { problem = e; }
// in java/org/apache/struts2/components/Debug.java
catch (Exception e) { throw new StrutsException("Caught an exception while getting the property values of " + o, e); }
// in java/org/apache/struts2/components/UIBean.java
catch (Exception e) { throw new StrutsException(e); }
// in java/org/apache/struts2/components/Bean.java
catch (Exception e) { LOG.error("Could not instantiate bean", e); return false;
// in java/org/apache/struts2/components/ClosingUIBean.java
catch (Exception e) { LOG.error("Could not open template", e); e.printStackTrace(); }
// in java/org/apache/struts2/components/Include.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to url-encode "+values.get(i).toString()+", it will be ignored");
// in java/org/apache/struts2/components/Include.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Exception thrown during include of " + result, e); } }
// in java/org/apache/struts2/components/ActionComponent.java
catch (Exception e) { String message = "Could not execute action: " + namespace + "/" + actualName; LOG.error(message, e); if (rethrowException) { throw new StrutsException(message, e); } }
// in java/org/apache/struts2/components/Submit.java
catch (Exception e) { LOG.error("error when rendering", e); }
// in java/org/apache/struts2/views/jsp/IteratorTag.java
catch (Exception e) { throw new JspException(e.getMessage()); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
catch (Exception e) { LOG.error("Unable to render XSLT Template, '" + location + "'", e); throw e; }
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (Exception e) { if (e instanceof InvocationTargetException) e = (Exception) ((InvocationTargetException) e).getTargetException(); log.error("Cannot access bean property: "+propertyName, e); continue; }
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (Exception ex) { // Could not encode the URL for some reason // Use it unchanged result = link.toString(); }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Warning. " + e.getClass().getName() + " caught while attempting to instantiate a chained VelocityContext, " + className + " -- skipping"); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); }
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch(Exception e) { // catch any exception that may occurred during destroy() and log it LOG.error("exception occurred while destroying ObjectFactory ["+objectFactory+"]", e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception e) { sendError(request, response, context, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception e) { LOG.error("Error setting character encoding to '" + encoding + "' - ignoring.", e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception exp) { try { response.sendError(code, "Unable to show problem report: " + exp); } catch (IOException ex) { // we're already sending an error, not much else we can do if more stuff breaks } }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (Exception e) { log.warn("Invalid If-Modified-Since header value: '" + request.getHeader("If-Modified-Since") + "', ignoring"); }
// in java/org/apache/struts2/dispatcher/VelocityResult.java
catch (Exception e) { LOG.error("Unable to render Velocity Template, '" + finalLocation + "'", e); throw e; }
// in java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to determine parameters from the url", e); } }
// in java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java
catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Cannot determine url parameters", e); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (Exception ex) { dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (Exception ex) { log.error("error getting ActionMapping", ex); dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); return; }
// in java/org/apache/struts2/util/IteratorGenerator.java
catch(Exception e) { // make sure things, goes on, we just ignore the bad ones if (LOG.isWarnEnabled()) { LOG.warn("unable to convert ["+token+"], skipping this token, it will not appear in the generated iterator", e); } }
// in java/org/apache/struts2/util/SortIteratorFilter.java
catch (Exception e) { LoggerFactory.getLogger(SortIteratorFilter.class.getName()).warn("Error creating sort iterator.", e); return ERROR; }
// in java/org/apache/struts2/util/StrutsUtil.java
catch (Exception e) { e.printStackTrace(); throw e; }
// in java/org/apache/struts2/util/SubsetIteratorFilter.java
catch(Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("decider ["+decider+"] encountered an error while decide adding element ["+element+"], element will be ignored, it will not appeared in subseted iterator", e); } return false; }
13
            
// in java/org/apache/struts2/config/DefaultPropertiesProvider.java
catch (Exception e) { throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e); }
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (Exception e) { throw new ConfigurationException( "Caught Exception while registering Interceptor class " + className, e, interceptorConfig); }
// in java/org/apache/struts2/components/I18n.java
catch (Exception e) { String msg = "Could not find the bundle " + name; throw new StrutsException(msg, e); }
// in java/org/apache/struts2/components/Debug.java
catch (Exception e) { throw new StrutsException("Caught an exception while getting the property values of " + o, e); }
// in java/org/apache/struts2/components/UIBean.java
catch (Exception e) { throw new StrutsException(e); }
// in java/org/apache/struts2/components/ActionComponent.java
catch (Exception e) { String message = "Could not execute action: " + namespace + "/" + actualName; LOG.error(message, e); if (rethrowException) { throw new StrutsException(message, e); } }
// in java/org/apache/struts2/views/jsp/IteratorTag.java
catch (Exception e) { throw new JspException(e.getMessage()); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
catch (Exception e) { LOG.error("Unable to render XSLT Template, '" + location + "'", e); throw e; }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); }
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); }
// in java/org/apache/struts2/dispatcher/VelocityResult.java
catch (Exception e) { LOG.error("Unable to render Velocity Template, '" + finalLocation + "'", e); throw e; }
// in java/org/apache/struts2/util/StrutsUtil.java
catch (Exception e) { e.printStackTrace(); throw e; }
0
unknown (Lib) FileNotFoundException 0 0 1
            
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
private InputStream createFileInputStream(File propFile) throws FileNotFoundException { InputStream is = null; if (propFile.exists()) { is = new FileInputStream(propFile); } return is; }
1
            
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (FileNotFoundException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to find file in filesystem [" + propFile.getAbsolutePath() + "]"); } return null; }
0 0
unknown (Lib) FileUploadException 0 0 2
            
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
private void processUpload(HttpServletRequest request, String saveDir) throws FileUploadException, UnsupportedEncodingException { for (FileItem item : parseRequest(request, saveDir)) { if (LOG.isDebugEnabled()) { LOG.debug("Found item " + item.getFieldName()); } if (item.isFormField()) { processNormalFormField(item, request.getCharacterEncoding()); } else { processFileField(item); } } }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
private List<FileItem> parseRequest(HttpServletRequest servletRequest, String saveDir) throws FileUploadException { DiskFileItemFactory fac = createDiskFileItemFactory(saveDir); ServletFileUpload upload = new ServletFileUpload(fac); upload.setSizeMax(maxSize); return upload.parseRequest(createRequestContext(servletRequest)); }
1
            
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (FileUploadException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to parse request", e); } errors.add(e.getMessage()); }
0 0
checked (Lib) IOException 6
            
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
protected URL findInFileSystem(String fileName) throws IOException { URL url = null; File file = new File(fileName); if (LOG.isDebugEnabled()) { LOG.debug("Trying to load file " + file); } // Trying relative path to original file if (!file.exists()) { file = new File(baseDir, fileName); } if (file.exists()) { try { url = file.toURI().toURL(); } catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); } } return url; }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
protected void loadSettings(ServletContext servletContext) { InputStream in = null; try { in = fileManager.loadFile(ClassLoaderUtil.getResource("freemarker.properties", getClass())); if (in != null) { Properties p = new Properties(); p.load(in); for (Object o : p.keySet()) { String name = (String) o; String value = (String) p.get(name); if (name == null) { throw new IOException( "init-param without param-name. Maybe the freemarker.properties is not well-formed?"); } if (value == null) { throw new IOException( "init-param without param-value. Maybe the freemarker.properties is not well-formed?"); } addSetting(name, value); } } } catch (IOException e) { LOG.error("Error while loading freemarker settings from /freemarker.properties", e); } catch (TemplateException e) { LOG.error("Error while loading freemarker settings from /freemarker.properties", e); } finally { if (in != null) { try { in.close(); } catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } } } } }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
public InputStream getInputStream() throws IOException { InputStream in = req.getInputStream(); if (in == null) { throw new IOException("Missing content in the request"); } return req.getInputStream(); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(int datum) throws IOException { if (closed) { throw new IOException("Stream closed"); } if (index == blockSize) { addBuffer(); } buffer[index++] = (byte) datum; }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(byte data[], int offset, int length) throws IOException { if (data == null) { throw new NullPointerException(); } if (offset < 0 || offset + length > data.length || length < 0) { throw new IndexOutOfBoundsException(); } if (closed) { throw new IOException("Stream closed"); } if (index + length > blockSize) { do { if (index == blockSize) { addBuffer(); } int copyLength = blockSize - index; if (length < copyLength) { copyLength = length; } System.arraycopy(data, offset, buffer, index, copyLength); offset += copyLength; index += copyLength; length -= copyLength; } while (length > 0); } else { System.arraycopy(data, offset, buffer, index, length); index += length; } }
1
            
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); }
56
            
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
Override protected Iterator<URL> getConfigurationUrls(String fileName) throws IOException { URL url = null; if (baseDir != null) { url = findInFileSystem(fileName); if (url == null) { return super.getConfigurationUrls(fileName); } } if (url != null) { List<URL> list = new ArrayList<URL>(); list.add(url); return list.iterator(); } else { return super.getConfigurationUrls(fileName); } }
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
protected URL findInFileSystem(String fileName) throws IOException { URL url = null; File file = new File(fileName); if (LOG.isDebugEnabled()) { LOG.debug("Trying to load file " + file); } // Trying relative path to original file if (!file.exists()) { file = new File(baseDir, fileName); } if (file.exists()) { try { url = file.toURI().toURL(); } catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); } } return url; }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
public void renderTemplate(TemplateRenderingContext templateContext) throws Exception { // get the various items required from the stack ValueStack stack = templateContext.getStack(); Map context = stack.getContext(); ServletContext servletContext = (ServletContext) context.get(ServletActionContext.SERVLET_CONTEXT); HttpServletRequest req = (HttpServletRequest) context.get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) context.get(ServletActionContext.HTTP_RESPONSE); // prepare freemarker Configuration config = freemarkerManager.getConfiguration(servletContext); // get the list of templates we can use List<Template> templates = templateContext.getTemplate().getPossibleTemplates(this); // find the right template freemarker.template.Template template = null; String templateName = null; Exception exception = null; for (Template t : templates) { templateName = getFinalTemplateName(t); try { // try to load, and if it works, stop at the first one template = config.getTemplate(templateName); break; } catch (ParseException e) { // template was found but was invalid - always report this. exception = e; break; } catch (IOException e) { // FileNotFoundException is anticipated - report the first IOException if no template found if (exception == null) { exception = e; } } } if (template == null) { if (LOG.isErrorEnabled()) { LOG.error("Could not load the FreeMarker template named '" + templateContext.getTemplate().getName() +"':"); for (Template t : templates) { LOG.error("Attempted: " + getFinalTemplateName(t)); } LOG.error("The TemplateLoader provided by the FreeMarker Configuration was a: "+config.getTemplateLoader().getClass().getName()); } if (exception != null) { throw exception; } else { return; } } if (LOG.isDebugEnabled()) { LOG.debug("Rendering template " + templateName); } ActionInvocation ai = ActionContext.getContext().getActionInvocation(); Object action = (ai == null) ? null : ai.getAction(); SimpleHash model = freemarkerManager.buildTemplateModel(stack, action, servletContext, req, res, config.getObjectWrapper()); model.put("tag", templateContext.getTag()); model.put("themeProperties", getThemeProps(templateContext.getTemplate())); // the BodyContent JSP writer doesn't like it when FM flushes automatically -- // so let's just not do it (it will be flushed eventually anyway) Writer writer = templateContext.getWriter(); final Writer wrapped = writer; writer = new Writer() { public void write(char cbuf[], int off, int len) throws IOException { wrapped.write(cbuf, off, len); } public void flush() throws IOException { // nothing! } public void close() throws IOException { wrapped.close(); } }; try { stack.push(templateContext.getTag()); template.process(model, writer); } finally { stack.pop(); } }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
public void write(char cbuf[], int off, int len) throws IOException { wrapped.write(cbuf, off, len); }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
public void flush() throws IOException { // nothing! }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
public void close() throws IOException { wrapped.close(); }
// in java/org/apache/struts2/components/Include.java
public static void include( String relativePath, Writer writer, ServletRequest request, HttpServletResponse response ) throws ServletException, IOException { include(relativePath, writer, request, response, null); }
// in java/org/apache/struts2/components/Include.java
public static void include( String relativePath, Writer writer, ServletRequest request, HttpServletResponse response, String encoding ) throws ServletException, IOException { String resourcePath = getContextRelativePath(request, relativePath); RequestDispatcher rd = request.getRequestDispatcher(resourcePath); if (rd == null) { throw new ServletException("Not a valid resource path:" + resourcePath); } PageResponse pageResponse = new PageResponse(response); // Include the resource rd.include(request, pageResponse); if (encoding != null) { // Use given encoding pageResponse.getContent().writeTo(writer, encoding); } else { //use the platform specific encoding pageResponse.getContent().writeTo(writer, systemEncoding); } }
// in java/org/apache/struts2/components/Include.java
public FastByteArrayOutputStream getBuffer() throws IOException { flush(); return buffer; }
// in java/org/apache/struts2/components/Include.java
public void close() throws IOException { buffer.close(); }
// in java/org/apache/struts2/components/Include.java
public void flush() throws IOException { buffer.flush(); }
// in java/org/apache/struts2/components/Include.java
public void write(byte[] b, int o, int l) throws IOException { buffer.write(b, o, l); }
// in java/org/apache/struts2/components/Include.java
public void write(int i) throws IOException { buffer.write(i); }
// in java/org/apache/struts2/components/Include.java
public void write(byte[] b) throws IOException { buffer.write(b); }
// in java/org/apache/struts2/components/Include.java
public FastByteArrayOutputStream getContent() throws IOException { //if we are using a writer, we need to flush the //data to the underlying outputstream. //most containers do this - but it seems Jetty 4.0.5 doesn't if (pagePrintWriter != null) { pagePrintWriter.flush(); } return ((PageOutputStream) getOutputStream()).getBuffer(); }
// in java/org/apache/struts2/components/Include.java
public ServletOutputStream getOutputStream() throws IOException { if (pageOutputStream == null) { pageOutputStream = new PageOutputStream(); } return pageOutputStream; }
// in java/org/apache/struts2/components/Include.java
public PrintWriter getWriter() throws IOException { if (pagePrintWriter == null) { pagePrintWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), getCharacterEncoding())); } return pagePrintWriter; }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public void close() throws IOException { if (bean.usesBody()) { body.close(); } }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public void flush() throws IOException { writer.flush(); if (bean.usesBody()) { body.flush(); } }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public void write(char cbuf[], int off, int len) throws IOException { if (bean.usesBody() && !afterBody) { body.write(cbuf, off, len); } else { writer.write(cbuf, off, len); } }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public int onStart() throws TemplateModelException, IOException { boolean result = bean.start(this); if (result) { return EVALUATE_BODY; } else { return SKIP_BODY; } }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public int afterBody() throws TemplateModelException, IOException { afterBody = true; boolean result = bean.end(this, bean.usesBody() ? body.toString() : ""); if (result) { return REPEAT_EVALUATION; } else { return END_EVALUATION; } }
// in java/org/apache/struts2/views/freemarker/tags/TagModel.java
public Writer getWriter(Writer writer, Map params) throws TemplateModelException, IOException { Component bean = getBean(); Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); Map unwrappedParameters = unwrapParameters(params); bean.copyParams(unwrappedParameters); return new CallbackWriter(bean, writer); }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
public void doExecute(String locationArg, ActionInvocation invocation) throws IOException, TemplateException { this.location = locationArg; this.invocation = invocation; this.configuration = getConfiguration(); this.wrapper = getObjectWrapper(); ActionContext ctx = invocation.getInvocationContext(); HttpServletRequest req = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST); if (!locationArg.startsWith("/")) { String base = ResourceUtil.getResourceBase(req); locationArg = base + "/" + locationArg; } Template template = configuration.getTemplate(locationArg, deduceLocale()); TemplateModel model = createModel(); // Give subclasses a chance to hook into preprocessing if (preTemplateProcess(template, model)) { try { // Process the template Writer writer = getWriter(); if (isWriteIfCompleted() || configuration.getTemplateExceptionHandler() == TemplateExceptionHandler.RETHROW_HANDLER) { CharArrayWriter parentCharArrayWriter = (CharArrayWriter) req.getAttribute(PARENT_TEMPLATE_WRITER); boolean isTopTemplate = false; if (isTopTemplate = (parentCharArrayWriter == null)) { //this is the top template parentCharArrayWriter = new CharArrayWriter(); //set it in the request because when the "action" tag is used a new VS and ActionContext is created req.setAttribute(PARENT_TEMPLATE_WRITER, parentCharArrayWriter); } try { template.process(model, parentCharArrayWriter); if (isTopTemplate) { parentCharArrayWriter.flush(); parentCharArrayWriter.writeTo(writer); } } finally { if (isTopTemplate && parentCharArrayWriter != null) { req.removeAttribute(PARENT_TEMPLATE_WRITER); parentCharArrayWriter.close(); } } } else { template.process(model, writer); } } finally { // Give subclasses a chance to hook into postprocessing postTemplateProcess(template, model); } } }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
protected Writer getWriter() throws IOException { if(writer != null) { return writer; } return ServletActionContext.getResponse().getWriter(); }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
protected void postTemplateProcess(Template template, TemplateModel data) throws IOException { }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
protected boolean preTemplateProcess(Template template, TemplateModel model) throws IOException { Object attrContentType = template.getCustomAttribute("content_type"); HttpServletResponse response = ServletActionContext.getResponse(); if (response.getContentType() == null) { if (attrContentType != null) { response.setContentType(attrContentType.toString()); } else { String contentType = getContentType(); if (contentType == null) { contentType = "text/html"; } String encoding = template.getEncoding(); if (encoding != null) { contentType = contentType + "; charset=" + encoding; } response.setContentType(contentType); } } else if(isInsideActionTag()){ //trigger com.opensymphony.module.sitemesh.filter.PageResponseWrapper.deactivateSiteMesh() response.setContentType(response.getContentType()); } return true; }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
protected Templates getTemplates(String path) throws TransformerException, IOException { String pathFromRequest = ServletActionContext.getRequest().getParameter("xslt.location"); if (pathFromRequest != null) path = pathFromRequest; if (path == null) throw new TransformerException("Stylesheet path is null"); Templates templates = templatesCache.get(path); if (noCache || (templates == null)) { synchronized (templatesCache) { URL resource = ServletActionContext.getServletContext().getResource(path); if (resource == null) { throw new TransformerException("Stylesheet " + path + " not found in resources."); } if (LOG.isDebugEnabled()) { LOG.debug("Preparing XSLT stylesheet templates: " + path); } TransformerFactory factory = TransformerFactory.newInstance(); factory.setURIResolver(getURIResolver()); templates = factory.newTemplates(new StreamSource(resource.openStream())); templatesCache.put(path, templates); } } return templates; }
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { // get the bean ValueStack stack = (ValueStack) ctx.get("stack"); HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE); Component bean = getBean(stack, req, res); Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); // get the parameters Map params = createPropertyMap(ctx, node); bean.copyParams(params); //bean.addAllParameters(params); bean.start(writer); if (getType() == BLOCK) { Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1); body.render(ctx, writer); } bean.end(writer, ""); return true; }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
private RequestContext createRequestContext(final HttpServletRequest req) { return new RequestContext() { public String getCharacterEncoding() { return req.getCharacterEncoding(); } public String getContentType() { return req.getContentType(); } public int getContentLength() { return req.getContentLength(); } public InputStream getInputStream() throws IOException { InputStream in = req.getInputStream(); if (in == null) { throw new IOException("Missing content in the request"); } return req.getInputStream(); } }; }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
public InputStream getInputStream() throws IOException { InputStream in = req.getInputStream(); if (in == null) { throw new IOException("Missing content in the request"); } return req.getInputStream(); }
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String timerKey = "ActionContextCleanUp_doFilter: "; try { UtilTimerStack.push(timerKey); try { Integer count = (Integer)request.getAttribute(COUNTER); if (count == null) { count = Integer.valueOf(1); } else { count = Integer.valueOf(count.intValue()+1); } request.setAttribute(COUNTER, count); //LOG.debug("filtering counter="+count); chain.doFilter(request, response); } finally { int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue(); counterVal -= 1; request.setAttribute(COUNTER, Integer.valueOf(counterVal)); cleanUp(request); } } finally { UtilTimerStack.pop(timerKey); } }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException { // don't wrap more than once if (request instanceof StrutsRequestWrapper) { return request; } String content_type = request.getContentType(); if (content_type != null && content_type.contains("multipart/form-data")) { MultiPartRequest mpr = null; //check for alternate implementations of MultiPartRequest Set<String> multiNames = getContainer().getInstanceNames(MultiPartRequest.class); if (multiNames != null) { for (String multiName : multiNames) { if (multiName.equals(multipartHandlerName)) { mpr = getContainer().getInstance(MultiPartRequest.class, multiName); } } } if (mpr == null ) { mpr = getContainer().getInstance(MultiPartRequest.class); } request = new MultiPartRequestWrapper(mpr, request, getSaveDir(servletContext)); } else { request = new StrutsRequestWrapper(request); } return request; }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void cleanUpRequest(HttpServletRequest request) throws IOException { if (!(request instanceof MultiPartRequestWrapper)) { return; } MultiPartRequestWrapper multiWrapper = (MultiPartRequestWrapper) request; Enumeration fileParameterNames = multiWrapper.getFileParameterNames(); while (fileParameterNames != null && fileParameterNames.hasMoreElements()) { String inputValue = (String) fileParameterNames.nextElement(); File[] files = multiWrapper.getFiles(inputValue); for (File currentFile : files) { if (LOG.isInfoEnabled()) { String msg = LocalizedTextUtil.findText(this.getClass(), "struts.messages.removing.file", Locale.ENGLISH, "no.message.found", new Object[]{inputValue, currentFile}); LOG.info(msg); } if ((currentFile != null) && currentFile.isFile()) { if (!currentFile.delete()) { if (LOG.isWarnEnabled()) { LOG.warn("Resource Leaking: Could not remove uploaded file '" + currentFile.getCanonicalPath() + "'."); } } } } } }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
public void findStaticResource(String path, HttpServletRequest request, HttpServletResponse response) throws IOException { String name = cleanupPath(path); for (String pathPrefix : pathPrefixes) { URL resourceUrl = findResource(buildPath(name, pathPrefix)); if (resourceUrl != null) { InputStream is = null; try { //check that the resource path is under the pathPrefix path String pathEnding = buildPath(name, pathPrefix); if (resourceUrl.getFile().endsWith(pathEnding)) is = resourceUrl.openStream(); } catch (IOException ex) { // just ignore it continue; } //not inside the try block, as this could throw IOExceptions also if (is != null) { process(is, path, request, response); return; } } } response.sendError(HttpServletResponse.SC_NOT_FOUND); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
protected void process(InputStream is, String path, HttpServletRequest request, HttpServletResponse response) throws IOException { if (is != null) { Calendar cal = Calendar.getInstance(); // check for if-modified-since, prior to any other headers long ifModifiedSince = 0; try { ifModifiedSince = request.getDateHeader("If-Modified-Since"); } catch (Exception e) { log.warn("Invalid If-Modified-Since header value: '" + request.getHeader("If-Modified-Since") + "', ignoring"); } long lastModifiedMillis = lastModifiedCal.getTimeInMillis(); long now = cal.getTimeInMillis(); cal.add(Calendar.DAY_OF_MONTH, 1); long expires = cal.getTimeInMillis(); if (ifModifiedSince > 0 && ifModifiedSince <= lastModifiedMillis) { // not modified, content is not sent - only basic // headers and status SC_NOT_MODIFIED response.setDateHeader("Expires", expires); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); is.close(); return; } // set the content-type header String contentType = getContentType(path); if (contentType != null) { response.setContentType(contentType); } if (serveStaticBrowserCache) { // set heading information for caching static content response.setDateHeader("Date", now); response.setDateHeader("Expires", expires); response.setDateHeader("Retry-After", expires); response.setHeader("Cache-Control", "public"); response.setDateHeader("Last-Modified", lastModifiedMillis); } else { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setHeader("Expires", "-1"); } try { copy(is, response.getOutputStream()); } finally { is.close(); } return; } }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
protected URL findResource(String path) throws IOException { return ClassLoaderUtil.getResource(path, getClass()); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
protected void copy(InputStream input, OutputStream output) throws IOException { final byte[] buffer = new byte[4096]; int n; while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); } output.flush(); }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; if (excludeUrl(request)) { chain.doFilter(request, response); return; } // This is necessary since we need the dispatcher instance, which was created by the prepare filter if (execute == null) { lazyInit(); } ActionMapping mapping = prepare.findActionMapping(request, response); //if recusrion counter is > 1, it means we are in a "forward", in that case a mapping will still be //in the request, if we handle it, it will lead to an infinte loop, see WW-3077 Integer recursionCounter = (Integer) request.getAttribute(PrepareOperations.CLEANUP_RECURSION_COUNTER); if (mapping == null || recursionCounter > 1) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) { chain.doFilter(request, response); } } else { execute.executeAction(request, response, mapping); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; try { prepare.setEncodingAndLocale(request, response); prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); if ( excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) { chain.doFilter(request, response); } else { request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response, true); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) { chain.doFilter(request, response); } } else { execute.executeAction(request, response, mapping); } } } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; try { prepare.setEncodingAndLocale(request, response); prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); if ( excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) { request.setAttribute(REQUEST_EXCLUDED_FROM_ACTION_MAPPING, new Object()); } else { request = prepare.wrapRequest(request); prepare.findActionMapping(request, response); } chain.doFilter(request, response); } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); prepare.setEncodingAndLocale(request, response); request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) throw new ServletException("Resource loading not supported, use the StrutsPrepareAndExecuteFilter instead."); } else { execute.executeAction(request, response, mapping); } } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/ExecuteOperations.java
public boolean executeStaticResourceRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // there is no action in this request, should we look for a static resource? String resourcePath = RequestUtils.getServletPath(request); if ("".equals(resourcePath) && null != request.getPathInfo()) { resourcePath = request.getPathInfo(); } StaticContentLoader staticResourceLoader = dispatcher.getContainer().getInstance(StaticContentLoader.class); if (staticResourceLoader.canHandle(resourcePath)) { staticResourceLoader.findStaticResource(resourcePath, request, response); // The framework did its job here return true; } else { // this is a normal request, let it pass through return false; } }
// in java/org/apache/struts2/dispatcher/PlainTextResult.java
protected void sendStream(PrintWriter writer, InputStreamReader reader) throws IOException { char[] buffer = new char[BUFFER_SIZE]; int charRead; while((charRead = reader.read(buffer)) != -1) { writer.write(buffer, 0, charRead); } }
// in java/org/apache/struts2/dispatcher/ServletRedirectResult.java
protected void sendRedirect(HttpServletResponse response, String finalLocation) throws IOException { if (SC_FOUND == statusCode) { response.sendRedirect(finalLocation); } else { response.setStatus(statusCode); response.setHeader("Location", finalLocation); response.getWriter().write(finalLocation); response.getWriter().close(); } }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; ServletContext servletContext = getServletContext(); String timerKey = "FilterDispatcher_doFilter: "; try { // FIXME: this should be refactored better to not duplicate work with the action invocation ValueStack stack = dispatcher.getContainer().getInstance(ValueStackFactory.class).createValueStack(); ActionContext ctx = new ActionContext(stack.getContext()); ActionContext.setContext(ctx); UtilTimerStack.push(timerKey); request = prepareDispatcherAndWrapRequest(request, response); ActionMapping mapping; try { mapping = actionMapper.getMapping(request, dispatcher.getConfigurationManager()); } catch (Exception ex) { log.error("error getting ActionMapping", ex); dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); return; } if (mapping == null) { // there is no action in this request, should we look for a static resource? String resourcePath = RequestUtils.getServletPath(request); if ("".equals(resourcePath) && null != request.getPathInfo()) { resourcePath = request.getPathInfo(); } if (staticResourceLoader.canHandle(resourcePath)) { staticResourceLoader.findStaticResource(resourcePath, request, response); } else { // this is a normal request, let it pass through chain.doFilter(request, response); } // The framework did its job here return; } dispatcher.serviceAction(request, response, servletContext, mapping); } finally { dispatcher.cleanUpRequest(request); try { ActionContextCleanUp.cleanUp(req); } finally { UtilTimerStack.pop(timerKey); } devModeOverride.remove(); } }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void writeTo(OutputStream out) throws IOException { if (buffers != null) { for (byte[] bytes : buffers) { out.write(bytes, 0, blockSize); } } out.write(buffer, 0, index); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void writeTo(RandomAccessFile out) throws IOException { if (buffers != null) { for (byte[] bytes : buffers) { out.write(bytes, 0, blockSize); } } out.write(buffer, 0, index); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void writeTo(Writer out, String encoding) throws IOException { if (encoding != null) { CharsetDecoder decoder = getDecoder(encoding); // Create buffer for characters decoding CharBuffer charBuffer = CharBuffer.allocate(buffer.length); // Create buffer for bytes float bytesPerChar = decoder.charset().newEncoder().maxBytesPerChar(); ByteBuffer byteBuffer = ByteBuffer.allocate((int) (buffer.length + bytesPerChar)); if (buffers != null) { for (byte[] bytes : buffers) { decodeAndWriteOut(out, bytes, bytes.length, byteBuffer, charBuffer, decoder, false); } } decodeAndWriteOut(out, buffer, index, byteBuffer, charBuffer, decoder, true); } else { if (buffers != null) { for (byte[] bytes : buffers) { writeOut(out, bytes, bytes.length); } } writeOut(out, buffer, index); } }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void writeTo(JspWriter out, String encoding) throws IOException { try { writeTo((Writer) out, encoding); } catch (IOException e) { writeToFile(); throw e; } catch (Throwable e) { writeToFile(); throw new RuntimeException(e); } }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
private void writeOut(Writer out, byte[] bytes, int length) throws IOException { out.write(new String(bytes, 0, length)); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
private static void decodeAndWriteOut(Writer writer, byte[] bytes, int length, ByteBuffer in, CharBuffer out, CharsetDecoder decoder, boolean endOfInput) throws IOException { // Append bytes to current buffer // Previous data maybe partially decoded, this part will appended to previous in.put(bytes, 0, length); // To begin of data in.flip(); decodeAndWriteBuffered(writer, in, out, decoder, endOfInput); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
private static void decodeAndWriteBuffered(Writer writer, ByteBuffer in, CharBuffer out, CharsetDecoder decoder, boolean endOfInput) throws IOException { // Decode CoderResult result; do { result = decodeAndWrite(writer, in, out, decoder, endOfInput); // Check that all data are decoded if (in.hasRemaining()) { // Move remaining to top of buffer in.compact(); if (result.isOverflow() && !result.isError() && !result.isMalformed()) { // Not all buffer chars decoded, spin it again // Set to begin in.flip(); } } else { // Clean up buffer in.clear(); } } while (in.hasRemaining() && result.isOverflow() && !result.isError() && !result.isMalformed()); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
private static CoderResult decodeAndWrite(Writer writer, ByteBuffer in, CharBuffer out, CharsetDecoder decoder, boolean endOfInput) throws IOException { CoderResult result = decoder.decode(in, out, endOfInput); // To begin of decoded data out.flip(); // Output writer.write(out.toString()); return result; }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(int datum) throws IOException { if (closed) { throw new IOException("Stream closed"); } if (index == blockSize) { addBuffer(); } buffer[index++] = (byte) datum; }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(byte data[], int offset, int length) throws IOException { if (data == null) { throw new NullPointerException(); } if (offset < 0 || offset + length > data.length || length < 0) { throw new IndexOutOfBoundsException(); } if (closed) { throw new IOException("Stream closed"); } if (index + length > blockSize) { do { if (index == blockSize) { addBuffer(); } int copyLength = blockSize - index; if (length < copyLength) { copyLength = length; } System.arraycopy(data, offset, buffer, index, copyLength); offset += copyLength; index += copyLength; length -= copyLength; } while (length > 0); } else { System.arraycopy(data, offset, buffer, index, length); index += length; } }
// in java/org/apache/struts2/util/VelocityStrutsUtil.java
public String evaluate(String expression) throws IOException, ResourceNotFoundException, MethodInvocationException, ParseErrorException { CharArrayWriter writer = new CharArrayWriter(); velocityEngine.evaluate(ctx, writer, "Error parsing " + expression, expression); return writer.toString(); }
// in java/org/apache/struts2/util/StrutsUtil.java
public PrintWriter getWriter() throws IOException { return writer; }
33
            
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (IOException ex) { ex.printStackTrace(); }
// in java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
catch (IOException ex) { ex.printStackTrace(); }
// in java/org/apache/struts2/config/PropertiesSettings.java
catch (IOException e) { throw new StrutsException("Could not load " + name + ".properties:" + e, e); }
// in java/org/apache/struts2/config/PropertiesSettings.java
catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/components/Date.java
catch (IOException e) { LOG.error("Could not write out Date tag", e); }
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (IOException e) { LOG.error("Could not load " + propName, e); }
// in java/org/apache/struts2/components/template/BaseTemplateEngine.java
catch (IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/components/template/VelocityTemplateEngine.java
catch (IOException e) { if (exception == null) { exception = e; } }
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
catch (IOException e) { // FileNotFoundException is anticipated - report the first IOException if no template found if (exception == null) { exception = e; } }
// in java/org/apache/struts2/components/Text.java
catch (IOException e) { LOG.error("Could not write out Text tag", e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Number.java
catch (IOException e) { LOG.error("Could not write out Number tag", e); }
// in java/org/apache/struts2/components/Component.java
catch (IOException e) { throw new StrutsException("IOError while writing the body: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Property.java
catch (IOException e) { if (LOG.isInfoEnabled()) { LOG.info("Could not print out value '" + value + "'", e); } }
// in java/org/apache/struts2/components/ActionComponent.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("error while trying to flush writer ", e);
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (IOException e) { LOG.error("Invalid template path specified: " + e.getMessage(), e); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (IOException e) { LOG.error("Error while loading freemarker settings from /freemarker.properties", e); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch(IOException io) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to close input stream", io); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to load velocity configuration " + resourceLocation, e); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (IOException e) { }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
catch (IOException e) { if(LOG.isErrorEnabled()){ LOG.error("Cannot write uploaded empty file to disk: " + storeLocation.getAbsolutePath(),e); } }
// in java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
catch (IOException e) { addError("Cannot parse request: "+e.toString()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IOException e) { logMessage = "Could not find create multipart save directory '"+multipartSaveDir.toString()+"'."; }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception exp) { try { response.sendError(code, "Unable to show problem report: " + exp); } catch (IOException ex) { // we're already sending an error, not much else we can do if more stuff breaks } }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IOException ex) { // we're already sending an error, not much else we can do if more stuff breaks }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IOException e1) { // we're already sending an error, not much else we can do if more stuff breaks }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (IOException ex) { // just ignore it continue; }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("Cannot clean up the request, some files can still remain in #0 after upload!", e, StrutsConstants.STRUTS_MULTIPART_SAVEDIR); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (IOException e) { writeToFile(); throw e; }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (IOException e) { // Ignore }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (IOException e) { // Ignore }
7
            
// in java/org/apache/struts2/config/PropertiesSettings.java
catch (IOException e) { throw new StrutsException("Could not load " + name + ".properties:" + e, e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Component.java
catch (IOException e) { throw new StrutsException("IOError while writing the body: " + e.getMessage(), e); }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (IOException e) { writeToFile(); throw e; }
0
unknown (Lib) IllegalAccessException 0 0 2
            
// in java/org/apache/struts2/views/xslt/XSLTResult.java
protected Source getDOMSourceForStack(Object value) throws IllegalAccessException, InstantiationException { return new DOMSource(getAdapterFactory().adaptDocument("result", value) ); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
public Document adaptDocument(String propertyName, Object propertyValue) throws IllegalAccessException, InstantiationException { //if ( propertyValue instanceof Document ) // return (Document)propertyValue; return new SimpleAdapterDocument(this, null, propertyName, propertyValue); }
6
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IllegalAccessException e) { throw new ConfigurationException("Unable to access provider: "+cname, e); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (IllegalAccessException e) { System.err.println("Unable to access logger factory: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( IllegalAccessException e ) { System.err.println("Unable to access logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IllegalAccessException e) { System.err.println("Unable to access logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
3
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (IllegalAccessException e) { throw new ConfigurationException( "IllegalAccessException while attempting to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (IllegalAccessException e) { throw new ConfigurationException("Unable to access provider: "+cname, e); }
0
runtime (Lib) IllegalArgumentException 14
            
// in java/org/apache/struts2/interceptor/ScopeInterceptor.java
public void setType(String type) { type = type.toLowerCase(); if ("start".equals(type) || "end".equals(type)) { this.type = type; } else { throw new IllegalArgumentException("Only start or end are allowed arguments for type"); } }
// in java/org/apache/struts2/config/PropertiesSettings.java
public String getImpl(String aName) throws IllegalArgumentException { String setting = settings.getProperty(aName); if (setting == null) { throw new IllegalArgumentException("No such setting:" + aName); } return setting; }
// in java/org/apache/struts2/config/PropertiesSettings.java
public Location getLocationImpl(String aName) throws IllegalArgumentException { Location loc = settings.getPropertyLocation(aName); if (loc == null) { if (!settings.containsKey(aName)) { throw new IllegalArgumentException("No such setting:" + aName); } } return loc; }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
public Properties loadConfiguration(ServletContext context) { if (context == null) { String gripe = "Error attempting to create a loadConfiguration from a null ServletContext!"; LOG.error(gripe); throw new IllegalArgumentException(gripe); } Properties properties = new Properties(); // now apply our systemic defaults, then allow user to override applyDefaultConfiguration(context, properties); String defaultUserDirective = properties.getProperty("userdirective"); /** * if the user has specified an external velocity configuration file, we'll want to search for it in the * following order * * 1. relative to the context path * 2. relative to /WEB-INF * 3. in the class path */ String configfile; if (customConfigFile != null) { configfile = customConfigFile; } else { configfile = "velocity.properties"; } configfile = configfile.trim(); InputStream in = null; String resourceLocation = null; try { if (context.getRealPath(configfile) != null) { // 1. relative to context path, i.e. /velocity.properties String filename = context.getRealPath(configfile); if (filename != null) { File file = new File(filename); if (file.isFile()) { resourceLocation = file.getCanonicalPath() + " from file system"; in = new FileInputStream(file); } // 2. if nothing was found relative to the context path, search relative to the WEB-INF directory if (in == null) { file = new File(context.getRealPath("/WEB-INF/" + configfile)); if (file.isFile()) { resourceLocation = file.getCanonicalPath() + " from file system"; in = new FileInputStream(file); } } } } // 3. finally, if there's no physical file, how about something in our classpath if (in == null) { in = VelocityManager.class.getClassLoader().getResourceAsStream(configfile); if (in != null) { resourceLocation = configfile + " from classloader"; } } // if we've got something, load 'er up if (in != null) { if (LOG.isInfoEnabled()) { LOG.info("Initializing velocity using " + resourceLocation); } properties.load(in); } } catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to load velocity configuration " + resourceLocation, e); } } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } } // overide with programmatically set properties if (this.velocityProperties != null) { Iterator keys = this.velocityProperties.keySet().iterator(); while (keys.hasNext()) { String key = (String) keys.next(); properties.setProperty(key, this.velocityProperties.getProperty(key)); } } String userdirective = properties.getProperty("userdirective"); if ((userdirective == null) || userdirective.trim().equals("")) { userdirective = defaultUserDirective; } else { userdirective = userdirective.trim() + "," + defaultUserDirective; } properties.setProperty("userdirective", userdirective); // for debugging purposes, allows users to dump out the properties that have been configured if (LOG.isDebugEnabled()) { LOG.debug("Initializing Velocity with the following properties ..."); for (Iterator iter = properties.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); String value = properties.getProperty(key); if (LOG.isDebugEnabled()) { LOG.debug(" '" + key + "' = '" + value + "'"); } } } return properties; }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
protected VelocityEngine newVelocityEngine(ServletContext context) { if (context == null) { String gripe = "Error attempting to create a new VelocityEngine from a null ServletContext!"; LOG.error(gripe); throw new IllegalArgumentException(gripe); } Properties p = loadConfiguration(context); VelocityEngine velocityEngine = new VelocityEngine(); // Set the velocity attribute for the servlet context // if this is not set the webapp loader WILL NOT WORK velocityEngine.setApplicationAttribute(ServletContext.class.getName(), context); try { velocityEngine.init(p); } catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); } return velocityEngine; }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
private void init_TraditionalXmlConfigurations() { String configPaths = initParams.get("config"); if (configPaths == null) { configPaths = DEFAULT_CONFIGURATION_PATHS; } String[] files = configPaths.split("\\s*[,]\\s*"); for (String file : files) { if (file.endsWith(".xml")) { if ("xwork.xml".equals(file)) { configurationManager.addContainerProvider(createXmlConfigurationProvider(file, false)); } else { configurationManager.addContainerProvider(createStrutsXmlConfigurationProvider(file, false, servletContext)); } } else { throw new IllegalArgumentException("Invalid configuration file name"); } } }
// in java/org/apache/struts2/dispatcher/StreamResult.java
protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { // Override any parameters using values on the stack resolveParamsFromStack(invocation.getStack(), invocation); OutputStream oOutput = null; try { if (inputStream == null) { // Find the inputstream from the invocation variable stack inputStream = (InputStream) invocation.getStack().findValue(conditionalParse(inputName, invocation)); } if (inputStream == null) { String msg = ("Can not find a java.io.InputStream with the name [" + inputName + "] in the invocation stack. " + "Check the <param name=\"inputName\"> tag specified for this action."); LOG.error(msg); throw new IllegalArgumentException(msg); } // Find the Response in context HttpServletResponse oResponse = (HttpServletResponse) invocation.getInvocationContext().get(HTTP_RESPONSE); // Set the content type if (contentCharSet != null && ! contentCharSet.equals("")) { oResponse.setContentType(conditionalParse(contentType, invocation)+";charset="+contentCharSet); } else { oResponse.setContentType(conditionalParse(contentType, invocation)); } // Set the content length if (contentLength != null) { String _contentLength = conditionalParse(contentLength, invocation); int _contentLengthAsInt = -1; try { _contentLengthAsInt = Integer.parseInt(_contentLength); if (_contentLengthAsInt >= 0) { oResponse.setContentLength(_contentLengthAsInt); } } catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e); } } } // Set the content-disposition if (contentDisposition != null) { oResponse.addHeader("Content-Disposition", conditionalParse(contentDisposition, invocation)); } // Set the cache control headers if neccessary if (!allowCaching) { oResponse.addHeader("Pragma", "no-cache"); oResponse.addHeader("Cache-Control", "no-cache"); } // Get the outputstream oOutput = oResponse.getOutputStream(); if (LOG.isDebugEnabled()) { LOG.debug("Streaming result [" + inputName + "] type=[" + contentType + "] length=[" + contentLength + "] content-disposition=[" + contentDisposition + "] charset=[" + contentCharSet + "]"); } // Copy input to output if (LOG.isDebugEnabled()) { LOG.debug("Streaming to output buffer +++ START +++"); } byte[] oBuff = new byte[bufferSize]; int iSize; while (-1 != (iSize = inputStream.read(oBuff))) { oOutput.write(oBuff, 0, iSize); } if (LOG.isDebugEnabled()) { LOG.debug("Streaming to output buffer +++ END +++"); } // Flush oOutput.flush(); } finally { if (inputStream != null) inputStream.close(); if (oOutput != null) oOutput.close(); } }
// in java/org/apache/struts2/util/TokenHelper.java
public static String setToken(String tokenName) { Map session = ActionContext.getContext().getSession(); String token = generateGUID(); try { session.put(tokenName, token); } catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); } return token; }
// in java/org/apache/struts2/util/DateFormatter.java
public void setDate(String date) { try { this.date = parser.parse(date); } catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); } }
// in java/org/apache/struts2/util/PrefixTrie.java
public void put(String prefix, Object value) { Node current = root; for (int i = 0; i < prefix.length(); i++) { char c = prefix.charAt(i); if (c > SIZE) throw new IllegalArgumentException("'" + c + "' is too big."); if (current.next[c] == null) current.next[c] = new Node(); current = current.next[c]; } current.value = value; }
// in java/org/apache/struts2/util/RegexPatternMatcher.java
public RegexPatternMatcherExpression compilePattern(String data) { Map<Integer, String> params = new HashMap<Integer, String>(); Matcher matcher = PATTERN.matcher(data); int count = 0; while (matcher.find()) { String expression = matcher.group(1); //check if it is a regex int index = expression.indexOf(':'); if (index > 0) { String paramName = expression.substring(0, index); String regex = StringUtils.substring(expression, index + 1); if (StringUtils.isBlank(regex)) { throw new IllegalArgumentException("invalid expression [" + expression + "], named parameter regular exression " + "must be in the format {PARAM_NAME:REGEX}"); } params.put(++count, paramName); } else { params.put(++count, expression); } } //generate a new pattern used to match URIs //replace {X:B} by (B) String newPattern = data.replaceAll("(\\{[^\\}]*?:(.*?)\\})", "($2)"); //replace {X} by (.*?) newPattern = newPattern.replaceAll("(\\{.*?\\})", "(.*?)"); return new RegexPatternMatcherExpression(Pattern.compile(newPattern), params); }
// in java/org/apache/struts2/util/StrutsUtil.java
public String include(Object aName, HttpServletRequest aRequest, HttpServletResponse aResponse) throws Exception { try { RequestDispatcher dispatcher = aRequest.getRequestDispatcher(aName.toString()); if (dispatcher == null) { throw new IllegalArgumentException("Cannot find included file " + aName); } ResponseWrapper responseWrapper = new ResponseWrapper(aResponse); dispatcher.include(aRequest, responseWrapper); return responseWrapper.getData(); } catch (Exception e) { e.printStackTrace(); throw e; } }
2
            
// in java/org/apache/struts2/util/TokenHelper.java
catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); }
// in java/org/apache/struts2/util/DateFormatter.java
catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); }
12
            
// in java/org/apache/struts2/config/DefaultSettings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { delegate.setImpl(name, value); }
// in java/org/apache/struts2/config/DefaultSettings.java
public String getImpl(String aName) throws IllegalArgumentException { return delegate.getImpl(aName); }
// in java/org/apache/struts2/config/Settings.java
public static String get(String name) throws IllegalArgumentException { return getInstance().getImpl(name); }
// in java/org/apache/struts2/config/Settings.java
public static Location getLocation(String name) throws IllegalArgumentException { return getInstance().getLocationImpl(name); }
// in java/org/apache/struts2/config/Settings.java
public static void set(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { getInstance().setImpl(name, value); }
// in java/org/apache/struts2/config/Settings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { throw new UnsupportedOperationException("Settings: This implementation does not support setting a value."); }
// in java/org/apache/struts2/config/Settings.java
public String getImpl(String name) throws IllegalArgumentException { return null; }
// in java/org/apache/struts2/config/Settings.java
public Location getLocationImpl(String name) throws IllegalArgumentException { return null; }
// in java/org/apache/struts2/config/PropertiesSettings.java
public String getImpl(String aName) throws IllegalArgumentException { String setting = settings.getProperty(aName); if (setting == null) { throw new IllegalArgumentException("No such setting:" + aName); } return setting; }
// in java/org/apache/struts2/config/PropertiesSettings.java
public Location getLocationImpl(String aName) throws IllegalArgumentException { Location loc = settings.getPropertyLocation(aName); if (loc == null) { if (!settings.containsKey(aName)) { throw new IllegalArgumentException("No such setting:" + aName); } } return loc; }
// in java/org/apache/struts2/config/DelegatingSettings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { IllegalArgumentException e = null; for (Settings delegate : delegates) { try { delegate.getImpl(name); // Throws exception if not found delegate.setImpl(name, value); // Found it return; // Done } catch (IllegalArgumentException ex) { e = ex; // Try next delegate } } throw e; }
// in java/org/apache/struts2/config/DelegatingSettings.java
public String getImpl(String name) throws IllegalArgumentException { IllegalArgumentException e = null; for (Settings delegate : delegates) { try { return delegate.getImpl(name); // Throws exception if not found } catch (IllegalArgumentException ex) { e = ex; // Try next delegate } } throw e; }
5
            
// in java/org/apache/struts2/config/DefaultSettings.java
catch (IllegalArgumentException e) { // Assume it's OK, since IllegalArgumentException is thrown // when Settings is unable to find a certain setting, // like the struts.custom.properties, which is commented out }
// in java/org/apache/struts2/config/Settings.java
catch (IllegalArgumentException ex) { // ignore }
// in java/org/apache/struts2/config/DelegatingSettings.java
catch (IllegalArgumentException ex) { e = ex; // Try next delegate }
// in java/org/apache/struts2/config/DelegatingSettings.java
catch (IllegalArgumentException ex) { e = ex; // Try next delegate }
// in java/org/apache/struts2/components/Number.java
catch (IllegalArgumentException iae) { LOG.error("Could not recognise a currency of [" + currency + "]"); }
0 0
runtime (Lib) IllegalStateException 7
            
// in java/org/apache/struts2/config/NullResult.java
public void execute(ActionInvocation invocation) throws Exception { throw new IllegalStateException("Shouldn't be called"); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public Container getContainer() { ConfigurationManager mgr = getConfigurationManager(); if (mgr == null) { throw new IllegalStateException("The configuration manager shouldn't be null"); } else { Configuration config = mgr.getConfiguration(); if (config == null) { throw new IllegalStateException("Unable to load configuration"); } else { return config.getContainer(); } } }
// in java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java
public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) { if (!isSlashesInActionNames()) { throw new IllegalStateException("This action mapper requires the setting 'slashesInActionNames' to be set to 'true'"); } ActionMapping mapping = super.getMapping(request, configManager); if (mapping == null) { return null; } String actionName = mapping.getName(); String id = null; // Only try something if the action name is specified if (actionName != null && actionName.length() > 0) { int lastSlashPos = actionName.lastIndexOf('/'); if (lastSlashPos > -1) { id = actionName.substring(lastSlashPos+1); } // If a method hasn't been explicitly named, try to guess using ReST-style patterns if (mapping.getMethod() == null) { if (lastSlashPos == actionName.length() -1) { // Index e.g. foo/ if (isGet(request)) { mapping.setMethod("index"); // Creating a new entry on POST e.g. foo/ } else if (isPost(request)) { mapping.setMethod("create"); } } else if (lastSlashPos > -1) { // Viewing the form to create a new item e.g. foo/new if (isGet(request) && "new".equals(id)) { mapping.setMethod("editNew"); // Viewing an item e.g. foo/1 } else if (isGet(request)) { mapping.setMethod("view"); // Removing an item e.g. foo/1 } else if (isDelete(request)) { mapping.setMethod("remove"); // Updating an item e.g. foo/1 } else if (isPut(request)) { mapping.setMethod("update"); } } if (idParameterName != null && lastSlashPos > -1) { actionName = actionName.substring(0, lastSlashPos); } } if (idParameterName != null && id != null) { if (mapping.getParams() == null) { mapping.setParams(new HashMap<String, Object>()); } mapping.getParams().put(idParameterName, id); } // Try to determine parameters from the url before the action name int actionSlashPos = actionName.lastIndexOf('/', lastSlashPos - 1); if (actionSlashPos > 0 && actionSlashPos < lastSlashPos) { String params = actionName.substring(0, actionSlashPos); HashMap<String,String> parameters = new HashMap<String,String>(); try { StringTokenizer st = new StringTokenizer(params, "/"); boolean isNameTok = true; String paramName = null; String paramValue; while (st.hasMoreTokens()) { if (isNameTok) { paramName = URLDecoder.decode(st.nextToken(), "UTF-8"); isNameTok = false; } else { paramValue = URLDecoder.decode(st.nextToken(), "UTF-8"); if ((paramName != null) && (paramName.length() > 0)) { parameters.put(paramName, paramValue); } isNameTok = true; } } if (parameters.size() > 0) { if (mapping.getParams() == null) { mapping.setParams(new HashMap<String, Object>()); } mapping.getParams().putAll(parameters); } } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Unable to determine parameters from the url", e); } } mapping.setName(actionName.substring(actionSlashPos+1)); } } return mapping; }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
public Dispatcher findDispatcherOnThread() { Dispatcher dispatcher = Dispatcher.getInstance(); if (dispatcher == null) { throw new IllegalStateException("Must have the StrutsPrepareFilter execute before this one"); } return dispatcher; }
// in java/org/apache/struts2/util/InvocationSessionStore.java
static void setInvocationMap(Map invocationMap) { Map session = ActionContext.getContext().getSession(); if (session == null) { throw new IllegalStateException("Unable to access the session."); } session.put(INVOCATION_MAP_KEY, invocationMap); }
// in java/org/apache/struts2/util/InvocationSessionStore.java
static Map getInvocationMap() { Map session = ActionContext.getContext().getSession(); if (session == null) { throw new IllegalStateException("Unable to access the session."); } Map invocationMap = (Map) session.get(INVOCATION_MAP_KEY); if (invocationMap == null) { invocationMap = new HashMap(); setInvocationMap(invocationMap); } return invocationMap; }
0 1
            
// in java/org/apache/struts2/config/Settings.java
public static void setInstance(Settings config) throws IllegalStateException { settingsImpl = config; locale = null; }
1
            
// in java/org/apache/struts2/util/TokenHelper.java
catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); }
1
            
// in java/org/apache/struts2/util/TokenHelper.java
catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); }
1
unknown (Lib) IndexOutOfBoundsException 2
            
// in java/org/apache/struts2/components/IteratorComponent.java
public Object next() { if (hasNext()) { int nextIndex = peekNextIndex(); currentIndex += step; return value != null ? values.get(nextIndex) : nextIndex; } else { throw new IndexOutOfBoundsException("Index " + ( currentIndex + step) + " must be less than or equal to " + end); } }
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(byte data[], int offset, int length) throws IOException { if (data == null) { throw new NullPointerException(); } if (offset < 0 || offset + length > data.length || length < 0) { throw new IndexOutOfBoundsException(); } if (closed) { throw new IOException("Stream closed"); } if (index + length > blockSize) { do { if (index == blockSize) { addBuffer(); } int copyLength = blockSize - index; if (length < copyLength) { copyLength = length; } System.arraycopy(data, offset, buffer, index, copyLength); offset += copyLength; index += copyLength; length -= copyLength; } while (length > 0); } else { System.arraycopy(data, offset, buffer, index, length); index += length; } }
0 0 0 0 0
unknown (Lib) InstantiationException 0 0 2
            
// in java/org/apache/struts2/views/xslt/XSLTResult.java
protected Source getDOMSourceForStack(Object value) throws IllegalAccessException, InstantiationException { return new DOMSource(getAdapterFactory().adaptDocument("result", value) ); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
public Document adaptDocument(String propertyName, Object propertyValue) throws IllegalAccessException, InstantiationException { //if ( propertyValue instanceof Document ) // return (Document)propertyValue; return new SimpleAdapterDocument(this, null, propertyName, propertyValue); }
6
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (InstantiationException e) { throw new ConfigurationException("Unable to instantiate provider: "+cname, e); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
catch (InstantiationException e) { System.err.println("Unable to instantiate logger factory: "+factoryName+", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/ng/InitOperations.java
catch ( InstantiationException e ) { System.err.println("Unable to instantiate logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (InstantiationException e) { System.err.println("Unable to instantiate logger factory: " + factoryName + ", using default"); e.printStackTrace(); }
3
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (InstantiationException e) { throw new ConfigurationException( "Unable to instantiate an instance of Interceptor class [" + className + "].", e, interceptorConfig); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (InstantiationException e) { throw new ConfigurationException("Unable to instantiate provider: "+cname, e); }
0
unknown (Lib) IntrospectionException 0 0 0 1
            
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); }
1
            
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); }
0
unknown (Lib) JspException 4
            
// in java/org/apache/struts2/views/jsp/IteratorTag.java
public int doAfterBody() throws JspException { boolean again = component.end(pageContext.getOut(), getBody()); if (again) { return EVAL_BODY_AGAIN; } else { if (bodyContent != null) { try { bodyContent.writeOut(bodyContent.getEnclosingWriter()); } catch (Exception e) { throw new JspException(e.getMessage()); } } return SKIP_BODY; } }
1
            
// in java/org/apache/struts2/views/jsp/IteratorTag.java
catch (Exception e) { throw new JspException(e.getMessage()); }
8
            
// in java/org/apache/struts2/views/jsp/ui/AbstractUITag.java
public void setDynamicAttribute(String uri, String localName, Object value) throws JspException { if (value != null && value instanceof String) { dynamicAttributes.put(localName, String.valueOf(ObjectUtils.defaultIfNull(findValue(value.toString()), value))); } else { dynamicAttributes.put(localName, value); } }
// in java/org/apache/struts2/views/jsp/IteratorTag.java
public int doEndTag() throws JspException { component = null; return EVAL_PAGE; }
// in java/org/apache/struts2/views/jsp/IteratorTag.java
public int doAfterBody() throws JspException { boolean again = component.end(pageContext.getOut(), getBody()); if (again) { return EVAL_BODY_AGAIN; } else { if (bodyContent != null) { try { bodyContent.writeOut(bodyContent.getEnclosingWriter()); } catch (Exception e) { throw new JspException(e.getMessage()); } } return SKIP_BODY; } }
// in java/org/apache/struts2/views/jsp/ComponentTagSupport.java
public int doEndTag() throws JspException { component.end(pageContext.getOut(), getBody()); component = null; return EVAL_PAGE; }
// in java/org/apache/struts2/views/jsp/ComponentTagSupport.java
public int doStartTag() throws JspException { component = getBean(getStack(), (HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse()); Container container = Dispatcher.getInstance().getContainer(); container.inject(component); populateParams(); boolean evalBody = component.start(pageContext.getOut()); if (evalBody) { return component.usesBody() ? EVAL_BODY_BUFFERED : EVAL_BODY_INCLUDE; } else { return SKIP_BODY; } }
// in java/org/apache/struts2/views/jsp/iterator/IteratorGeneratorTag.java
public int doEndTag() throws JspException { // pop resulting iterator from stack at end tag getStack().pop(); iteratorGenerator = null; // clean up return EVAL_PAGE; }
// in java/org/apache/struts2/views/jsp/iterator/SortIteratorTag.java
public int doEndTag() throws JspException { int returnVal = super.doEndTag(); // pop sorted list from stack at the end of tag getStack().pop(); sortIteratorFilter = null; return returnVal; }
// in java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java
public int doEndTag() throws JspException { getStack().pop(); subsetIteratorFilter = null; return EVAL_PAGE; }
0 0 0
unknown (Lib) MalformedURLException 0 0 0 1
            
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); }
1
            
// in java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
catch (MalformedURLException e) { throw new IOException("Unable to convert "+file+" to a URL"); }
0
unknown (Lib) NoClassDefFoundError 0 0 0 1
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); }
1
            
// in java/org/apache/struts2/impl/StrutsObjectFactory.java
catch (NoClassDefFoundError e) { throw new ConfigurationException( "Could not load class " + className + ". Perhaps it exists but certain dependencies are not available?", e, interceptorConfig); }
0
unknown (Lib) NoSuchMethodException 0 0 1
            
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
protected Method getActionMethod(Class actionClass, String methodName) throws NoSuchMethodException { Method method; try { method = actionClass.getMethod(methodName, new Class[0]); } catch (NoSuchMethodException e) { // hmm -- OK, try doXxx instead try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1); method = actionClass.getMethod(altMethodName, new Class[0]); } catch (NoSuchMethodException e1) { // throw the original one throw e; } } return method; }
3
            
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e) { // hmm -- OK, try doXxx instead try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1); method = actionClass.getMethod(altMethodName, new Class[0]); } catch (NoSuchMethodException e1) { // throw the original one throw e; } }
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e1) { // throw the original one throw e; }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (NoSuchMethodException e1) { throw new StrutsException("Adapter class: " + adapterClass + " does not have a no-args consructor."); }
2
            
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e) { // hmm -- OK, try doXxx instead try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1); method = actionClass.getMethod(altMethodName, new Class[0]); } catch (NoSuchMethodException e1) { // throw the original one throw e; } }
// in java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
catch (NoSuchMethodException e1) { // throw the original one throw e; }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (NoSuchMethodException e1) { throw new StrutsException("Adapter class: " + adapterClass + " does not have a no-args consructor."); }
0
runtime (Lib) NullPointerException 1
            
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void write(byte data[], int offset, int length) throws IOException { if (data == null) { throw new NullPointerException(); } if (offset < 0 || offset + length > data.length || length < 0) { throw new IndexOutOfBoundsException(); } if (closed) { throw new IOException("Stream closed"); } if (index + length > blockSize) { do { if (index == blockSize) { addBuffer(); } int copyLength = blockSize - index; if (length < copyLength) { copyLength = length; } System.arraycopy(data, offset, buffer, index, copyLength); offset += copyLength; index += copyLength; length -= copyLength; } while (length > 0); } else { System.arraycopy(data, offset, buffer, index, length); index += length; } }
0 0 2
            
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (NullPointerException npe) { // in case this was used outside the lifecycle of struts servlet LOG.debug("internal toolbox context ignored"); }
// in java/org/apache/struts2/util/AttributeMap.java
catch (NullPointerException npe){ return null; }
0 0
unknown (Lib) NumberFormatException 0 0 0 4
            
// in java/org/apache/struts2/views/jsp/iterator/IteratorGeneratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("unable to convert count attribute ["+startObj+"] to number, ignore count attribute", e); } }
// in java/org/apache/struts2/dispatcher/StreamResult.java
catch(NumberFormatException e) { if (LOG.isWarnEnabled()) { LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e); } }
0 0
unknown (Lib) OgnlException 0 0 0 1
            
// in java/org/apache/struts2/views/jsp/ui/OgnlTool.java
catch (OgnlException e) { return null; }
0 0
unknown (Lib) ParseErrorException 1
            
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
protected void putProperty(Map propertyMap, InternalContextAdapter contextAdapter, Node node) throws ParseErrorException, MethodInvocationException { // node.value uses the StrutsValueStack to evaluate the directive's value parameter String param = node.value(contextAdapter).toString(); int idx = param.indexOf("="); if (idx != -1) { String property = param.substring(0, idx); String value = param.substring(idx + 1); propertyMap.put(property, value); } else { throw new ParseErrorException("#" + this.getName() + " arguments must include an assignment operator! For example #tag( Component \"template=mytemplate\" ). #tag( TextField \"mytemplate\" ) is illegal!"); } }
0 4
            
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { // get the bean ValueStack stack = (ValueStack) ctx.get("stack"); HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE); Component bean = getBean(stack, req, res); Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); // get the parameters Map params = createPropertyMap(ctx, node); bean.copyParams(params); //bean.addAllParameters(params); bean.start(writer); if (getType() == BLOCK) { Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1); body.render(ctx, writer); } bean.end(writer, ""); return true; }
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
protected Map createPropertyMap(InternalContextAdapter contextAdapter, Node node) throws ParseErrorException, MethodInvocationException { Map propertyMap; int children = node.jjtGetNumChildren(); if (getType() == BLOCK) { children--; } // Velocity supports an on-the-fly Map-definition syntax that leads // to more readable and faster code: // // #url({'id':'url', 'action':'MyAction'}) // // We support this syntax by checking for a single Map argument // to any directive and using that as the property map instead // of building one from individual name-value pair strings. Node firstChild = null; Object firstValue = null; if(children == 1 && null != (firstChild = node.jjtGetChild(0)) && null != (firstValue = firstChild.value(contextAdapter)) && firstValue instanceof Map) { propertyMap = (Map)firstValue; } else { propertyMap = new HashMap(); for (int index = 0, length = children; index < length; index++) { this.putProperty(propertyMap, contextAdapter, node.jjtGetChild(index)); } } return propertyMap; }
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
protected void putProperty(Map propertyMap, InternalContextAdapter contextAdapter, Node node) throws ParseErrorException, MethodInvocationException { // node.value uses the StrutsValueStack to evaluate the directive's value parameter String param = node.value(contextAdapter).toString(); int idx = param.indexOf("="); if (idx != -1) { String property = param.substring(0, idx); String value = param.substring(idx + 1); propertyMap.put(property, value); } else { throw new ParseErrorException("#" + this.getName() + " arguments must include an assignment operator! For example #tag( Component \"template=mytemplate\" ). #tag( TextField \"mytemplate\" ) is illegal!"); } }
// in java/org/apache/struts2/util/VelocityStrutsUtil.java
public String evaluate(String expression) throws IOException, ResourceNotFoundException, MethodInvocationException, ParseErrorException { CharArrayWriter writer = new CharArrayWriter(); velocityEngine.evaluate(ctx, writer, "Error parsing " + expression, expression); return writer.toString(); }
0 0 0
unknown (Lib) ParseException 0 0 0 2
            
// in java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java
catch (ParseException e) { // template was found but was invalid - always report this. exception = e; break; }
// in java/org/apache/struts2/util/DateFormatter.java
catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); }
1
            
// in java/org/apache/struts2/util/DateFormatter.java
catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); }
1
unknown (Lib) ResourceNotFoundException 2
            
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
public synchronized InputStream getResourceStream(String name) throws ResourceNotFoundException { if ((name == null) || (name.length() == 0)) { throw new ResourceNotFoundException("No template name provided"); } if (name.startsWith("/")) { name = name.substring(1); } try { return ClassLoaderUtil.getResourceAsStream(name, StrutsResourceLoader.class); } catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); } }
1
            
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); }
3
            
// in java/org/apache/struts2/views/velocity/components/AbstractDirective.java
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { // get the bean ValueStack stack = (ValueStack) ctx.get("stack"); HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE); Component bean = getBean(stack, req, res); Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); // get the parameters Map params = createPropertyMap(ctx, node); bean.copyParams(params); //bean.addAllParameters(params); bean.start(writer); if (getType() == BLOCK) { Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1); body.render(ctx, writer); } bean.end(writer, ""); return true; }
// in java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
public synchronized InputStream getResourceStream(String name) throws ResourceNotFoundException { if ((name == null) || (name.length() == 0)) { throw new ResourceNotFoundException("No template name provided"); } if (name.startsWith("/")) { name = name.substring(1); } try { return ClassLoaderUtil.getResourceAsStream(name, StrutsResourceLoader.class); } catch (Exception e) { throw new ResourceNotFoundException(e.getMessage()); } }
// in java/org/apache/struts2/util/VelocityStrutsUtil.java
public String evaluate(String expression) throws IOException, ResourceNotFoundException, MethodInvocationException, ParseErrorException { CharArrayWriter writer = new CharArrayWriter(); velocityEngine.evaluate(ctx, writer, "Error parsing " + expression, expression); return writer.toString(); }
0 0 0
runtime (Lib) RuntimeException 1
            
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
public void writeTo(JspWriter out, String encoding) throws IOException { try { writeTo((Writer) out, encoding); } catch (IOException e) { writeToFile(); throw e; } catch (Throwable e) { writeToFile(); throw new RuntimeException(e); } }
1
            
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (Throwable e) { writeToFile(); throw new RuntimeException(e); }
0 0 0 0
unknown (Lib) ServletException 4
            
// in java/org/apache/struts2/components/Include.java
public static void include( String relativePath, Writer writer, ServletRequest request, HttpServletResponse response, String encoding ) throws ServletException, IOException { String resourcePath = getContextRelativePath(request, relativePath); RequestDispatcher rd = request.getRequestDispatcher(resourcePath); if (rd == null) { throw new ServletException("Not a valid resource path:" + resourcePath); } PageResponse pageResponse = new PageResponse(response); // Include the resource rd.include(request, pageResponse); if (encoding != null) { // Use given encoding pageResponse.getContent().writeTo(writer, encoding); } else { //use the platform specific encoding pageResponse.getContent().writeTo(writer, systemEncoding); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
public HttpServletRequest wrapRequest(HttpServletRequest oldRequest) throws ServletException { HttpServletRequest request = oldRequest; try { // Wrap request first, just in case it is multipart/form-data // parameters might not be accessible through before encoding (ww-1278) request = dispatcher.wrapRequest(request, servletContext); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); } return request; }
// in java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); prepare.setEncodingAndLocale(request, response); request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) throw new ServletException("Resource loading not supported, use the StrutsPrepareAndExecuteFilter instead."); } else { execute.executeAction(request, response, mapping); } } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
protected HttpServletRequest prepareDispatcherAndWrapRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException { Dispatcher du = Dispatcher.getInstance(); // Prepare and wrap the request if the cleanup filter hasn't already, cleanup filter should be // configured first before struts2 dispatcher filter, hence when its cleanup filter's turn, // static instance of Dispatcher should be null. if (du == null) { Dispatcher.setInstance(dispatcher); // prepare the request no matter what - this ensures that the proper character encoding // is used before invoking the mapper (see WW-9127) dispatcher.prepare(request, response); } else { dispatcher = du; } try { // Wrap request first, just in case it is multipart/form-data // parameters might not be accessible through before encoding (ww-1278) request = dispatcher.wrapRequest(request, getServletContext()); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); } return request; }
2
            
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); }
20
            
// in java/org/apache/struts2/components/Include.java
public static void include( String relativePath, Writer writer, ServletRequest request, HttpServletResponse response ) throws ServletException, IOException { include(relativePath, writer, request, response, null); }
// in java/org/apache/struts2/components/Include.java
public static void include( String relativePath, Writer writer, ServletRequest request, HttpServletResponse response, String encoding ) throws ServletException, IOException { String resourcePath = getContextRelativePath(request, relativePath); RequestDispatcher rd = request.getRequestDispatcher(resourcePath); if (rd == null) { throw new ServletException("Not a valid resource path:" + resourcePath); } PageResponse pageResponse = new PageResponse(response); // Include the resource rd.include(request, pageResponse); if (encoding != null) { // Use given encoding pageResponse.getContent().writeTo(writer, encoding); } else { //use the platform specific encoding pageResponse.getContent().writeTo(writer, systemEncoding); } }
// in java/org/apache/struts2/views/JspSupportServlet.java
public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); jspSupportServlet = this; }
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String timerKey = "ActionContextCleanUp_doFilter: "; try { UtilTimerStack.push(timerKey); try { Integer count = (Integer)request.getAttribute(COUNTER); if (count == null) { count = Integer.valueOf(1); } else { count = Integer.valueOf(count.intValue()+1); } request.setAttribute(COUNTER, count); //LOG.debug("filtering counter="+count); chain.doFilter(request, response); } finally { int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue(); counterVal -= 1; request.setAttribute(COUNTER, Integer.valueOf(counterVal)); cleanUp(request); } } finally { UtilTimerStack.pop(timerKey); } }
// in java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
public void init(FilterConfig arg0) throws ServletException { }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException { Map<String, Object> extraContext = createContextMap(request, response, mapping, context); // If there was a previous value stack, then create a new copy and pass it in to be used by the new Action ValueStack stack = (ValueStack) request.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY); boolean nullStack = stack == null; if (nullStack) { ActionContext ctx = ActionContext.getContext(); if (ctx != null) { stack = ctx.getValueStack(); } } if (stack != null) { extraContext.put(ActionContext.VALUE_STACK, valueStackFactory.createValueStack(stack)); } String timerKey = "Handling request from Dispatcher"; try { UtilTimerStack.push(timerKey); String namespace = mapping.getNamespace(); String name = mapping.getName(); String method = mapping.getMethod(); Configuration config = configurationManager.getConfiguration(); ActionProxy proxy = config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy( namespace, name, method, extraContext, true, false); request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack()); // if the ActionMapping says to go straight to a result, do it! if (mapping.getResult() != null) { Result result = mapping.getResult(); result.execute(proxy.getInvocation()); } else { proxy.execute(); } // If there was a previous value stack then set it back onto the request if (!nullStack) { request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); } } catch (ConfigurationException e) { // WW-2874 Only log error if in devMode if(devMode) { String reqStr = request.getRequestURI(); if (request.getQueryString() != null) { reqStr = reqStr + "?" + request.getQueryString(); } LOG.error("Could not find action or result\n" + reqStr, e); } else { if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); } catch (Exception e) { sendError(request, response, context, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e); } finally { UtilTimerStack.pop(timerKey); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
public HttpServletRequest wrapRequest(HttpServletRequest oldRequest) throws ServletException { HttpServletRequest request = oldRequest; try { // Wrap request first, just in case it is multipart/form-data // parameters might not be accessible through before encoding (ww-1278) request = dispatcher.wrapRequest(request, servletContext); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; throw new ServletException(message, e); } return request; }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; if (excludeUrl(request)) { chain.doFilter(request, response); return; } // This is necessary since we need the dispatcher instance, which was created by the prepare filter if (execute == null) { lazyInit(); } ActionMapping mapping = prepare.findActionMapping(request, response); //if recusrion counter is > 1, it means we are in a "forward", in that case a mapping will still be //in the request, if we handle it, it will lead to an infinte loop, see WW-3077 Integer recursionCounter = (Integer) request.getAttribute(PrepareOperations.CLEANUP_RECURSION_COUNTER); if (mapping == null || recursionCounter > 1) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) { chain.doFilter(request, response); } } else { execute.executeAction(request, response, mapping); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
public void init(FilterConfig filterConfig) throws ServletException { InitOperations init = new InitOperations(); try { FilterHostConfig config = new FilterHostConfig(filterConfig); init.initLogging(config); Dispatcher dispatcher = init.initDispatcher(config); init.initStaticContentLoader(config, dispatcher); prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher); execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher); this.excludedPatterns = init.buildExcludedPatternsList(dispatcher); postInit(dispatcher, filterConfig); } finally { init.cleanup(); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; try { prepare.setEncodingAndLocale(request, response); prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); if ( excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) { chain.doFilter(request, response); } else { request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response, true); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) { chain.doFilter(request, response); } } else { execute.executeAction(request, response, mapping); } } } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
public void init(FilterConfig filterConfig) throws ServletException { InitOperations init = new InitOperations(); try { FilterHostConfig config = new FilterHostConfig(filterConfig); init.initLogging(config); Dispatcher dispatcher = init.initDispatcher(config); prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher); this.excludedPatterns = init.buildExcludedPatternsList(dispatcher); postInit(dispatcher, filterConfig); } finally { init.cleanup(); } }
// in java/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; try { prepare.setEncodingAndLocale(request, response); prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); if ( excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) { request.setAttribute(REQUEST_EXCLUDED_FROM_ACTION_MAPPING, new Object()); } else { request = prepare.wrapRequest(request); prepare.findActionMapping(request, response); } chain.doFilter(request, response); } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
Override public void init(ServletConfig filterConfig) throws ServletException { InitOperations init = new InitOperations(); try { ServletHostConfig config = new ServletHostConfig(filterConfig); init.initLogging(config); Dispatcher dispatcher = init.initDispatcher(config); init.initStaticContentLoader(config, dispatcher); prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher); execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher); } finally { init.cleanup(); } }
// in java/org/apache/struts2/dispatcher/ng/servlet/StrutsServlet.java
Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); prepare.setEncodingAndLocale(request, response); request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) throw new ServletException("Resource loading not supported, use the StrutsPrepareAndExecuteFilter instead."); } else { execute.executeAction(request, response, mapping); } } finally { prepare.cleanupRequest(request); } }
// in java/org/apache/struts2/dispatcher/ng/ExecuteOperations.java
public boolean executeStaticResourceRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // there is no action in this request, should we look for a static resource? String resourcePath = RequestUtils.getServletPath(request); if ("".equals(resourcePath) && null != request.getPathInfo()) { resourcePath = request.getPathInfo(); } StaticContentLoader staticResourceLoader = dispatcher.getContainer().getInstance(StaticContentLoader.class); if (staticResourceLoader.canHandle(resourcePath)) { staticResourceLoader.findStaticResource(resourcePath, request, response); // The framework did its job here return true; } else { // this is a normal request, let it pass through return false; } }
// in java/org/apache/struts2/dispatcher/ng/ExecuteOperations.java
public void executeAction(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws ServletException { dispatcher.serviceAction(request, response, servletContext, mapping); }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
public void init(FilterConfig filterConfig) throws ServletException { try { this.filterConfig = filterConfig; initLogging(); dispatcher = createDispatcher(filterConfig); dispatcher.init(); dispatcher.getContainer().inject(this); staticResourceLoader.setHostConfig(new FilterHostConfig(filterConfig)); } finally { ActionContext.setContext(null); } }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
protected HttpServletRequest prepareDispatcherAndWrapRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException { Dispatcher du = Dispatcher.getInstance(); // Prepare and wrap the request if the cleanup filter hasn't already, cleanup filter should be // configured first before struts2 dispatcher filter, hence when its cleanup filter's turn, // static instance of Dispatcher should be null. if (du == null) { Dispatcher.setInstance(dispatcher); // prepare the request no matter what - this ensures that the proper character encoding // is used before invoking the mapper (see WW-9127) dispatcher.prepare(request, response); } else { dispatcher = du; } try { // Wrap request first, just in case it is multipart/form-data // parameters might not be accessible through before encoding (ww-1278) request = dispatcher.wrapRequest(request, getServletContext()); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; log.error(message, e); throw new ServletException(message, e); } return request; }
// in java/org/apache/struts2/dispatcher/FilterDispatcher.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; ServletContext servletContext = getServletContext(); String timerKey = "FilterDispatcher_doFilter: "; try { // FIXME: this should be refactored better to not duplicate work with the action invocation ValueStack stack = dispatcher.getContainer().getInstance(ValueStackFactory.class).createValueStack(); ActionContext ctx = new ActionContext(stack.getContext()); ActionContext.setContext(ctx); UtilTimerStack.push(timerKey); request = prepareDispatcherAndWrapRequest(request, response); ActionMapping mapping; try { mapping = actionMapper.getMapping(request, dispatcher.getConfigurationManager()); } catch (Exception ex) { log.error("error getting ActionMapping", ex); dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); return; } if (mapping == null) { // there is no action in this request, should we look for a static resource? String resourcePath = RequestUtils.getServletPath(request); if ("".equals(resourcePath) && null != request.getPathInfo()) { resourcePath = request.getPathInfo(); } if (staticResourceLoader.canHandle(resourcePath)) { staticResourceLoader.findStaticResource(resourcePath, request, response); } else { // this is a normal request, let it pass through chain.doFilter(request, response); } // The framework did its job here return; } dispatcher.serviceAction(request, response, servletContext, mapping); } finally { dispatcher.cleanUpRequest(request); try { ActionContextCleanUp.cleanUp(req); } finally { UtilTimerStack.pop(timerKey); } devModeOverride.remove(); } }
1
            
// in java/org/apache/struts2/dispatcher/FilterDispatcherCompatWeblogic61.java
catch (ServletException se) { LOG.error("Couldn't set the filter configuration in this filter", se); }
0 0
unknown (Domain) StrutsException
public class StrutsException extends XWorkException implements Locatable {

    private static final long serialVersionUID = 888724366243600135L;


    /**
     * Constructs a <code>StrutsException</code> with no detail message.
     */
    public StrutsException() {
    }

    /**
     * Constructs a <code>StrutsException</code> with the specified
     * detail message.
     *
     * @param s the detail message.
     */
    public StrutsException(String s) {
        this(s, null, null);
    }

    /**
     * Constructs a <code>StrutsException</code> with the specified
     * detail message and target.
     *
     * @param s the detail message.
     * @param target the target of the exception.
     */
    public StrutsException(String s, Object target) {
        this(s, (Throwable) null, target);
    }

    /**
     * Constructs a <code>StrutsException</code> with the root cause
     *
     * @param cause The wrapped exception
     */
    public StrutsException(Throwable cause) {
        this(null, cause, null);
    }

    /**
     * Constructs a <code>StrutsException</code> with the root cause and target
     *
     * @param cause The wrapped exception
     * @param target The target of the exception
     */
    public StrutsException(Throwable cause, Object target) {
        this(null, cause, target);
    }

    /**
     * Constructs a <code>StrutsException</code> with the specified
     * detail message and exception cause.
     *
     * @param s the detail message.
     * @param cause the wrapped exception
     */
    public StrutsException(String s, Throwable cause) {
        this(s, cause, null);
    }


     /**
     * Constructs a <code>StrutsException</code> with the specified
     * detail message, cause, and target
     *
     * @param s the detail message.
     * @param cause The wrapped exception
     * @param target The target of the exception
     */
    public StrutsException(String s, Throwable cause, Object target) {
        super(s, cause, target);
    }
}
30
            
// in java/org/apache/struts2/interceptor/ScopeInterceptor.java
static final void lock(Object o, ActionInvocation invocation) throws Exception { synchronized (o) { int count = 3; Object previous = null; while ((previous = locks.get(o)) != null) { if (previous == invocation) { return; } if (count-- <= 0) { locks.remove(o); o.notify(); throw new StrutsException("Deadlock in session lock"); } o.wait(10000); } ; locks.put(o, invocation); } }
// in java/org/apache/struts2/components/I18n.java
public boolean end(Writer writer, String body) throws StrutsException { if (pushed) { Object o = getStack().pop(); if ((o == null) || (!o.equals(textProvider))) { LOG.error("A closing i18n tag attempted to pop its own TextProvider from the top of the ValueStack but popped an unexpected object ("+(o != null ? o.getClass() : "null")+"). " + "Refactor the page within the i18n tags to ensure no objects are pushed onto the ValueStack without popping them prior to the closing tag. " + "If you see this message it's likely that the i18n's TextProvider is still on the stack and will continue to provide message resources after the closing tag."); throw new StrutsException("A closing i18n tag attempted to pop its TextProvider from the top of the ValueStack but popped an unexpected object ("+(o != null ? o.getClass() : "null")+")"); } } return super.end(writer, body); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
public void renderUrl(Writer writer, UrlProvider urlComponent) { String scheme = urlComponent.getHttpServletRequest().getScheme(); if (urlComponent.getScheme() != null) { scheme = urlComponent.getScheme(); } String result; ActionInvocation ai = (ActionInvocation) ActionContext.getContext().get(ActionContext.ACTION_INVOCATION); if (urlComponent.getValue() == null && urlComponent.getAction() != null) { result = urlComponent.determineActionURL(urlComponent.getAction(), urlComponent.getNamespace(), urlComponent.getMethod(), urlComponent.getHttpServletRequest(), urlComponent.getHttpServletResponse(), urlComponent.getParameters(), scheme, urlComponent.isIncludeContext(), urlComponent.isEncode(), urlComponent.isForceAddSchemeHostAndPort(), urlComponent.isEscapeAmp()); } else if (urlComponent.getValue() == null && urlComponent.getAction() == null && ai != null) { // both are null, we will default to the current action final String action = ai.getProxy().getActionName(); final String namespace = ai.getProxy().getNamespace(); final String method = urlComponent.getMethod() != null || !ai.getProxy().isMethodSpecified() ? urlComponent.getMethod() : ai.getProxy().getMethod(); result = urlComponent.determineActionURL(action, namespace, method, urlComponent.getHttpServletRequest(), urlComponent.getHttpServletResponse(), urlComponent.getParameters(), scheme, urlComponent.isIncludeContext(), urlComponent.isEncode(), urlComponent.isForceAddSchemeHostAndPort(), urlComponent.isEscapeAmp()); } else { String _value = urlComponent.getValue(); // We don't include the request parameters cause they would have been // prioritised before this [in start(Writer) method] if (_value != null && _value.indexOf("?") > 0) { _value = _value.substring(0, _value.indexOf("?")); } result = urlHelper.buildUrl(_value, urlComponent.getHttpServletRequest(), urlComponent.getHttpServletResponse(), urlComponent.getParameters(), scheme, urlComponent.isIncludeContext(), urlComponent.isEncode(), urlComponent.isForceAddSchemeHostAndPort(), urlComponent.isEscapeAmp()); } String anchor = urlComponent.getAnchor(); if (StringUtils.isNotEmpty(anchor)) { result += '#' + urlComponent.findString(anchor); } if (urlComponent.isPutInContext()) { String var = urlComponent.getVar(); if (StringUtils.isNotEmpty(var)) { urlComponent.putInContext(result); // add to the request and page scopes as well urlComponent.getHttpServletRequest().setAttribute(var, result); } else { try { writer.write(result); } catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); } } } else { try { writer.write(result); } catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); } } }
// in java/org/apache/struts2/components/Component.java
protected boolean end(Writer writer, String body, boolean popComponentStack) { assert(body != null); try { writer.write(body); } catch (IOException e) { throw new StrutsException("IOError while writing the body: " + e.getMessage(), e); } if (popComponentStack) { popComponentStack(); } return false; }
// in java/org/apache/struts2/components/Component.java
protected StrutsException fieldError(String field, String errorMsg, Exception e) { String msg = "tag '" + getComponentName() + "', field '" + field + ( parameters != null && parameters.containsKey("name")?"', name '" + parameters.get("name"):"") + "': " + errorMsg; throw new StrutsException(msg, e); }
// in java/org/apache/struts2/components/Debug.java
public boolean start(Writer writer) { boolean result = super.start(writer); ValueStack stack = getStack(); Iterator iter = stack.getRoot().iterator(); List stackValues = new ArrayList(stack.getRoot().size()); while (iter.hasNext()) { Object o = iter.next(); Map values; try { values = reflectionProvider.getBeanMap(o); } catch (Exception e) { throw new StrutsException("Caught an exception while getting the property values of " + o, e); } stackValues.add(new DebugMapEntry(o.getClass().getName(), values)); } addParameter("stackValues", stackValues); return result; }
// in java/org/apache/struts2/components/ActionComponent.java
protected void executeAction() { String actualName = findString(name, "name", "Action name is required. Example: updatePerson"); if (actualName == null) { throw new StrutsException("Unable to find value for name " + name); } // handle "name!method" convention. final String actionName; final String methodName; ActionMapping mapping = actionMapper.getMappingFromActionName(actualName); actionName = mapping.getName(); methodName = mapping.getMethod(); String namespace; if (this.namespace == null) { namespace = TagUtils.buildNamespace(actionMapper, getStack(), req); } else { namespace = findString(this.namespace); } // get the old value stack from the request ValueStack stack = getStack(); // execute at this point, after params have been set ActionInvocation inv = ActionContext.getContext().getActionInvocation(); try { proxy = actionProxyFactory.createActionProxy(namespace, actionName, methodName, createExtraContext(), executeResult, true); // set the new stack into the request for the taglib to use req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack()); req.setAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION, Boolean.TRUE); proxy.execute(); } catch (Exception e) { String message = "Could not execute action: " + namespace + "/" + actualName; LOG.error(message, e); if (rethrowException) { throw new StrutsException(message, e); } } finally { req.removeAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION); // set the old stack back on the request req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); if (inv != null) { ActionContext.getContext().setActionInvocation(inv); } } if ((getVar() != null) && (proxy != null)) { putInContext(proxy.getAction()); } }
// in java/org/apache/struts2/views/xslt/AbstractAdapterNode.java
public Node getChildBeforeOrAfter(Node child, boolean before) { log.debug("getChildBeforeOrAfter: "); List adapters = getChildAdapters(); if (log.isDebugEnabled()) { log.debug("childAdapters = " + adapters); log.debug("child = " + child); } int index = adapters.indexOf(child); if (index < 0) throw new StrutsException(child + " is no child of " + this); int siblingIndex = before ? index - 1 : index + 1; return ((0 < siblingIndex) && (siblingIndex < adapters.size())) ? ((Node) adapters.get(siblingIndex)) : null; }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public void setData(String string) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public void appendData(String string) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public void deleteData(int i, int i1) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public void insertData(int i, String string) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public void replaceData(int i, int i1, String string) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/SimpleTextNode.java
public Text splitText(int i) throws DOMException { throw new StrutsException("Operation not supported"); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void error(TransformerException exception) throws TransformerException { throw new StrutsException("Error transforming result", exception); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void fatalError(TransformerException exception) throws TransformerException { throw new StrutsException("Fatal error transforming result", exception); }
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
private synchronized PropertyDescriptor[] getPropertyDescriptors(Object bean) { try { if (propertyDescriptorCache == null) { propertyDescriptorCache = new HashMap<Class, PropertyDescriptor[]>(); } PropertyDescriptor[] props = propertyDescriptorCache.get(bean.getClass()); if (props == null) { log.debug("Caching property descriptor for " + bean.getClass().getName()); props = Introspector.getBeanInfo(bean.getClass(), Object.class).getPropertyDescriptors(); propertyDescriptorCache.put(bean.getClass(), props); } return props; } catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); } }
// in java/org/apache/struts2/views/xslt/SimpleAdapterDocument.java
private Element getRootElement() { if (rootElement != null) return rootElement; Node node = getAdapterFactory().adaptNode( this, getPropertyName(), getPropertyValue()); if (node instanceof Element) rootElement = (Element) node; else throw new StrutsException( "Document adapter expected to wrap an Element type. Node is not an element:" + node); return rootElement; }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
private Node constructAdapterInstance(Class adapterClass, AdapterNode parent, String propertyName, Object propertyValue) { // Check to see if the class has a no-args constructor try { adapterClass.getConstructor(new Class []{}); } catch (NoSuchMethodException e1) { throw new StrutsException("Adapter class: " + adapterClass + " does not have a no-args consructor."); } try { AdapterNode adapterNode = (AdapterNode) adapterClass.newInstance(); adapterNode.setAdapterFactory(this); adapterNode.setParent(parent); adapterNode.setPropertyName(propertyName); adapterNode.setPropertyValue(propertyValue); return adapterNode; } catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); } catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); } }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
protected VelocityEngine newVelocityEngine(ServletContext context) { if (context == null) { String gripe = "Error attempting to create a new VelocityEngine from a null ServletContext!"; LOG.error(gripe); throw new IllegalArgumentException(gripe); } Properties p = loadConfiguration(context); VelocityEngine velocityEngine = new VelocityEngine(); // Set the velocity attribute for the servlet context // if this is not set the webapp loader WILL NOT WORK velocityEngine.setApplicationAttribute(ServletContext.class.getName(), context); try { velocityEngine.init(p); } catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); } return velocityEngine; }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
public void init() { if (configurationManager == null) { configurationManager = createConfigurationManager(BeanSelectionProvider.DEFAULT_BEAN_NAME); } try { init_DefaultProperties(); // [1] init_TraditionalXmlConfigurations(); // [2] init_LegacyStrutsProperties(); // [3] init_CustomConfigurationProviders(); // [5] init_FilterInitParameters() ; // [6] init_AliasStandardObjects() ; // [7] Container container = init_PreloadConfiguration(); container.inject(this); init_CheckConfigurationReloading(container); init_CheckWebLogicWorkaround(container); if (!dispatcherListeners.isEmpty()) { for (DispatcherListener l : dispatcherListeners) { l.dispatcherInitialized(this); } } } catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); } }
// in java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
public void cleanupDispatcher() { if (dispatcher == null) { throw new StrutsException("Something is seriously wrong, Dispatcher is not initialized (null) "); } else { try { dispatcher.cleanup(); } finally { ActionContext.setContext(null); } } }
14
            
// in java/org/apache/struts2/config/PropertiesSettings.java
catch (IOException e) { throw new StrutsException("Could not load " + name + ".properties:" + e, e); }
// in java/org/apache/struts2/components/I18n.java
catch (Exception e) { String msg = "Could not find the bundle " + name; throw new StrutsException(msg, e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/ServletUrlRenderer.java
catch (IOException e) { throw new StrutsException("IOError: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Component.java
catch (IOException e) { throw new StrutsException("IOError while writing the body: " + e.getMessage(), e); }
// in java/org/apache/struts2/components/Debug.java
catch (Exception e) { throw new StrutsException("Caught an exception while getting the property values of " + o, e); }
// in java/org/apache/struts2/components/UIBean.java
catch (Exception e) { throw new StrutsException(e); }
// in java/org/apache/struts2/components/ActionComponent.java
catch (Exception e) { String message = "Could not execute action: " + namespace + "/" + actualName; LOG.error(message, e); if (rethrowException) { throw new StrutsException(message, e); } }
// in java/org/apache/struts2/views/xslt/BeanAdapter.java
catch (IntrospectionException e) { e.printStackTrace(); throw new StrutsException("Error getting property descriptors for " + bean + " : " + e.getMessage()); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (NoSuchMethodException e1) { throw new StrutsException("Adapter class: " + adapterClass + " does not have a no-args consructor."); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (IllegalAccessException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/views/xslt/AdapterFactory.java
catch (InstantiationException e) { e.printStackTrace(); throw new StrutsException("Cannot adapt " + propertyValue + " (" + propertyName + ") :" + e.getMessage()); }
// in java/org/apache/struts2/views/velocity/VelocityManager.java
catch (Exception e) { String gripe = "Unable to instantiate VelocityEngine!"; throw new StrutsException(gripe, e); }
// in java/org/apache/struts2/dispatcher/Dispatcher.java
catch (Exception ex) { if (LOG.isErrorEnabled()) LOG.error("Dispatcher initialization failed", ex); throw new StrutsException(ex); }
1
            
// in java/org/apache/struts2/components/I18n.java
public boolean end(Writer writer, String body) throws StrutsException { if (pushed) { Object o = getStack().pop(); if ((o == null) || (!o.equals(textProvider))) { LOG.error("A closing i18n tag attempted to pop its own TextProvider from the top of the ValueStack but popped an unexpected object ("+(o != null ? o.getClass() : "null")+"). " + "Refactor the page within the i18n tags to ensure no objects are pushed onto the ValueStack without popping them prior to the closing tag. " + "If you see this message it's likely that the i18n's TextProvider is still on the stack and will continue to provide message resources after the closing tag."); throw new StrutsException("A closing i18n tag attempted to pop its TextProvider from the top of the ValueStack but popped an unexpected object ("+(o != null ? o.getClass() : "null")+")"); } } return super.end(writer, body); }
0 0 0
unknown (Lib) TemplateException 0 0 5
            
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
public void doExecute(String locationArg, ActionInvocation invocation) throws IOException, TemplateException { this.location = locationArg; this.invocation = invocation; this.configuration = getConfiguration(); this.wrapper = getObjectWrapper(); ActionContext ctx = invocation.getInvocationContext(); HttpServletRequest req = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST); if (!locationArg.startsWith("/")) { String base = ResourceUtil.getResourceBase(req); locationArg = base + "/" + locationArg; } Template template = configuration.getTemplate(locationArg, deduceLocale()); TemplateModel model = createModel(); // Give subclasses a chance to hook into preprocessing if (preTemplateProcess(template, model)) { try { // Process the template Writer writer = getWriter(); if (isWriteIfCompleted() || configuration.getTemplateExceptionHandler() == TemplateExceptionHandler.RETHROW_HANDLER) { CharArrayWriter parentCharArrayWriter = (CharArrayWriter) req.getAttribute(PARENT_TEMPLATE_WRITER); boolean isTopTemplate = false; if (isTopTemplate = (parentCharArrayWriter == null)) { //this is the top template parentCharArrayWriter = new CharArrayWriter(); //set it in the request because when the "action" tag is used a new VS and ActionContext is created req.setAttribute(PARENT_TEMPLATE_WRITER, parentCharArrayWriter); } try { template.process(model, parentCharArrayWriter); if (isTopTemplate) { parentCharArrayWriter.flush(); parentCharArrayWriter.writeTo(writer); } } finally { if (isTopTemplate && parentCharArrayWriter != null) { req.removeAttribute(PARENT_TEMPLATE_WRITER); parentCharArrayWriter.close(); } } } else { template.process(model, writer); } } finally { // Give subclasses a chance to hook into postprocessing postTemplateProcess(template, model); } } }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
protected Configuration getConfiguration() throws TemplateException { return freemarkerManager.getConfiguration(ServletActionContext.getServletContext()); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
public void init(ServletContext servletContext) throws TemplateException { config = createConfiguration(servletContext); // Set defaults: config.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER); contentType = DEFAULT_CONTENT_TYPE; // Process object_wrapper init-param out of order: wrapper = createObjectWrapper(servletContext); if (LOG.isDebugEnabled()) { LOG.debug("Using object wrapper of class " + wrapper.getClass().getName()); } config.setObjectWrapper(wrapper); // Process TemplatePath init-param out of order: templatePath = servletContext.getInitParameter(INITPARAM_TEMPLATE_PATH); if (templatePath == null) { templatePath = servletContext.getInitParameter("templatePath"); } config.setTemplateLoader(createTemplateLoader(servletContext, templatePath)); loadSettings(servletContext); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
protected Configuration createConfiguration(ServletContext servletContext) throws TemplateException { Configuration configuration = new Configuration(); configuration.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER); if (mruMaxStrongSize > 0) { configuration.setSetting(Configuration.CACHE_STORAGE_KEY, "strong:" + mruMaxStrongSize); } if (templateUpdateDelay != null) { configuration.setSetting(Configuration.TEMPLATE_UPDATE_DELAY_KEY, templateUpdateDelay); } if (encoding != null) { configuration.setDefaultEncoding(encoding); } configuration.setWhitespaceStripping(true); return configuration; }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
public void addSetting(String name, String value) throws TemplateException { // Process all other init-params: if (name.equals(INITPARAM_NOCACHE)) { nocache = StringUtil.getYesNo(value); } else if (name.equals(INITPARAM_DEBUG)) { debug = StringUtil.getYesNo(value); } else if (name.equals(INITPARAM_CONTENT_TYPE)) { contentType = value; } else { config.setSetting(name, value); } if (contentType != null && !contentTypeEvaluated) { int i = contentType.toLowerCase().indexOf("charset="); contentTypeEvaluated = true; if (i != -1) { char c = ' '; i--; while (i >= 0) { c = contentType.charAt(i); if (!Character.isWhitespace(c)) break; i--; } if (i == -1 || c == ';') { noCharsetInContentType = false; } } } }
2
            
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (TemplateException e) { LOG.error("Cannot load freemarker configuration: ",e); }
// in java/org/apache/struts2/views/freemarker/FreemarkerManager.java
catch (TemplateException e) { LOG.error("Error while loading freemarker settings from /freemarker.properties", e); }
0 0
unknown (Lib) TemplateModelException 0 0 5
            
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public int onStart() throws TemplateModelException, IOException { boolean result = bean.start(this); if (result) { return EVALUATE_BODY; } else { return SKIP_BODY; } }
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public int afterBody() throws TemplateModelException, IOException { afterBody = true; boolean result = bean.end(this, bean.usesBody() ? body.toString() : ""); if (result) { return REPEAT_EVALUATION; } else { return END_EVALUATION; } }
// in java/org/apache/struts2/views/freemarker/tags/TagModel.java
public Writer getWriter(Writer writer, Map params) throws TemplateModelException, IOException { Component bean = getBean(); Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); Map unwrappedParameters = unwrapParameters(params); bean.copyParams(unwrappedParameters); return new CallbackWriter(bean, writer); }
// in java/org/apache/struts2/views/freemarker/ScopesHashModel.java
public TemplateModel get(String key) throws TemplateModelException { // Lookup in default scope TemplateModel model = super.get(key); if (model != null) { return model; } if (stack != null) { Object obj = findValueOnStack(key); if (obj != null) { return wrap(obj); } // ok, then try the context obj = stack.getContext().get(key); if (obj != null) { return wrap(obj); } } if (request != null) { // Lookup in request scope Object obj = request.getAttribute(key); if (obj != null) { return wrap(obj); } // Lookup in session scope HttpSession session = request.getSession(false); if (session != null) { obj = session.getAttribute(key); if (obj != null) { return wrap(obj); } } } if (servletContext != null) { // Lookup in application scope Object obj = servletContext.getAttribute(key); if (obj != null) { return wrap(obj); } } // Look in unlisted models model = unlistedModels.get(key); if(model != null) { return wrap(model); } return null; }
// in java/org/apache/struts2/views/freemarker/FreemarkerResult.java
protected TemplateModel createModel() throws TemplateModelException { ServletContext servletContext = ServletActionContext.getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); ValueStack stack = ServletActionContext.getContext().getValueStack(); Object action = null; if(invocation!= null ) action = invocation.getAction(); //Added for NullPointException return freemarkerManager.buildTemplateModel(stack, action, servletContext, request, response, wrapper); }
2
            
// in java/org/apache/struts2/views/freemarker/tags/TagModel.java
catch (TemplateModelException e) { LOG.error("failed to unwrap [" + value + "] it will be ignored", e); }
// in java/org/apache/struts2/views/freemarker/tags/TagModel.java
catch (TemplateModelException e) { LOG.error("There was a problem converting a SimpleSequence to a list", e); }
0 0
checked (Lib) Throwable 0 0 1
            
// in java/org/apache/struts2/views/freemarker/tags/CallbackWriter.java
public void onError(Throwable throwable) throws Throwable { throw throwable; }
1
            
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (Throwable e) { writeToFile(); throw new RuntimeException(e); }
1
            
// in java/org/apache/struts2/util/FastByteArrayOutputStream.java
catch (Throwable e) { writeToFile(); throw new RuntimeException(e); }
1
unknown (Lib) TransformerException 4
            
// in java/org/apache/struts2/views/xslt/XSLTResult.java
protected Templates getTemplates(String path) throws TransformerException, IOException { String pathFromRequest = ServletActionContext.getRequest().getParameter("xslt.location"); if (pathFromRequest != null) path = pathFromRequest; if (path == null) throw new TransformerException("Stylesheet path is null"); Templates templates = templatesCache.get(path); if (noCache || (templates == null)) { synchronized (templatesCache) { URL resource = ServletActionContext.getServletContext().getResource(path); if (resource == null) { throw new TransformerException("Stylesheet " + path + " not found in resources."); } if (LOG.isDebugEnabled()) { LOG.debug("Preparing XSLT stylesheet templates: " + path); } TransformerFactory factory = TransformerFactory.newInstance(); factory.setURIResolver(getURIResolver()); templates = factory.newTemplates(new StreamSource(resource.openStream())); templatesCache.put(path, templates); } } return templates; }
// in java/org/apache/struts2/views/xslt/ServletURIResolver.java
public Source resolve(String href, String base) throws TransformerException { log.debug("ServletURIResolver resolve(): href=" + href + ", base=" + base); if (href.startsWith(PROTOCOL)) { String res = href.substring(PROTOCOL.length()); log.debug("Resolving resource <" + res + ">"); InputStream is = sc.getResourceAsStream(res); if (is == null) { throw new TransformerException( "Resource " + res + " not found in resources."); } return new StreamSource(is); } throw new TransformerException( "Cannot handle procotol of resource " + href); }
0 5
            
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void execute(ActionInvocation invocation) throws Exception { long startTime = System.currentTimeMillis(); String location = getStylesheetLocation(); if (parse) { ValueStack stack = ActionContext.getContext().getValueStack(); location = TextParseUtil.translateVariables(location, stack); } try { HttpServletResponse response = ServletActionContext.getResponse(); PrintWriter writer = response.getWriter(); // Create a transformer for the stylesheet. Templates templates = null; Transformer transformer; if (location != null) { templates = getTemplates(location); transformer = templates.newTransformer(); } else transformer = TransformerFactory.newInstance().newTransformer(); transformer.setURIResolver(getURIResolver()); transformer.setErrorListener(new ErrorListener() { public void error(TransformerException exception) throws TransformerException { throw new StrutsException("Error transforming result", exception); } public void fatalError(TransformerException exception) throws TransformerException { throw new StrutsException("Fatal error transforming result", exception); } public void warning(TransformerException exception) throws TransformerException { if (LOG.isWarnEnabled()) { LOG.warn(exception.getMessage(), exception); } } }); String mimeType; if (templates == null) mimeType = "text/xml"; // no stylesheet, raw xml else mimeType = templates.getOutputProperties().getProperty(OutputKeys.MEDIA_TYPE); if (mimeType == null) { // guess (this is a servlet, so text/html might be the best guess) mimeType = "text/html"; } response.setContentType(mimeType); Object result = invocation.getAction(); if (exposedValue != null) { ValueStack stack = invocation.getStack(); result = stack.findValue(exposedValue); } Source xmlSource = getDOMSourceForStack(result); // Transform the source XML to System.out. if (LOG.isDebugEnabled()) { LOG.debug("xmlSource = " + xmlSource); } transformer.transform(xmlSource, new StreamResult(writer)); writer.flush(); // ...and flush... if (LOG.isDebugEnabled()) { LOG.debug("Time:" + (System.currentTimeMillis() - startTime) + "ms"); } } catch (Exception e) { LOG.error("Unable to render XSLT Template, '" + location + "'", e); throw e; } }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void error(TransformerException exception) throws TransformerException { throw new StrutsException("Error transforming result", exception); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void fatalError(TransformerException exception) throws TransformerException { throw new StrutsException("Fatal error transforming result", exception); }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
public void warning(TransformerException exception) throws TransformerException { if (LOG.isWarnEnabled()) { LOG.warn(exception.getMessage(), exception); } }
// in java/org/apache/struts2/views/xslt/XSLTResult.java
protected Templates getTemplates(String path) throws TransformerException, IOException { String pathFromRequest = ServletActionContext.getRequest().getParameter("xslt.location"); if (pathFromRequest != null) path = pathFromRequest; if (path == null) throw new TransformerException("Stylesheet path is null"); Templates templates = templatesCache.get(path); if (noCache || (templates == null)) { synchronized (templatesCache) { URL resource = ServletActionContext.getServletContext().getResource(path); if (resource == null) { throw new TransformerException("Stylesheet " + path + " not found in resources."); } if (LOG.isDebugEnabled()) { LOG.debug("Preparing XSLT stylesheet templates: " + path); } TransformerFactory factory = TransformerFactory.newInstance(); factory.setURIResolver(getURIResolver()); templates = factory.newTemplates(new StreamSource(resource.openStream())); templatesCache.put(path, templates); } } return templates; }
// in java/org/apache/struts2/views/xslt/ServletURIResolver.java
public Source resolve(String href, String base) throws TransformerException { log.debug("ServletURIResolver resolve(): href=" + href + ", base=" + base); if (href.startsWith(PROTOCOL)) { String res = href.substring(PROTOCOL.length()); log.debug("Resolving resource <" + res + ">"); InputStream is = sc.getResourceAsStream(res); if (is == null) { throw new TransformerException( "Resource " + res + " not found in resources."); } return new StreamSource(is); } throw new TransformerException( "Cannot handle procotol of resource " + href); }
0 0 0
unknown (Lib) UnsupportedEncodingException 0 0 3
            
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
private void processUpload(HttpServletRequest request, String saveDir) throws FileUploadException, UnsupportedEncodingException { for (FileItem item : parseRequest(request, saveDir)) { if (LOG.isDebugEnabled()) { LOG.debug("Found item " + item.getFieldName()); } if (item.isFormField()) { processNormalFormField(item, request.getCharacterEncoding()); } else { processFileField(item); } } }
// in java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
private void processNormalFormField(FileItem item, String charset) throws UnsupportedEncodingException { if (LOG.isDebugEnabled()) { LOG.debug("Item is a normal form field"); } List<String> values; if (params.get(item.getFieldName()) != null) { values = params.get(item.getFieldName()); } else { values = new ArrayList<String>(); } // note: see http://jira.opensymphony.com/browse/WW-633 // basically, in some cases the charset may be null, so // we're just going to try to "other" method (no idea if this // will work) if (charset != null) { values.add(item.getString(charset)); } else { values.add(item.getString()); } params.put(item.getFieldName(), values); }
// in java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
protected String buildPath(String name, String packagePrefix) throws UnsupportedEncodingException { String resourcePath; if (packagePrefix.endsWith("/") && name.startsWith("/")) { resourcePath = packagePrefix + name.substring(1); } else { resourcePath = packagePrefix + name; } return URLDecoder.decode(resourcePath, encoding); }
4
            
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); } return translatedInput; }
// in java/org/apache/struts2/views/util/DefaultUrlHelper.java
catch (UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); } return translatedInput; }
// in java/org/apache/struts2/dispatcher/StrutsResultSupport.java
catch(UnsupportedEncodingException e) { if (LOG.isWarnEnabled()) { LOG.warn("error while trying to encode ["+parsedValue+"]", e); } }
// in java/org/apache/struts2/util/StrutsUtil.java
catch (UnsupportedEncodingException e) { return s; }
0 0
runtime (Lib) UnsupportedOperationException 32
            
// in java/org/apache/struts2/config/Settings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { throw new UnsupportedOperationException("Settings: This implementation does not support setting a value."); }
// in java/org/apache/struts2/config/Settings.java
public Iterator listImpl() { throw new UnsupportedOperationException("Settings: This implementation does not support listing the registered settings"); }
// in java/org/apache/struts2/components/IteratorComponent.java
public void remove() { throw new UnsupportedOperationException("Values cannot be removed from this iterator"); }
// in java/org/apache/struts2/views/xslt/ProxyAttrAdapter.java
public void setValue(String string) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyNamedNodeMap.java
public Node removeNamedItem(String name) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyNamedNodeMap.java
public Node setNamedItem(Node arg) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyNamedNodeMap.java
public Node setNamedItemNS(Node arg) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyNamedNodeMap.java
public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public Text splitText(int offset) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public void deleteData(int offset, int count) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public void replaceData(int offset, int count, String arg) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public void insertData(int offset, String arg) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public void appendData(String arg) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyTextNodeAdapter.java
public void setData(String data) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public void removeAttribute(String name) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public void removeAttributeNS(String namespaceURI, String localName) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public void setAttribute(String name, String value) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public Attr removeAttributeNode(Attr oldAttr) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public Attr setAttributeNode(Attr newAttr) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public Attr setAttributeNodeNS(Attr newAttr) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/views/xslt/ProxyElementAdapter.java
public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/util/IteratorGenerator.java
public void remove() { throw new UnsupportedOperationException("Remove is not supported in IteratorGenerator."); }
// in java/org/apache/struts2/util/AppendIteratorFilter.java
public void remove() { throw new UnsupportedOperationException(); }
// in java/org/apache/struts2/util/SortIteratorFilter.java
public void remove() { throw new UnsupportedOperationException("Remove is not supported in SortIteratorFilter."); }
// in java/org/apache/struts2/util/IteratorFilterSupport.java
public void remove() { throw new UnsupportedOperationException("Remove is not supported in IteratorFilterSupport."); }
// in java/org/apache/struts2/util/MergeIteratorFilter.java
public void remove() { throw new UnsupportedOperationException("Remove is not supported in MergeIteratorFilter."); }
// in java/org/apache/struts2/util/AttributeMap.java
public boolean isEmpty() { throw new UnsupportedOperationException(UNSUPPORTED); }
// in java/org/apache/struts2/util/AttributeMap.java
public void clear() { throw new UnsupportedOperationException(UNSUPPORTED); }
// in java/org/apache/struts2/util/AttributeMap.java
public boolean containsValue(Object value) { throw new UnsupportedOperationException(UNSUPPORTED); }
// in java/org/apache/struts2/util/AttributeMap.java
public void putAll(Map t) { throw new UnsupportedOperationException(UNSUPPORTED); }
// in java/org/apache/struts2/util/AttributeMap.java
public Object remove(Object key) { throw new UnsupportedOperationException(UNSUPPORTED); }
// in java/org/apache/struts2/util/AttributeMap.java
public int size() { throw new UnsupportedOperationException(UNSUPPORTED); }
0 4
            
// in java/org/apache/struts2/config/DefaultSettings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { delegate.setImpl(name, value); }
// in java/org/apache/struts2/config/Settings.java
public static void set(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { getInstance().setImpl(name, value); }
// in java/org/apache/struts2/config/Settings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { throw new UnsupportedOperationException("Settings: This implementation does not support setting a value."); }
// in java/org/apache/struts2/config/DelegatingSettings.java
public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { IllegalArgumentException e = null; for (Settings delegate : delegates) { try { delegate.getImpl(name); // Throws exception if not found delegate.setImpl(name, value); // Found it return; // Done } catch (IllegalArgumentException ex) { e = ex; // Try next delegate } } throw e; }
1
            
// in java/org/apache/struts2/config/DelegatingSettings.java
catch (UnsupportedOperationException ex) { e = ex; // Try next delegate }
0 0

Miscellanous Metrics

nF = Number of Finally 42
nF = Number of Try-Finally (without catch) 29
Number of Methods with Finally (nMF) 35 / 2084 (1.7%)
Number of Finally with a Continue 0
Number of Finally with a Return 0
Number of Finally with a Throw 0
Number of Finally with a Break 0
Number of different exception types thrown 14
Number of Domain exception types thrown 1
Number of different exception types caught 25
Number of Domain exception types caught 0
Number of exception declarations in signatures 281
Number of different exceptions types declared in method signatures 26
Number of library exceptions types declared in method signatures 25
Number of Domain exceptions types declared in method signatures 1
Number of Catch with a continue 2
Number of Catch with a return 12
Number of Catch with a Break 1
nbIf = Number of If 1470
nbFor = Number of For 133
Number of Method with an if 485 / 2084
Number of Methods with a for 97 / 2084
Number of Method starting with a try 16 / 2084 (0.8%)
Number of Expressions 17345
Number of Expressions in try 1644 (9.5%)