jbossas / jboss-as-maven-plugin

Maven plugin to deploy applications to JBoss AS 7 (moved to https://github.com/wildfly/wildfly-maven-plugin)
74 stars 69 forks source link

xa-resource in 7.4.Final doesn't work #45

Closed AndriyKalashnykov closed 10 years ago

AndriyKalashnykov commented 11 years ago

xa-datasource creation fails when following configuration used, also no working example in plugin documentation available (https://docs.jboss.org/jbossas/7/plugins/maven/latest/)

<configuration> <address>subsystem=datasources</address> <resources> <resource> <address>xa-data-source=java:jboss/datasources/postgresDS</address> <enable-resource>true</enable-resource> <properties> </properties> <resources> <resource> <address>xa-datasource-properties=DatabaseName</address> <properties> <value>dbname</value> </properties> </resource> <resource> <address>xa-datasource-properties=ServerName</address> <properties> <value>localhost</value> </properties> </resource> <resource> <address>xa-datasource-properties=User</address> <properties> <value>user</value> </properties> </resource> <resource> <address>xa-datasource-properties=Password</address> <properties> <value>password</value> </properties> </resource> </resources> </resource> </resources> </configuration>

AndriyKalashnykov commented 11 years ago

To be little more specific, mentiond below fails... Environment: (Windows 7 x64bit, Maven 3.0.5, Java 1.7, JBoss 7.1.1.Final)

                <execution>
                    <id>add-datasource-xa</id>
                    <phase>install</phase>
                    <goals>
                        <goal>add-resource</goal>
                    </goals>
                    <configuration>
                        <address>subsystem=datasources</address>
                         <resources>
                            <resource>
                                <address>xa-data-source=java:jboss/datasources/ds-xa</address>
                                <enable-resource>true</enable-resource>
                                <properties>
                                    <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                                    <jndi-name>java:jboss/datasources/ds-xa</jndi-name>
                                    <enabled>true</enabled>
                                    <pool-name>ds-xa</pool-name>
                                    <driver-name>ojdbc6-${oracle.connector.java.version}.jar</driver-name>
                                </properties>
                            </resource>
                            <resource>
                                <address>xa-data-source=java:jboss/datasources/ds-xa,xa-datasource-properties=DatabaseName</address>
                                <properties>
                                    <value>oradev01</value>
                                </properties>
                            </resource>
                            <resource>
                                <address>xa-data-source=java:jboss/datasources/ds-xa,xa-datasource-properties=ServerName</address>
                                <properties>
                                    <value>localhost:30003</value>
                                </properties>
                            </resource>
                            <resource>
                                <address>xa-data-source=java:jboss/datasources/ds-xa,xa-datasource-properties=User</address>
                                <properties>
                                    <value>${db.user}</value>
                                </properties>
                            </resource>
                            <resource>
                                <address>xa-data-source=java:jboss/datasources/ds-xa,xa-datasource-properties=Password</address>
                                <properties>
                                    <value>${db.password}</value>
                                </properties>
                            </resource>
                        </resources>
                    </configuration>
                </execution>

With following error:

[INFO] --- jboss-as-maven-plugin:7.4.Final:add-resource (add-datasource-xa) @ xa-deploy --- [DEBUG] Configuring mojo org.jboss.as.plugins:jboss-as-maven-plugin:7.4.Final:add-resource from plugin realm ClassRealm[plugin>org.jboss.as.plugins:jboss-as-maven-plugin:7.4.Final, parent: s un.misc.Launcher$AppClassLoader@2b1cccce] [DEBUG] Configuring mojo 'org.jboss.as.plugins:jboss-as-maven-plugin:7.4.Final:add-resource' with basic configurator --> DEBUG address = subsystem=datasources DEBUG force = true DEBUG hostname = 127.0.0.1 DEBUG port = 9999 DEBUG address = xa-data-source=java:jboss/datasources/ds-xa DEBUG enableResource = true DEBUG properties = {driver-name=ojdbc6-11.2.0.3.jar, enabled=true, jndi-name=java:jboss/datasources/ds-xa, pool-name=ds-xa, xa-datasource-class=org.postgresql.xa.PGXADataSource} DEBUG address = xa-data-source=java:jboss/datasources/ds-xa,xa-datasource-properties=DatabaseName DEBUG properties = {value=oradev01} DEBUG address = xa-data-source=java:jboss/datasources/ds-xa,xa-datasource-properties=ServerName DEBUG properties = {value=localhost:30003} DEBUG address = xa-data-source=java:jboss/datasources/ds-xa,xa-datasource-properties=User DEBUG properties = {value=db_user} DEBUG address = xa-data-source=java:jboss/datasources/ds-xa,xa-datasource-properties=Password DEBUG properties = {value=db_password} DEBUG resources = [org.jboss.as.plugin.deployment.resource.Resource@6467f9ec, org.jboss.as.plugin.deployment.resource.Resource@66492873, org.jboss.as.plugin.deployment.resource.Resou rce@4cfeca7b, org.jboss.as.plugin.deployment.resource.Resource@6b9f78ba, org.jboss.as.plugin.deployment.resource.Resource@32af3289] DEBUG settings = org.apache.maven.execution.SettingsAdapter@19fef64 [DEBUG] -- end configuration -- [INFO] Executing goal add-resource on server 127.0.0.1 (127.0.0.1) port 9999. [DEBUG] No element was found in the POM - Getting credentials from CLI entry [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 12.416s [INFO] Finished at: Mon Apr 22 18:34:22 EDT 2013 [INFO] Final Memory: 15M/244M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.4.Final:add-resource (add-datasource-xa) on project xa-deploy: Could not execute goal add-resource. Reason: Operat ion failed: {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => "JBAS010469: At least one xa-datasource-property is required for an xa -datasource"}} -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.4.Final:add-resource (add-datasource-xa) on project xa-deploy: Cou ld not execute goal add-resource. Reason: Operation failed: {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => "JBAS010469: At least one xa-datasource-property is required for an xa-datasource"}} at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.MojoExecutionException: Could not execute goal add-resource. Reason: Operation failed: {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => "JBAS010469: At least one xa-datasource-property is required for an xa-datasource"}} at org.jboss.as.plugin.deployment.resource.AddResource.execute(AddResource.java:136) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: java.lang.RuntimeException: Operation failed: {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => "JBAS010469: At least one xa-datasource-property is required for an xa-datasource"}} at org.jboss.as.plugin.deployment.resource.AddResource.reportFailure(AddResource.java:326) at org.jboss.as.plugin.deployment.resource.AddResource.processResources(AddResource.java:171) at org.jboss.as.plugin.deployment.resource.AddResource.execute(AddResource.java:129) ... 21 more [ERROR] [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/MojoExecutionException

jamezp commented 10 years ago

The issue is here, https://github.com/jbossas/jboss-as-maven-plugin/blob/master/src/main/java/org/jboss/as/plugin/deployment/resource/AddResource.java#L289. The result should first be checked if it's defined, then try to get it as a list. The asList() cannot be defined on an undefined ModelNode.

eis commented 10 years ago

In addition to the code issue, example in the documentation seems to be wrong. My PR should fix both.

jamezp commented 10 years ago

Fixed in PR #67