Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-9798

InitTheme.groovy can't work without request

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Trunk
    • Fix Version/s: Upcoming Release
    • Component/s: framework
    • Labels:
      None

      Description

      When a sendOrderConfirmation runs it calls InitTheme.groovy. But then there is no request and InitTheme fails:

      2017-10-02 09:13:37,302 |OFBiz-JobQueue-0     |ScriptUtil                    |W| Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No
      such property: request for class: InitTheme
      groovy.lang.MissingPropertyException: No such property: request for class: InitTheme
         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) ~[groovy-all-2.4.12.jar:2.4.12]
           at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) ~[groovy-all-2.4.12.jar:2.4.12]
         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) ~[groovy-all-2.4.12.jar:2.4.12]
              at InitTheme.run(InitTheme.groovy:26) ~[?:?]
         at org.apache.ofbiz.base.util.GroovyUtil.runScriptAtLocation(GroovyUtil.java:204) ~[ofbiz.jar:?]
             at org.apache.ofbiz.base.util.ScriptUtil.executeScript(ScriptUtil.java:342) [ofbiz.jar:?]
            at org.apache.ofbiz.base.util.ScriptUtil.executeScript(ScriptUtil.java:324) [ofbiz.jar:?]
            at org.apache.ofbiz.widget.model.AbstractModelAction$Script.runAction(AbstractModelAction.java:632) [ofbiz.jar:?]
            at org.apache.ofbiz.widget.model.AbstractModelAction.runSubActions(AbstractModelAction.java:141) [ofbiz.jar:?]
       at org.apache.ofbiz.widget.model.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:273) [ofbiz.jar:?]
              at org.apache.ofbiz.widget.model.ModelScreen.renderScreenString(ModelScreen.java:164) [ofbiz.jar:?]
          at org.apache.ofbiz.widget.model.ScreenFactory.renderReferencedScreen(ScreenFactory.java:214) [ofbiz.jar:?]
          at org.apache.ofbiz.widget.model.ModelScreenWidget$IncludeScreen.renderWidgetString(ModelScreenWidget.java:780) [ofbiz.jar:?]
        at org.apache.ofbiz.widget.model.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:98) [ofbiz.jar:?]
           at org.apache.ofbiz.widget.model.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:280) [ofbiz.jar:?]
              at org.apache.ofbiz.widget.model.ModelScreen.renderScreenString(ModelScreen.java:164) [ofbiz.jar:?]
          at org.apache.ofbiz.widget.model.ScreenFactory.renderReferencedScreen(ScreenFactory.java:214) [ofbiz.jar:?]
          at org.apache.ofbiz.widget.model.ModelScreenWidget$IncludeScreen.renderWidgetString(ModelScreenWidget.java:780) [ofbiz.jar:?]
        at org.apache.ofbiz.widget.model.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:98) [ofbiz.jar:?]
           at org.apache.ofbiz.widget.model.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:280) [ofbiz.jar:?]
              at org.apache.ofbiz.widget.model.ModelScreen.renderScreenString(ModelScreen.java:164) [ofbiz.jar:?]
          at org.apache.ofbiz.widget.model.ScreenFactory.renderReferencedScreen(ScreenFactory.java:214) [ofbiz.jar:?]
          at org.apache.ofbiz.widget.model.ModelScreenWidget$DecoratorScreen.renderWidgetString(ModelScreenWidget.java:860) [ofbiz.jar:?]
              at org.apache.ofbiz.widget.model.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:98) [ofbiz.jar:?]
           at org.apache.ofbiz.widget.model.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:280) [ofbiz.jar:?]
              at org.apache.ofbiz.widget.model.ModelScreen.renderScreenString(ModelScreen.java:164) [ofbiz.jar:?]
          at org.apache.ofbiz.widget.renderer.ScreenRenderer.render(ScreenRenderer.java:137) [ofbiz.jar:?]
             at org.apache.ofbiz.widget.renderer.ScreenRenderer.render(ScreenRenderer.java:99) [ofbiz.jar:?]
              at org.apache.ofbiz.common.email.EmailServices.sendMailFromScreen(EmailServices.java:547) [ofbiz.jar:?]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112]
              at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112]
           at org.apache.ofbiz.service.engine.StandardJavaEngine.serviceInvoker(StandardJavaEngine.java:100) [ofbiz.jar:?]
              at org.apache.ofbiz.service.engine.StandardJavaEngine.runSync(StandardJavaEngine.java:57) [ofbiz.jar:?]
              at org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:396) [ofbiz.jar:?]
              at org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:227) [ofbiz.jar:?]
              at org.apache.ofbiz.service.GenericDispatcherFactory$GenericDispatcher.runSync(GenericDispatcherFactory.java:88) [ofbiz.jar:?]
       at org.apache.ofbiz.order.order.OrderServices.sendOrderNotificationScreen(OrderServices.java:2680) [ofbiz.jar:?]
             at org.apache.ofbiz.order.order.OrderServices.sendOrderConfirmNotification(OrderServices.java:2510) [ofbiz.jar:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112]
              at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112]
           at org.apache.ofbiz.service.engine.StandardJavaEngine.serviceInvoker(StandardJavaEngine.java:100) [ofbiz.jar:?]
              at org.apache.ofbiz.service.engine.StandardJavaEngine.runSync(StandardJavaEngine.java:57) [ofbiz.jar:?]
              at org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:396) [ofbiz.jar:?]
              at org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:227) [ofbiz.jar:?]
              at org.apache.ofbiz.service.GenericDispatcherFactory$GenericDispatcher.runSync(GenericDispatcherFactory.java:88) [ofbiz.jar:?]
       at org.apache.ofbiz.service.job.GenericServiceJob.exec(GenericServiceJob.java:70) [ofbiz.jar:?]
              at org.apache.ofbiz.service.job.AbstractJob.run(AbstractJob.java:87) [ofbiz.jar:?]
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_112]
             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_112]
             at java.lang.Thread.run(Thread.java:745) [?:1.8.0_112]
      

      So InitTheme.groovy fails. A simple fix seems to check if there is a request, but then you still get a MissingPropertyException even when adding an import of HttpServletRequest.

      This is easily reproductible by creating an order and is related with PDF attachement

      2017-10-02 09:13:37,304 |OFBiz-JobQueue-0     |ModelScreen                   |E| Error rendering screen [component://common/widget/CommonScreens.xml#FoReportDecorator]: org.apache.ofbiz.widget.renderer.Screen
      RenderException: Error rendering screen [component://common/widget/CommonScreens.xml#GlobalActions]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/C
      ommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such proper
      ty: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme) (E
      rror rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: gr
      oovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException:
      No such property: request for class: InitTheme)). Rolling back transaction.
      
      2017-10-02 09:13:37,304 |OFBiz-JobQueue-0     |ModelScreen                   |E| Error rendering screen [component://ecommerce/widget/EmailOrderScreens.xml#OrderConfirmNoticePdf]: org.apache.ofbiz.widget.rend
      erer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#FoReportDecorator]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://
      common/widget/CommonScreens.xml#GlobalActions]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalAr
      gumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running scrip
      t at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme) (Error rendering screen [component://common/widget/Comm
      onScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property:
       request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme)) (Err
      or rendering screen [component://common/widget/CommonScreens.xml#GlobalActions]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#Min
      imalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for clas
      s: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme) (Error rendering scree
      n [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPro
      pertyException: No such property: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: re
      quest for class: InitTheme))). Rolling back transaction.
      
      2017-10-02 09:13:37,304 |OFBiz-JobQueue-0     |EmailServices                 |E| Error rendering PDF attachment for email: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [compo
      nent://ecommerce/widget/EmailOrderScreens.xml#OrderConfirmNoticePdf]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#FoReportDecora
      tor]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#GlobalActions]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error
      rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.
      lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No su
      ch property: request for class: InitTheme) (Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component
      ://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.gr
      oovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme)) (Error rendering screen [component://common/widget/CommonScreens.xml#GlobalActions]: org.apache.ofbiz.widget.rende
      rer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyS
      cripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lan
      g.MissingPropertyException: No such property: request for class: InitTheme) (Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error runn
      ing script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [component://
      common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme))) (Error rendering screen [component://common/widget/CommonScreens.xml#FoReportDec
      orator]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#GlobalActions]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Err
      or rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groo
      vy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No
       such property: request for class: InitTheme) (Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [compon
      ent://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme
      .groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme)) (Error rendering screen [component://common/widget/CommonScreens.xml#GlobalActions]: org.apache.ofbiz.widget.re
      nderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groo
      vyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.
      lang.MissingPropertyException: No such property: request for class: InitTheme) (Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error r
      unning script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [component
      ://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme))))
      org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://ecommerce/widget/EmailOrderScreens.xml#OrderConfirmNoticePdf]: org.apache.ofbiz.widget.renderer.ScreenRenderExceptio
      n: Error rendering screen [component://common/widget/CommonScreens.xml#FoReportDecorator]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScree
      ns.xml#GlobalActions]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error ru
      nning script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [component:
      //common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme) (Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActi
      ons]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitT
      heme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme)) (Error rendering screen [comp
      onent://common/widget/CommonScreens.xml#GlobalActions]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.I
      llegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error runni
      ng script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme) (Error rendering screen [component://common/wid
      get/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such p
      roperty: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitThem
      e))) (Error rendering screen [component://common/widget/CommonScreens.xml#FoReportDecorator]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonSc
      reens.xml#GlobalActions]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error
       running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error running script at location [compone
      nt://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme) (Error rendering screen [component://common/widget/CommonScreens.xml#MinimalA
      ctions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: In
      itTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme)) (Error rendering screen [c
      omponent://common/widget/CommonScreens.xml#GlobalActions]: org.apache.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#MinimalActions]: java.lan
      g.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme (Error ru
      nning script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme) (Error rendering screen [component://common/
      widget/CommonScreens.xml#MinimalActions]: java.lang.IllegalArgumentException: Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No suc
      h property: request for class: InitTheme (Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitT
      heme))))
      

      Actually this is related with sendMailFromScreen so more email sending jobs are concerned (as long as they have a PDF attached only?)

      1. OFBIZ-9798.patch
        0.9 kB
        Nicolas Malin

        Issue Links

          Activity

          Hide
          soledad Nicolas Malin added a comment -

          good catch Jacques !
          Can you try with the attached patch ?

          InitTheme.groovy script has been implemented at the beginning for rendering screen and I forget the case when it would be call by a service

          Show
          soledad Nicolas Malin added a comment - good catch Jacques ! Can you try with the attached patch ? InitTheme.groovy script has been implemented at the beginning for rendering screen and I forget the case when it would be call by a service
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          Hi Nicolas,

          Unfortunately it does not work because visualThemeId is always null in this case and we have no request.
          I added println("visualThemeId=========" + visualThemeId) to your patch

          +import javax.servlet.http.HttpServletRequest;
          
          -VisualTheme visualTheme = ThemeFactory.resolveVisualTheme(request)
          +
          +String visualThemeId = context.visualThemeId
          +println("visualThemeId=========" + visualThemeId)
          +VisualTheme visualTheme
          +if (! visualThemeId) visualThemeId = parameters?.visualThemeId
          +println("visualThemeId=========" + visualThemeId)
          +if (visualThemeId) visualTheme = ThemeFactory.getVisualThemeFromId(visualThemeId)
          +else visualTheme = ThemeFactory.resolveVisualTheme(request?:null)
          +
           if (visualTheme) {
               ModelTheme modelTheme = visualTheme.getModelTheme()
               globalContext.commonScreenLocations = modelTheme.getModelCommonScreens()
          

          But got the same error

          2017-10-03 10:02:09,023 |OFBiz-JobQueue-0     |ServiceDispatcher             |T| Sync service [default/getReturnableItems] finished in [14] milliseconds
          visualThemeId=========null
          visualThemeId=========null
          2017-10-03 10:02:09,036 |OFBiz-JobQueue-0     |ScriptUtil                    |W| Error running script at location [component://common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No
          such property: request for class: InitTheme
          groovy.lang.MissingPropertyException: No such property: request for class: InitTheme
             at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) ~[groovy-all-2.4.12.jar:2.4.12]
               at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) ~[groovy-all-2.4.12.jar:2.4.12]
             at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) ~[groovy-all-2.4.12.jar:2.4.12]
                  at InitTheme.run(InitTheme.groovy:33) ~[?:?]
          

          And adding import javax.servlet.http.HttpServletRequest does not help either (logical actually)

          Show
          jacques.le.roux Jacques Le Roux added a comment - Hi Nicolas, Unfortunately it does not work because visualThemeId is always null in this case and we have no request. I added println("visualThemeId=========" + visualThemeId) to your patch + import javax.servlet.http.HttpServletRequest; -VisualTheme visualTheme = ThemeFactory.resolveVisualTheme(request) + + String visualThemeId = context.visualThemeId +println( "visualThemeId=========" + visualThemeId) +VisualTheme visualTheme + if (! visualThemeId) visualThemeId = parameters?.visualThemeId +println( "visualThemeId=========" + visualThemeId) + if (visualThemeId) visualTheme = ThemeFactory.getVisualThemeFromId(visualThemeId) + else visualTheme = ThemeFactory.resolveVisualTheme(request?: null ) + if (visualTheme) { ModelTheme modelTheme = visualTheme.getModelTheme() globalContext.commonScreenLocations = modelTheme.getModelCommonScreens() But got the same error 2017-10-03 10:02:09,023 |OFBiz-JobQueue-0 |ServiceDispatcher |T| Sync service [ default /getReturnableItems] finished in [14] milliseconds visualThemeId========= null visualThemeId========= null 2017-10-03 10:02:09,036 |OFBiz-JobQueue-0 |ScriptUtil |W| Error running script at location [component: //common/groovyScripts/InitTheme.groovy]: groovy.lang.MissingPropertyException: No such property: request for class: InitTheme groovy.lang.MissingPropertyException: No such property: request for class: InitTheme at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) ~[groovy-all-2.4.12.jar:2.4.12] at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) ~[groovy-all-2.4.12.jar:2.4.12] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) ~[groovy-all-2.4.12.jar:2.4.12] at InitTheme.run(InitTheme.groovy:33) ~[?:?] And adding import javax.servlet.http.HttpServletRequest does not help either (logical actually)
          Hide
          soledad Nicolas Malin added a comment -

          Ok, the problem came from this line
          visualTheme = ThemeFactory.resolveVisualTheme(request?:null)
          just complete the syntax like this

          visualTheme = ThemeFactory.resolveVisualTheme(context.request?:null)
          

          work fine for me

          I added the visualThemeId resolving from context if the service propage correctly the information

          Show
          soledad Nicolas Malin added a comment - Ok, the problem came from this line visualTheme = ThemeFactory.resolveVisualTheme(request?:null) just complete the syntax like this visualTheme = ThemeFactory.resolveVisualTheme(context.request?: null ) work fine for me I added the visualThemeId resolving from context if the service propage correctly the information
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          Thanks Nicolas,

          It works here also. I previously tried to use the context also, but did not think about using visualThemeId, only tried visualTheme, well done!

          Now I face another issue but it seems unrelated and have opened OFBIZ-9802 for that

          I finally reassign this to you for committing

          Show
          jacques.le.roux Jacques Le Roux added a comment - Thanks Nicolas, It works here also. I previously tried to use the context also, but did not think about using visualThemeId, only tried visualTheme, well done! Now I face another issue but it seems unrelated and have opened OFBIZ-9802 for that I finally reassign this to you for committing
          Hide
          soledad Nicolas Malin added a comment -

          Ok It's now on trunk at 1811042, thanks Jacques

          Show
          soledad Nicolas Malin added a comment - Ok It's now on trunk at 1811042, thanks Jacques

            People

            • Assignee:
              soledad Nicolas Malin
              Reporter:
              jacques.le.roux Jacques Le Roux
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development