简体   繁体   中英

Configure Wildfly Naming subsytem on deploy with Maven plugin wildfly-maven-plugin

I would like to add a resource to the naming subsystem so that I can pull it into my EJB through the @Resource annotation. Ideally the resource must be added at build time for that specific environment, (once I get this working, I will set variables in maven that are set in the settings.xml). I am currently using the wildfly-maven-plugin , but cannot find a place to add JNDI references to String resources anywhere. It generally fails when I run mvn wildfly:deploy with:

[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Alpha5:add-resource (add_jndi) on project Project: Could not execute goal add-resource. Reason: Operation failed: "JBAS014807: Management resource '[
[ERROR] (\"subsystem\" => \"naming\"),
[ERROR] (\"binding\" => \"java:global/Project/key\")
[ERROR] ]' not found"
[ERROR] -> [Help 1]

My pom.xml looks as follows:

...
<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>${wildfly-maven-plugin.version}</version>
    <inherited>false</inherited>
    <configuration>
        <skip>false</skip>
    </configuration>
    <executions>
        <execution>
            <id>add_jndi</id>
            <phase>package</phase>
            <goals>
                <goal>add-resource</goal>
            </goals>
            <configuration>
                <address>subsystem=naming,binding=java:global/Project/key,binding-type=simple</address>
                <resources>
                    <resource>
                        <properties>
                            <name>key</name>
                            <type>java.lang.String</type>
                            <value>value</value>
                        </properties>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>
...

This is possible and documented to work with the CLI for wildfly

I am currently using Wildfly 8.2, Java JDK 8 and Maven 3.

A Execute Commands can be configured to run a CLI command. executeCommands tag can be configured inside plugin configuration. Please visit this link for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM