You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by "S.Hage" <sa...@hotmail.com> on 2010/04/27 18:33:40 UTC

'fail-property' inside 'call-map-processor' problem

Hi all,

  I'm writing a couple of tests to create a simple service. The service is
called from java code. When I call 'fail-property ' inside a
'call-map-processor ' I get 'Locate cannot be null' but if I use it inside
an 'if-compare' every thing is ok.  I would like to notice that i'm using
the latest trunk.

Any help is appreciated.

Here's the methods code called by the service:

test 1 (inside if-compare):
====================
<?xml version="1.0" encoding="UTF-8" ?>

<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
    <simple-method method-name="test1" short-description="test1"
login-required="false">

        <!-- TEST  1 -->
        <set field="require_login" value="true"/>
        <if-compare field="require_login" operator="equals" value="true">
            <add-error>
              <fail-property resource="PartyUiLabels"
property="PartyUserNameMissing"/>
            </add-error>
        </if-compare>

    </simple-method>
</simple-methods>


this test is correct;

test 2 inside call-map-processor:
=========================
<?xml version="1.0" encoding="UTF-8" ?>

<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
    <simple-method method-name="test2" short-description="test2"
login-required="false">
        
        <!-- TEST  2 -->
        <call-map-processor in-map-name="parameters"
out-map-name="personContext">
            <simple-map-processor name="newPerson">
                <process field="USER_FIRST_NAME"><copy
to-field="firstName"/>
                  <not-empty> 
                      <fail-property resource="PartyUiLabels"
property="PartyFirstNameMissing"/>
                  </not-empty>
                </process>
            </simple-map-processor>
        </call-map-processor>

this test logged the error 'locate cannot be null' in ofbiz.log


thanks in advance

Saad.
-- 
View this message in context: http://ofbiz.135035.n4.nabble.com/fail-property-inside-call-map-processor-problem-tp2067904p2067904.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: 'fail-property' inside 'call-map-processor' problem

Posted by Shubham Dubey <sh...@hotwaxmedia.com>.
Hi Hage

The code you are trying to write is correct, adding something more you 
need to add a additional tag  <check-errors/>
see (CheckErrors.java code) which returns the fail-property errors for 
you .

S.Hage wrote:
> Hi all,
>
>   I'm writing a couple of tests to create a simple service. The service is
> called from java code. When I call 'fail-property ' inside a
> 'call-map-processor ' I get 'Locate cannot be null' but if I use it inside
> an 'if-compare' every thing is ok.  I would like to notice that i'm using
> the latest trunk.
>
> Any help is appreciated.
>
> Here's the methods code called by the service:
>
> test 1 (inside if-compare):
> ====================
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        
> xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
>     <simple-method method-name="test1" short-description="test1"
> login-required="false">
>
>         <!-- TEST  1 -->
>         <set field="require_login" value="true"/>
>         <if-compare field="require_login" operator="equals" value="true">
>             <add-error>
>               <fail-property resource="PartyUiLabels"
> property="PartyUserNameMissing"/>
>             </add-error>
>         </if-compare>
>
>     </simple-method>
> </simple-methods>
>
>
> this test is correct;
>
> test 2 inside call-map-processor:
> =========================
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        
> xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
>     <simple-method method-name="test2" short-description="test2"
> login-required="false">
>         
>         <!-- TEST  2 -->
>         <call-map-processor in-map-name="parameters"
> out-map-name="personContext">
>             <simple-map-processor name="newPerson">
>                 <process field="USER_FIRST_NAME"><copy
> to-field="firstName"/>
>                   <not-empty> 
>                       <fail-property resource="PartyUiLabels"
> property="PartyFirstNameMissing"/>
>                   </not-empty>
>                 </process>
>             </simple-map-processor>
>         </call-map-processor>
>
> this test logged the error 'locate cannot be null' in ofbiz.log
>
>
> thanks in advance
>
> Saad.
>   

