cancel
Showing results for 
Search instead for 
Did you mean: 

Backoffice Action ClassNotFoundException

eric_rosfelder
Explorer
0 Kudos
557

Hello experts,

I'm currently trying to add a backoffice custom action (for Category) into my project and I've been following the action documentation (Creating an action & Using Actions in Widgets). I have a definition.xml file in the ressources folder, and my actionClass in the backoffice/src folder.

I've go no error on compilation, the server starts and run properly, but when i land on a Category i got a ClassNotFoundException ( The full Stacktrace at the end of the question). I've tried to move in different folders/changing the package of the action and so on.

Could you help me pointing what i missed or what i'm doing wrong ?

The Hybris Version 6.4

Files are as follow:

backofficeextension/resources/cockpitng/widgets/actions/clearproducts/definition.xml

 <?xml version="1.0" encoding="UTF-8"?>
 
 
 
 
 <action-definition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    id="com.company.backoffice.widgets.actions.clearproducts"
                    xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/action-definition.xsd">
 
     <name>ClearProducts</name>
     <description>Clear products link to selected Category</description>
     <author>MCO</author>
     <version>1.0</version>
 
     <iconUri>icons/icon_action_sync_default.png</iconUri>
     <iconHoverUri>icons/icon_action_sync_hover.png</iconHoverUri>
     <iconDisabledUri>icons/icon_action_sync_disabled.png</iconDisabledUri>
     <actionClassName>com.company.backoffice.widgets.ClearProductsAction</actionClassName>
 </action-definition>


backofficeextension/backoffice/src/com/company/backoffice/widgets/ClearProductsAction.java

 package com.company.backoffice.widgets;
 
 import com.hybris.cockpitng.actions.ActionContext;
 import com.hybris.cockpitng.actions.ActionResult;
 import com.hybris.cockpitng.actions.CockpitAction;
 
 
 /**
  * Created by mco on 21/11/17.
  */
 public class ClearProductsAction implements CockpitAction<String, String>
 {
     /**
      * invoked when an action is executed
      * @param ctx
      * @return
      */
     @Override
     public ActionResult<String> perform(ActionContext<String> ctx)
     {
         ActionResult<String> result = null;
         final String data = ctx.getData();
         if (data != null)
         {
             result = new ActionResult<String>(ActionResult.SUCCESS, ctx.getLabel("message", new Object[] { data }));
         }
         else
         {
             result = new ActionResult<String>(ActionResult.ERROR);
         }
 //        Messagebox.show(result.getData() + " (" + result.getResultCode() + ")");
 
         return result;
     }
 
     /**
      * Determines the state in which the action will be rendered
      * @param ctx
      * @return
      */
     @Override
     public boolean canPerform(ActionContext<String> ctx)
     {
         return true;
     }
 
     @Override
     public boolean needsConfirmation(ActionContext<String> ctx)
     {
         return true;
     }
 
     @Override
     public String getConfirmationMessage(ActionContext<String> ctx)
     {
         return "confirm please";
     }
 }
 

backofficeextension-backoffice-config.xml

     <context type="Category" component="editorareaactions"
              parent="GenericItem" xmlns:y="http://www.hybris.com/cockpit/config/hybris">
         <y:actions>
             <y:group qualifier="common">
                 <y:label>actiongroup.common</y:label>
                 <y:action action-id="com.company.backoffice.widgets.actions.clearproducts" property="currentObject">
                 </y:action>
             </y:group>
         </y:actions>
     </context>

The full stacktrace

Accepted Solutions (1)

Accepted Solutions (1)

former_member632755
Active Contributor
0 Kudos

Hi,

the error is in where you located the definition.xml:

is: backofficeextension/resources/cockpitng/widgets/actions/clearproducts/definition.xml should be: backofficeextension/backoffice/resources/widgets/actions/clearproducts/definition.xml

Cheers, Wojtek

Former Member
0 Kudos

I think, there's a tiny typo here. Instead of ressources there should be resources with single s.

former_member632755
Active Contributor
0 Kudos

Thx, fixed :)

eric_rosfelder
Explorer
0 Kudos

Hi Wojtek,

Thanks a lot for your reply, i confirm this was the problem, now everything works fine !

Former Member
0 Kudos

Hello Wojciech,

That fixed my problem too when creating my customized sync action but I have another problem, it's about getting another "Synchronize Action" appended to the list view bar on the Backoffice while all I need is one sync action using the implementation of my customized sync action class. Do you have any idea?

Thanks

Answers (2)

Answers (2)

former_member625836
Active Contributor
0 Kudos

Hi ,

I do it on daily basis and all works just fine. As you have obfuscated the code, it may be that you have some simple spelling mistake there. Please check it carefully - all looks fine in what you attached.

Cheers, Jacek

eric_rosfelder
Explorer
0 Kudos

I also tried to add some properties like the "keywords" one to try to be the closer possible from some other action-definitions but without great success