1 Reply Latest reply on Jun 3, 2016 6:06 AM by csbased

    persistence unit service failed to start

    csbased

      runtime: wildfly 10

      issue: I'm trying to keep the server configuration in my project so I can install the web app on a freshly downloaded wildfly without too much configuration (so other people don't have an hard time configuring it when trying out. To do so I use maven wildfly plugin. The deployment fails with the stack trace:


          22:06:01,722 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.persistenceunit."walbang-0.0.1-SNAPSHOT.war#my-pu".__FIRST_PHASE__: org.jboss.msc.service.StartException in service jboss.persistenceunit."walbang-0.0.1-    SNAPSHOT.war#my-pu".__FIRST_PHASE__: Failed to start service

            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)

           (...)

          Caused by: java.lang.NullPointerException

            at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler$ManagedReferenceFactoryInjector.uninject(PersistenceUnitServiceHandler.java:1088)

          (...)

           22:06:01,731 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "walbang-0.0.1-SNAPSHOT.war")]) - failure description: {

               "WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"walbang-0.0.1-SNAPSHOT.war#my-pu\".__FIRST_PHASE__" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"walbang-0.0.1-SNAPSHOT.war#my-pu\".__FIRST_PHASE__: Failed to start service

               Caused by: java.lang.NullPointerException"},

               "WFLYCTL0180: Services with missing/unavailable dependencies" => [

                   "jboss.deployment.unit.\"walbang-0.0.1-SNAPSHOT.war\".component.VoteDiscussionServiceImpl.CREATE is missing [jboss.security.security-domain.walbangSecureRealm]",

                   "jboss.deployment.unit.\"walbang-0.0.1-SNAPSHOT.war\".component.UserServiceImp.CREATE is missing [jboss.security.security-domain.walbangSecureRealm]"(...)

       

      Here is my config in maven (in bold what I think may be the root causes) :

       

      <plugin>
        <groupId>org.wildfly.plugins</groupId>
        <artifactId>wildfly-maven-plugin</artifactId>
        <version>1.0.2.Final</version>
        <executions>
              <!-- Deploy the JDBC driver -->
              <execution>
            <id>deploy-driver</id>
            <phase>install</phase>
            <configuration>
                  <groupId>mysql</groupId>
                  <artifactId>mysql-connector-java</artifactId>
                  <name>mysql-connector.jar</name>
            </configuration>
            <goals>
                  <goal>deploy-artifact</goal>
            </goals>
        </execution>
        <!-- Add a data source -->
        <execution>
            <id>add-datasource</id>
            <phase>install</phase>
            <configuration>
           <address>subsystem=datasources,data-source=myDatasource</address>
            <resources>
                  <resource>
                      <enableResource>true</enableResource>
                      <properties>
                            <connection-url>jdbc:mysql://localhost:3306/forumcs</connection-url>
                            <jndi-name>java:/forumcsDS</jndi-name>
                            <enabled>true</enabled>
                            <enable>true</enable>
                            <user-name>root</user-name>
                            <password>123456</password>
                            <driver-name>mysql-connector.jar</driver-name>
                            <use-ccm>false</use-ccm>
                      </properties>
                  </resource>
            </resources>
            </configuration>
            <goals>
                  <goal>add-resource</goal>
            </goals>
            </execution>
              <!-- Deploy the application on install -->
              <execution>
                  <id>deploy</id>
                  <phase>install</phase>
                  <goals>
                      <goal>deploy</goal>
                  </goals>
            </execution>
        </executions>


        <configuration>
              <!--add security domain-->
             <execute-commands>
                  <commands>
                  <command>/subsystem=security/security-domain=walbangSecureRealm:add(cache-type=default)</command>
                  <command>/subsystem=security/security-domain=walbangSecureRealm/authentication=classic:add(login-modules=[{"code"=>"Database","flag"=>"required","module-options"=>[("dsJndiName"=>"java:/forumcsDS"),("principalsQuery"=>"select password from usercredential uc where uc.username = ?"),("rolesQuery"=>"select role, 'Roles' from users u where u.username = ?"),("unauthenticatedIdentity"=>"guest")]}])</command>
                  <command>reload</command>
            </commands>
            </execute-commands>
        </configuration>
      </plugin>


      and my persistence.xml is simple :


      <persistence-unit name="my-pu" transaction-type="JTA">
        <jta-data-source>java:/forumcsDS</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <shared-cache-mode>DISABLE_SELECTIVE</shared-cache-mode>
        <properties>
        <property name="javax.persistence.schema-generation.database.action" value="create"/>
        </properties>
      </persistence-unit>