-- 
Thanks & Regards
Shubham Dubey
Jr. Software Developer
HotWax Media Pvt. Ltd.
http://www.hotwaxmedia.com/ 


Re: 'fail-property' inside 'call-map-processor' problem

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Fixed in trunk r939966 and 10.04 r939967, thanks for the report.

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 1/05/2010, at 1:16 PM, S.Hage wrote:

> 
> I'm using the trunk rev 937852.
> 
> Saad.
> -- 
> View this message in context: http://ofbiz.135035.n4.nabble.com/fail-property-inside-call-map-processor-problem-tp2067904p2077671.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.


Re: 'fail-property' inside 'call-map-processor' problem

Posted by "S.Hage" <sa...@hotmail.com>.
I'm using the trunk rev 937852.

Saad.
-- 
View this message in context: http://ofbiz.135035.n4.nabble.com/fail-property-inside-call-map-processor-problem-tp2067904p2077671.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: 'fail-property' inside 'call-map-processor' problem

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Thanks Saad, I'll take a look at the history and just check why it was the way it was before committing the fix.  Are you using the trunk or 9.04?

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 1/05/2010, at 8:13 AM, S.Hage wrote:

> 
> Hi Scott,
> 
>   I changed the code like you suggested and YES this fix the problem.
> 
> 
> Thanks
> 
> Saad.
> -- 
> View this message in context: http://ofbiz.135035.n4.nabble.com/fail-property-inside-call-map-processor-problem-tp2067904p2077449.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.


Re: 'fail-property' inside 'call-map-processor' problem

Posted by "S.Hage" <sa...@hotmail.com>.
Hi Scott,

   I changed the code like you suggested and YES this fix the problem.


Thanks

Saad.
-- 
View this message in context: http://ofbiz.135035.n4.nabble.com/fail-property-inside-call-map-processor-problem-tp2067904p2077449.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: 'fail-property' inside 'call-map-processor' problem

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Hi Saad,

Could you try changing the following line in CallSimpleMapProcessor.java (101-106):
        // run inlined map processor last so it can override the external map processor
        if (inlineMapProcessor != null) {
            inlineMapProcessor.exec(inMap, outMap, messages,
                (methodContext.getRequest() != null ? methodContext.getRequest().getLocale() : null),
                methodContext.getLoader());
        }

Change this:
                (methodContext.getRequest() != null ? methodContext.getRequest().getLocale() : null),
to this:
                methodContext.getLocale(),

and let me know if it helps any.  Note you'll need to recompile first if that wasn't obvious.

Thanks
Scott

HotWax Media
http://www.hotwaxmedia.com

On 29/04/2010, at 2:34 AM, S.Hage wrote:

> 
> HI Shubham,
> 
>  Thanks for your response. 
> 
> The problem is when I use (fail-property  resource="PartyUiLabels"
> property="PartyFirstNameMissing")  ofbiz log this error message in ofbiz.log
> file (you see all java stack above): 
> 
> Error in simple-method operation [<call-simple-map-processor/>]:
> java.lang.IllegalArgumentException: locale cannot be null
> Exception: java.lang.IllegalArgumentException
> Message: locale cannot be null
> 
> Even if in my java code I sent the locale object in the context like this:
> 
>              locale = UtilHttp.getLocale(request);
>              Map context = FastMap.newInstance();
> 	      context.put("locale",locale);
> 	      context.put("userLogin",userLogin);
>              ...
>              Map summaryResult = dispatcher.runSync("ccmsCreateGuarantor",
> context);
> 
> 
> And the PartyUiLabels is set in the commonScreen.xml like this:
>  <property-map resource="PartyUiLabels" map-name="uiLabelMap"
> global="true"/>
> 
> I'm stuck here because I can't figure out why the java exception and why
> locale is null. I logged the value of locale just before 
> 'call-map-processor' and the value is correct (fr_CA). 
> 
> Thanks
> 
> Saad.
> -- 
> View this message in context: http://ofbiz.135035.n4.nabble.com/fail-property-inside-call-map-processor-problem-tp2067904p2069307.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.


