Announcement Announcement Module
Collapse
No announcement yet.
No default constructor error on inner bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No default constructor error on inner bean

    Hello

    the following error occurs when initiating a bean with inner beans which contain other inner beans. I have not found any documentation if this is impossible there for it semms strange to me.

    Code:
    No default constructor found; nested exception is java.lang.NoSuchMethodException: de.sf.faps.ui.menu.NavigationMenuItem$MenuRight.<init>()
    The class is:

    Code:
    public class NavigationMenuItem extends NavigationItem implements Serializable {
    
      public NavigationMenuItem() {
        super();
        this.flowId = "";
        this.oncomplete = "";
        this.onsubmit = "";
        this.enabled = true;
      }
      
      public NavigationMenuItem(NavigationMenuItem argOriginal) {
        super(argOriginal);
        this.parentId = argOriginal.getParentId();
        this.flowId = argOriginal.getFlowId();
        this.position = argOriginal.getPosition();
        this.activeDependsOn = argOriginal.getActiveDependsOn();
        this.functionGroup = argOriginal.getFunctionGroup();
        this.oncomplete = argOriginal.getOncomplete();
        this.onsubmit = argOriginal.getOnsubmit();
        this.enabled = argOriginal.isEnabled();
        this.accessRights = argOriginal.getAccessRights();
      }
      
      // followed by setters and getters
      
      public class MenuRight implements Serializable {
      
          private static final long serialVersionUID = 9144699483642271332L;
      
          private String right = null;
          
          private Class<?> type = null;
      
          public MenuRight() {
            super();
          }
      
          public MenuRight(String argRight) {
            this.right = argRight;
          }
      
      
          public String getRigth() {
            return right;
          }
      
          public Class<?> getType() {
            return type;
          }
      
          public void setRigth(String rigth) {
            this.right = rigth;
          }
      
          public void setType(Class<?> argType) {
            this.type = argType;
          }
      }
    }
    As you can see the default constructor is implemented.
    The xml is:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-2.5.xsd">
      <bean id="fapsMenuService" class="de.sf.faps.ui.menu.MenuService" scope="singleton" lazy-init="false" parent="fapsAbstractMenuService">
        <property name="menuItems">
          <list>
            <bean class="de.sf.faps.ui.menu.NavigationMenuItem">
              <property name="id" value="main_delete"/>
              <property name="parentId" value="main_functions"/>
              <property name="label" value="de.sf.faps.function.main.delete"/>
              <property name="action" value="delete_object_confirmation"/>
              <property name="useAjax" value="true"/>
              <property name="reRender" value="showTheModalPanel"/>
              <property name="oncomplete" value="Richfaces.showModalPanel('fapsModalPanel')"/>
              <property name="position" value="150"/>
              <property name="activeDependsOn" value="fapsCurrentFocus" />
              <property name="functionGroup" value="de.sf.faps.function.group.edit"/>
              <property name="styleClass" value="functionDelete"/>
              
              <property name="accessRights">
                <list>
                  <bean class="de.sf.faps.ui.menu.NavigationMenuItem$MenuRight">
                    <property name="right"><value>workspace_delete</value></property>
                    <property name="type"><value>de.sf.faps.workspace.Workspace</value></property>
                  </bean>
                  <bean class="de.sf.faps.ui.menu.NavigationMenuItem$MenuRight">
                    <property name="right"><value>node_delete</value></property>
                    <property name="type"><value>de.sf.faps.node.Node</value></property>
                  </bean>
                  <bean class="de.sf.faps.ui.menu.NavigationMenuItem$MenuRight">
                    <property name="right"><value>item_delete</value></property>
                    <property name="type"><value>de.sf.faps.item.Item</value></property>
                  </bean>
                </list>
              </property>
            </bean>
          </list>
        </property>
      </bean>
    </beans>
    Has anybody an idea wy this hapens or what am i doing wrong?

  • #2
    The inner bean should be a STATIC inner bean, else y ou cannot instantiate an instance outside the enclosing class.

    Comment

    Working...
    X