4 Replies Latest reply on Oct 13, 2017 8:29 AM by gastaldi

    Errors forge generated CRUD when add a child (user), to a parent (role)

    cristian.pavalasc

      Errors forge generated CRUD when add a child (user), to a parent (role):

        1. SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-16) Error Rendering View[/role/create.xhtml]: java.lang.NullPointerException

        2. Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

      Steps:

      Environment/Configuration:

        JBoss Developper Tool Red Hat JBoss Developer Studio / Version: 10.0.0.GA

        Server: JBoss 10.0.0 WildFly

        Forge version: 3.2.2 Final embeded

        CDI 1.2

        JSF 2.2

      Two table, related one to many:

      CREATE TABLE role (

        role_id bigint(20) NOT NULL AUTO_INCREMENT,

        name varchar(255) DEFAULT NULL,

        description varchar(255) DEFAULT NULL,

        createdOn TIMESTAMP DEFAULT NOW(),

        createdBy varchar(255) DEFAULT NULL,

        lastUpdatedOn datetime DEFAULT NULL,

        lastUpdatedBy varchar(255) DEFAULT NULL,

        UNIQUE (name),

        PRIMARY KEY (role_id),

        UNIQUE KEY role_id (role_id)

      ) ENGINE=Innodb AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;

      CREATE TABLE user (

        user_id bigint(20) NOT NULL AUTO_INCREMENT,

        users_role_id bigint(20) NOT NULL ,

        fullname varchar(255) DEFAULT NULL,

        password varchar(255) DEFAULT NULL,

        email varchar(255) DEFAULT NULL,

        username varchar(255) DEFAULT NULL,

        createdOn TIMESTAMP DEFAULT NOW(),

        createdBy varchar(255) DEFAULT NULL,

        expireOn datetime DEFAULT NULL,

        lastUpdatedOn datetime DEFAULT NULL,

        lastUpdatedBy varchar(255) DEFAULT NULL,

        lastAccesOn datetime DEFAULT NULL,

        active bit(1) NOT NULL DEFAULT b'1',

        UNIQUE (username),

        PRIMARY KEY (user_id),

        UNIQUE KEY user_id (user_id),

        CONSTRAINT users_role_fk2 FOREIGN KEY (users_role_id) REFERENCES role (role_id)

      ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;

       

      The next forge commands were executed:

      1. project-new --top-level-package ro.procont.usersrole --named usersRole --stack JAVA_EE_7 --type war

      2. jpa-setup --data-source-name usersRole --db-type MYSQL

      3. jpa-generate-entities-from-tables --jdbc-url jdbc:mysql://localhost/user_role --user-name root --user-password password --driver-location /Volumes/datas/Applications/dev/jbossdevstudio10.0.0/runtimes/wildfly-10.0.0.Final/modules/system/layers/base/com/mysql/main/mysql-connector-java-5.1.33-bin.jar --hibernate-dialect org.hibernate.dialect.MySQL5InnoDBDialect --driver-class com.mysql.jdbc.Driver --database-tables *;

      4. scaffold-generate --targets ro.procont.usersrole.model.* --web-root / --provider Faces;

      Full stack below:

      12:19:54,483 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-16) Error Rendering View[/role/create.xhtml]: java.lang.NullPointerException

        at java.net.URLEncoder.encode(URLEncoder.java:204)

        at com.sun.faces.context.UrlBuilder.addValuesToParameter(UrlBuilder.java:318)

        at com.sun.faces.context.UrlBuilder.addParameters(UrlBuilder.java:127)

        at com.sun.faces.context.ExternalContextImpl.encodeBookmarkableURL(ExternalContextImpl.java:1059)

        at com.sun.faces.application.view.MultiViewHandler.getBookmarkableURL(MultiViewHandler.java:408)

        at javax.faces.application.ViewHandlerWrapper.getBookmarkableURL(ViewHandlerWrapper.java:272)

        at org.jboss.weld.jsf.ConversationAwareViewHandler.getBookmarkableURL(ConversationAwareViewHandler.java:132)

        at javax.faces.application.ViewHandlerWrapper.getBookmarkableURL(ViewHandlerWrapper.java:272)

        at com.sun.faces.renderkit.html_basic.OutcomeTargetRenderer.getEncodedTargetURL(OutcomeTargetRenderer.java:194)

        at com.sun.faces.renderkit.html_basic.OutcomeTargetLinkRenderer.renderAsActive(OutcomeTargetLinkRenderer.java:158)

        at com.sun.faces.renderkit.html_basic.OutcomeTargetLinkRenderer.encodeBegin(OutcomeTargetLinkRenderer.java:96)

        at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:865)

        at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)

        at com.sun.faces.renderkit.html_basic.TableRenderer.renderRow(TableRenderer.java:385)

        at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:161)

        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)

        at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)

        at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:114)

        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)

        at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)

        at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)

        at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)

        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)

        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)

        at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)

        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)

        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)

        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)

        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)

        at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)

        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)

        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)

        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)

        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)

        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)

        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)

        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

        at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)

        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)

        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)

        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)

        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)

        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)

        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)

        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)

        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

        at java.lang.Thread.run(Thread.java:745)

       

       

      12:19:54,496 ERROR [io.undertow.request] (default task-16) UT005023: Exception handling request to /usersRole/faces/role/create.xhtml: javax.servlet.ServletException

        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)

        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

        at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)

        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)

        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)

        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)

        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)

        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)

        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)

        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)

        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

        at java.lang.Thread.run(Thread.java:745)

      Caused by: java.lang.NullPointerException

        at java.net.URLEncoder.encode(URLEncoder.java:204)

        at com.sun.faces.context.UrlBuilder.addValuesToParameter(UrlBuilder.java:318)

        at com.sun.faces.context.UrlBuilder.addParameters(UrlBuilder.java:127)

        at com.sun.faces.context.ExternalContextImpl.encodeBookmarkableURL(ExternalContextImpl.java:1059)

        at com.sun.faces.application.view.MultiViewHandler.getBookmarkableURL(MultiViewHandler.java:408)

        at javax.faces.application.ViewHandlerWrapper.getBookmarkableURL(ViewHandlerWrapper.java:272)

        at org.jboss.weld.jsf.ConversationAwareViewHandler.getBookmarkableURL(ConversationAwareViewHandler.java:132)

        at javax.faces.application.ViewHandlerWrapper.getBookmarkableURL(ViewHandlerWrapper.java:272)

        at com.sun.faces.renderkit.html_basic.OutcomeTargetRenderer.getEncodedTargetURL(OutcomeTargetRenderer.java:194)

        at com.sun.faces.renderkit.html_basic.OutcomeTargetLinkRenderer.renderAsActive(OutcomeTargetLinkRenderer.java:158)

        at com.sun.faces.renderkit.html_basic.OutcomeTargetLinkRenderer.encodeBegin(OutcomeTargetLinkRenderer.java:96)

        at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:865)

        at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)

        at com.sun.faces.renderkit.html_basic.TableRenderer.renderRow(TableRenderer.java:385)

        at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:161)

        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)

        at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)

        at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:114)

        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)

        at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)

        at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)

        at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)

        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)

        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)

        at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)

        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)

        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)

        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)

        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)

        at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)

        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)

        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)

        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)

        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)

        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)

        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)

        ... 27 more

       

       

      12:19:54,511 ERROR [io.undertow.request] (default task-16) UT005022: Exception generating error page /faces/error.xhtml: javax.servlet.ServletException: Index: 0, Size: 0

        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)

        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:265)

        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:200)

        at io.undertow.servlet.spec.RequestDispatcherImpl.error(RequestDispatcherImpl.java:453)

        at io.undertow.servlet.spec.RequestDispatcherImpl.error(RequestDispatcherImpl.java:386)

        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:311)

        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)

        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)

        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)

        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

        at java.lang.Thread.run(Thread.java:745)

      Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

        at java.util.ArrayList.rangeCheck(ArrayList.java:653)

        at java.util.ArrayList.get(ArrayList.java:429)

        at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:166)

        at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1612)

        at com.sun.faces.application.view.FaceletPartialStateManagementStrategy$2.visit(FaceletPartialStateManagementStrategy.java:379)

        at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)

        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689)

        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)

        at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.restoreView(FaceletPartialStateManagementStrategy.java:366)

        at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:138)

        at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)

        at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:591)

        at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:151)

        at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:353)

        at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:353)

        at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:199)

        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:123)

        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)

        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)

        ... 19 more

      The errors occured when I tried to add new user to an existing role.

      I guess id of the new created user is null (and is normal to be null) and is used in the page (jsf) but no other ideas.

      Any clues?

      Thanks,

      Cristian.