Skip to Content
1
Former Member
Jan 17, 2018 at 05:37 PM

Problem creating custom constraint in backoffice

278 Views

Dear hybris experts, I have a problem with creating a custom constraint in the backoffice. I have used the steps exactly described in https://help.hybris.com/6.6.0/hcd/8ba7f5a9866910148b749e7217fa45fa.html

but when I try to make a build I am getting a compilation error in GeneratedTypeInitializer.java that

   [yjavac] 1. ERROR in /.../hybris/bin/custom/companynamebackoffice/gensrc/companynamebackoffice/GeneratedTypeInitializer.java (at line 131)
    [yjavac]     de.companyname.pim.backoffice.validation.annotations.AdvantagesNoDuplicates.class,
    [yjavac]     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [yjavac] de.companyname.pim.backoffice.validation.annotations cannot be resolved to a type
    [yjavac] ----------
    [yjavac] 1 problem (1 error)

Here is the itemtype that I have

  <itemtype code="AdvantagesNoDuplicatesConstraint" autocreate="true" generate="true" extends="AttributeConstraint"
                           jaloclass="de.companyname.pim.backoffice.validation.jalo.AdvantagesNoDuplicatesConstraint">
                     <description>Custom constraint to validate that no duplicate advantages are selected for the product</description>
                     <attributes>
                         <attribute qualifier="annotation" type="java.lang.Class" redeclare="true">
                             <modifiers write="false" initial="true" />
                             <defaultvalue>de.companyname.pim.backoffice.validation.annotations.AdvantagesNoDuplicates.class</defaultvalue>
                         </attribute>
                     </attributes>
                 </itemtype>
 

   

And this is the annotation

 @Target({java.lang.annotation.ElementType.FIELD})
 @Retention(RetentionPolicy.RUNTIME)
 @Constraint(
         validatedBy = {AdvantagesNoDuplicatesValidator.class}
 )
 @Documented
 public @interface AdvantagesNoDuplicates {
     String message() default "{de.companyname.pim.backoffice.validation.annotations.AdvantagesNoDuplicates.message}";
 
     Class<?>[] groups() default {};
 
     Class<? extends Payload>[] payload() default {};
 }
 

Have some had such kind of problems as well ?

Thanks and Kind Regards,