maven-3isis

Apache Isis Build Fail specifies unknown repository when use User from ApplicationUser as property of my Entity


I want my Employee has User as bellow

import org.isisaddons.module.security.dom.role.ApplicationRole;
import org.isisaddons.module.security.dom.user.ApplicationUser;
import org.isisaddons.module.security.dom.user.ApplicationUserRepository;

@Column(allowsNull = "true")
@Property(editing = Editing.ENABLED)
@Getter @Setter
private ApplicationUser user;

public List<ApplicationUser> choicesUser() {
    return applicationUserRepository.allUsers();
}

public List<ApplicationRole> getUserRoles() {
    return user!=null? Lists.newArrayList(user.getRoles()):Lists.newArrayList();
}

@Action()
public Employee createUser(
        @ParameterLayout(named = "Username") final String username,
        @ParameterLayout(named = "Password") final Password password,
        @ParameterLayout(named = "Repeat Password") final Password repeatPassword,
        final ApplicationRole initialRole,
        final Boolean enable,
        final String emailAddress) {
    ApplicationUser applicationUser = applicationUserRepository.newLocalUser(username, password, repeatPassword, initialRole, enable, emailAddress);
    this.setUser(applicationUser);
    return this;
}

When I run on IDE it run fine and everything work as expected, but then I run mvn clean install, it errors as bellow, when I remove code above it build just fine. Are there anything else that I have missed?

[INFO] calling @PostConstruct on all domain services
[WARNING] NOT configured
[ERROR]
[ERROR]
[ERROR]
[ERROR] @DomainObject annotation on org.isisaddons.module.security.dom.role.ApplicationRole specifies unknown repository 'org.isisaddons.module.security.dom.role.ApplicationRoleRepository'
[ERROR] @DomainObject annotation on org.isisaddons.module.security.dom.user.ApplicationUser specifies unknown repository 'org.isisaddons.module.security.dom.user.ApplicationUserRepository'
[ERROR]
[ERROR]
[ERROR]
[INFO] calling @PreDestroy on all domain services
[INFO] shutting down org.apache.isis.core.metamodel.specloader.SpecificationLoader@1f041bad
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Incode QuickStart .................................. SUCCESS [  0.279 s]
[INFO] Incode QuickStart Base Module ...................... SUCCESS [  2.480 s]
[INFO] Employment Module .................................. FAILURE [ 11.695 s]
[INFO] Incode QuickStart App Definition ................... SKIPPED
[INFO] Incode QuickStart Webapp ........................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.022 s
[INFO] Finished at: 2017-11-06T11:09:35+07:00
[INFO] Final Memory: 59M/457M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.isis.tool:isis-maven-plugin:1.15.1:validate (default) on project pApp-module-employment: 2 meta-model problems found. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :pApp-module-employment

Please Help, I also remove ! on pom on swagger by follow another question with similar issue, but it doesn't work !!!


Solution

  • The simpleapp archetype is preconfigured to run the "validate" goal of the Apache Isis maven plugin, which checks for semantic errors (eg orphaned supporting methods) in your domain logic. Your stack shows another one of the errors: an entity referencing a non-existing repository.

    The maven plugin runs from an AppManifest - details in the pom.xml of the module-simple module - but this isn't the same AppManifest as is used to bootstrap the application: it is just for a single module.

    Since your Employee entity is referencing ApplicationUser, that is resulting in the ApplicationUser being part of the metamodel, and therefore being validated. My guess is that the AppManifest being used by maven plugin does not reference the Security module (that has the required repositories), and this is triggering the error.

    The fix is just to add the declarations for the security module into this AppManifest. You can probably just copy the relevant lines from the AppManifest that you use to bootstrap the app.

    HTH