mpop
mpop

Reputation: 499

Turning off OGNL warnings in Struts 2

I am trying to turn off the following warning message

OgnlValueStac W com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn Error setting expression 'checkboxidentifyer' with value '[Ljava.lang.String;@518b518b'

I have tried putting the following in my log4j.xml file

<logger name="log4j.logger.org.apache.struts2" >
    <level value="ERROR" />
    <appender-ref ref="console" />
</logger>
<logger name="log4j.logger.com.opensymphony" >
  <level value="ERROR" />
  <appender-ref ref="console" />
</logger>
<logger name="ognl.OgnlException" >
  <level value="ERROR" />
     <appender-ref ref="console" />
</logger>
<logger name="com.opensymphony.xwork2.util.logging.commons.CommonsLogger" >
  <level value="ERROR" />
  <appender-ref ref="console" />
</logger>
<logger name="ognl.OgnlRuntime" >
  <level value="ERROR" />
  <appender-ref ref="console" />
</logger>

I have also tried adding

<constant name="struts.devMode" value="false" />

to my struts.xml file. Also I have tried adding the following to the interceptor-stack section of the struts.xml file

<interceptor-ref name="defaultStack">
    <param name="excludeParams">.*?checkbox.*</param>
</interceptor-ref>

My questions are:

  1. Did I do a miss configuration?
  2. How do you disable the warnings.

Upvotes: 1

Views: 2580

Answers (2)

Roman C
Roman C

Reputation: 1

The excludeParams is a property of the params interceptor and should be referenced like this

<interceptor-ref name="defaultStack">
    <param name="params.excludeParams">.*?checkbox.*</param>
</interceptor-ref>

Note, if you use interceptor-ref tag on the action then it overrides the default interceptor stack and applicable only to this action config. For common usage consider creating a custom interceptor stack and make it default for any action configuration.

You can set a logging level for interceptors and OGNL. Using log4j.properties

log4j.logger.com.opensymphony.xwork2.interceptor=ERROR
log4j.logger.com.opensymphony.xwork2.ognl=ERROR

Upvotes: 1

mpop
mpop

Reputation: 499

I finnaly sovled the error, while I had (as seen in the question above the param in the defaultStack interceptor-ref, when I moved the param to the interceptor-ref name params it removed the error

<interceptor-stack name="new_default_stack">
  <interceptor-ref name="params">
  <param name="paramNameMaxLength">250</param>
  <param name="excludeParams">.*?checkbox.*</param>
  </interceptor-ref>
  <interceptor-ref name="timeActions"/>
  <interceptor-ref name="defaultStack">

  </interceptor-ref>
  <interceptor-ref name="userProfile"/>
  <interceptor-ref name="valueStackManipulator"/>
  <interceptor-ref name="actionHistoryRecorder"/>
  <interceptor-ref name="cachingHeadersInterceptor"/>
</interceptor-stack>

it was the location of the excludeParams that needed to be changed.

Upvotes: 0

Related Questions