struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcin Gryszko (JIRA)" <j...@apache.org>
Subject [jira] Commented: (WW-1978) NPE in XWorkConverter.loadConversionProperties after adding DateConverter
Date Thu, 14 Jun 2007 11:37:26 GMT

    [ https://issues.apache.org/struts/browse/WW-1978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_41235
] 

Marcin Gryszko commented on WW-1978:
------------------------------------

I experience the same problem with Struts 2.0.8. I had a simple BooleanConverter working with
Webwork 2.2.4 and XWork 1.2.1. When switching to Struts 2.0.8 I got the same exception as
Matt.

It seems to be the same issue as http://jira.opensymphony.com/browse/XW-460.

> NPE in XWorkConverter.loadConversionProperties after adding DateConverter
> -------------------------------------------------------------------------
>
>                 Key: WW-1978
>                 URL: https://issues.apache.org/struts/browse/WW-1978
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.6, 2.0.8
>            Reporter: Matt Raible
>
> I recently added a DateConverter to my project (Struts 2.0.6, Maven 2) and now I'm getting
NPEs when running tests.
> xwork-conversion.properties:
> java.util.Date=org.appfuse.webapp.action.DateConverter
> DateConverter.java:
> public class DateConverter extends StrutsTypeConverter {
>     public Object convertFromString(Map ctx, String[] value, Class arg2) {
>         if (value[0] == null || value[0].trim().equals("")) {
>             return null;
>         }
>         try {
>             return DateUtil.convertStringToDate(value[0]);
>         } catch (ParseException pe) {
>             pe.printStackTrace();
>             throw new TypeConversionException(pe.getMessage());
>         }
>     }
>     public String convertToString(Map ctx, Object data) {
>         return DateUtil.convertDateToString((Date) data);
>     }
> }
> My test's setUp() method:
>     @Override
>     protected void onSetUpBeforeTransaction() throws Exception {
>         LocalizedTextUtil.addDefaultResourceBundle(Constants.BUNDLE_KEY);
>         ActionContext.getContext().setSession(new HashMap());
>         // change the port on the mailSender so it doesn't conflict with an
>         // existing SMTP server on localhost
>         JavaMailSenderImpl mailSender = (JavaMailSenderImpl) applicationContext.getBean("mailSender");
>         mailSender.setPort(2525);
>         mailSender.setHost("localhost");
>         // populate the request so getRequest().getSession() doesn't fail in BaseAction.java
>         ServletActionContext.setRequest(new MockHttpServletRequest());
>     }
> Stack trace:
> ERROR [main] XWorkConverter.loadConversionProperties(645) | Conversion registration error
> java.lang.NullPointerException
>         at com.opensymphony.xwork2.util.XWorkConverter.createTypeConverter(XWorkConverter.java:621)
>         at com.opensymphony.xwork2.util.XWorkConverter.loadConversionProperties(XWorkConverter.java:639)
>         at com.opensymphony.xwork2.util.XWorkConverter.<init>(XWorkConverter.java:176)
>         at com.opensymphony.xwork2.util.AnnotationXWorkConverter.<init>(AnnotationXWorkConverter.java:98)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>         at java.lang.Class.newInstance0(Class.java:350)
>         at java.lang.Class.newInstance(Class.java:303)
>         at com.opensymphony.xwork2.util.XWorkConverter.getInstance(XWorkConverter.java:202)
>         at com.opensymphony.xwork2.util.XWorkMapPropertyAccessor.<clinit>(XWorkMapPropertyAccessor.java:30)
>         at com.opensymphony.xwork2.util.OgnlValueStack.reset(OgnlValueStack.java:47)
>         at com.opensymphony.xwork2.util.OgnlValueStack.<clinit>(OgnlValueStack.java:37)
>         at com.opensymphony.xwork2.util.OgnlValueStackFactory.createValueStack(OgnlValueStackFactory.java:14)
>         at com.opensymphony.xwork2.ActionContext$ActionContextThreadLocal.initialValue(ActionContext.java:329)
>         at java.lang.ThreadLocal$ThreadLocalMap.getAfterMiss(ThreadLocal.java:374)
>         at java.lang.ThreadLocal$ThreadLocalMap.get(ThreadLocal.java:347)
>         at java.lang.ThreadLocal$ThreadLocalMap.access$000(ThreadLocal.java:225)
>         at java.lang.ThreadLocal.get(ThreadLocal.java:127)
>         at com.opensymphony.xwork2.ActionContext.getContext(ActionContext.java:151)
>         at org.appfuse.webapp.action.BaseActionTestCase.onSetUpBeforeTransaction(BaseActionTestCase.java:35)

> I tested this with Struts 2.0.8 and there's no change.
> I posted this to the mailing list, but received no responses.
> http://www.nabble.com/Testing-error-after-adding-DateConverter-tf3868021.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message