Re: 'fail-property' inside 'call-map-processor' problem

Posted by "S.Hage" <sa...@hotmail.com>.
HI Shubham,

  Thanks for your response. 

The problem is when I use (fail-property  resource="PartyUiLabels"
property="PartyFirstNameMissing")  ofbiz log this error message in ofbiz.log
file (you see all java stack above): 

Error in simple-method operation [<call-simple-map-processor/>]:
java.lang.IllegalArgumentException: locale cannot be null
Exception: java.lang.IllegalArgumentException
Message: locale cannot be null

Even if in my java code I sent the locale object in the context like this:

              locale = UtilHttp.getLocale(request);
              Map context = FastMap.newInstance();
	      context.put("locale",locale);
	      context.put("userLogin",userLogin);
              ...
              Map summaryResult = dispatcher.runSync("ccmsCreateGuarantor",
context);


And the PartyUiLabels is set in the commonScreen.xml like this:
  <property-map resource="PartyUiLabels" map-name="uiLabelMap"
global="true"/>

I'm stuck here because I can't figure out why the java exception and why
locale is null. I logged the value of locale just before 
'call-map-processor' and the value is correct (fr_CA). 

Thanks

Saad.
-- 
View this message in context: http://ofbiz.135035.n4.nabble.com/fail-property-inside-call-map-processor-problem-tp2067904p2069307.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: 'fail-property' inside 'call-map-processor' problem

Posted by Shubham Dubey <sh...@hotwaxmedia.com>.
<call-map-processor in-map-name="parameters"
out-map-name="personContext">
            <simple-map-processor name="newPerson">
                <process field="USER_FIRST_NAME"><copy
to-field="firstName"/>
                  <not-empty>                       <fail-property 
resource="PartyUiLabels"
property="PartyFirstNameMissing"/>
                  </not-empty>
                </process>
            </simple-map-processor>
        </call-map-processor>
<check-errors/>


S.Hage wrote:
> Hi all,
>
>   I'm writing a couple of tests to create a simple service. The service is
> called from java code. When I call 'fail-property ' inside a
> 'call-map-processor ' I get 'Locate cannot be null' but if I use it inside
> an 'if-compare' every thing is ok.  I would like to notice that i'm using
> the latest trunk.
>
> Any help is appreciated.
>
> Here's the methods code called by the service:
>
> test 1 (inside if-compare):
> ====================
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        
> xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
>     <simple-method method-name="test1" short-description="test1"
> login-required="false">
>
>         <!-- TEST  1 -->
>         <set field="require_login" value="true"/>
>         <if-compare field="require_login" operator="equals" value="true">
>             <add-error>
>               <fail-property resource="PartyUiLabels"
> property="PartyUserNameMissing"/>
>             </add-error>
>         </if-compare>
>
>     </simple-method>
> </simple-methods>
>
>
> this test is correct;
>
> test 2 inside call-map-processor:
> =========================
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        
> xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
>     <simple-method method-name="test2" short-description="test2"
> login-required="false">
>         
>         <!-- TEST  2 -->
>         <call-map-processor in-map-name="parameters"
> out-map-name="personContext">
>             <simple-map-processor name="newPerson">
>                 <process field="USER_FIRST_NAME"><copy
> to-field="firstName"/>
>                   <not-empty> 
>                       <fail-property resource="PartyUiLabels"
> property="PartyFirstNameMissing"/>
>                   </not-empty>
>                 </process>
>             </simple-map-processor>
>         </call-map-processor>
>
> this test logged the error 'locate cannot be null' in ofbiz.log
>
>
> thanks in advance
>
> Saad.
>   

-- 
Thanks & Regards
Shubham Dubey
Jr. Software Developer
HotWax Media Pvt. Ltd.
http://www.hotwaxmedia.com/