Creating security domain using wildfly-maven-plugin has no effect - maven

I found this which uses /subsystem in its command, so I tried it with a different subsystem command (I use one to create a security domain), it builds successfully, but has no effect in standalone.xml.
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.1.0.Alpha1</version>
<configuration>
<execute-commands>
<commands>
<command>/subsystem=security/security-domain=secureD:add(cache-type=default)</command>
<command>reload</command>
<command>/subsystem=security/security-domain=secureD/authentication=classic:add(login-modules=[{"code"=>"Database","flag"=>"required","module-options"=>[("dsJndiName"=>"java:jboss/datasources/MyDB"),("principalsQuery"=>"select password from Users where username=?"),("rolesQuery"=>"select role, 'Roles' from Users where username=?"),("hashAlgorithm"=>"SHA-256"),("hashEncoding"=>"hex"),("hashCharset"=>"UTF-8")]}])</command>
<command>reload</command>
</commands>
</execute-commands>
</configuration>
</plugin>
When I execute the commands manually in $ ./jboss-cli.sh --connect it works and the domain is created.
I use eclipse with the following Run Configurations: "Goals: clean package wildfly:deploy" "Profiles: local"
<project ...
...
<build>
<plugins>
<plugin>
tried pasting code from above once here
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>local</id>
<properties>
...
</properties>
<build>
<plugins>
<plugin>
and once here
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
When building I get these errors:
...
[INFO]
[INFO] --- wildfly-maven-plugin:1.0.1.Final:undeploy (undeploy) # Project ---
Jul 03, 2015 3:50:36 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.0.Final
Jul 03, 2015 3:50:36 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.0.Final
Jul 03, 2015 3:50:36 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.0.Final
WARN: can't find jboss-cli.xml. Using default configuration values.
Jul 03, 2015 3:50:36 PM org.jboss.as.cli.impl.CommandContextImpl printLine
INFO: {"outcome" => "success"}
{"outcome" => "success"}
Jul 03, 2015 3:50:36 PM org.jboss.as.cli.impl.CommandContextImpl printLine
INFO: {
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.316 s
[INFO] Finished at: 2015-07-03T15:50:36+01:00
[INFO] Final Memory: 12M/165M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.1.Final:undeploy (undeploy) on project Project: Could not execute goal undeploy on /home/username/workspace/Project/target/Project-0.0.1-SNAPSHOT.war. Reason: Command execution failed for command 'reload'. Unsupported ModelControllerClient implementation org.wildfly.plugin.cli.Commands$NonClosingModelControllerClient -> [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/MojoExecutionException
If I remove the reload command I get:
...
WARN: can't find jboss-cli.xml. Using default configuration values.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.825 s
[INFO] Finished at: 2015-07-03T15:45:23+01:00
[INFO] Final Memory: 22M/214M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.1.Final:deploy-artifact (deploy_jdbc_driver) on project Project: Could not execute goal deploy-artifact on /home/username/.m2/repository/mysql/mysql-connector-java/5.1.35/mysql-connector-java-5.1.35.jar. Reason: Command execution failed for command '/subsystem=security/security-domain=secureD:add(cache-type=default)'. {
[ERROR] "outcome" => "failed",
[ERROR] "failure-description" => "JBAS014803: Duplicate resource [
[ERROR] (\"subsystem\" => \"security\"),
[ERROR] (\"security-domain\" => \"secureD\")
[ERROR] ]",
[ERROR] "rolled-back" => true,
[ERROR] "response-headers" => {"process-state" => "reload-required"}
[ERROR] }
[ERROR] -> [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/MojoExecutionException

You need to either add the wildfly:execute-commands goal or change your configuration to use the <before-deployment/>. The latter is probably a better solution as you'd have to use executions to ensure the commands are executed before your deployment. I'd also only use a reload at the end.
<configuration>
<before-deployment>
<commands>
<command>/subsystem=security/security-domain=secureD:add(cache-type=default)</command>
<command>/subsystem=security/security-domain=secureD/authentication=classic:add(login-modules=[{"code"=>"Database","flag"=>"required","module-options"=>[("dsJndiName"=>"java:jboss/datasources/MyDB"),("principalsQuery"=>"select password from Users where username=?"),("rolesQuery"=>"select role, 'Roles' from Users where username=?"),("hashAlgorithm"=>"SHA-256"),("hashEncoding"=>"hex"),("hashCharset"=>"UTF-8")]}])</command>
<command>reload</command>
</commands>
</before-deployment>
</configuration>

Related

Build Failure during deploying maven project to heroku

I am trying to deploy maven project to heroku but it is showing error.
[INFO] Webapp assembled in [765 msecs]
[INFO] Building war:
C:\Users\Lenovo\Documents\GitHub\MakeMyEvent\target\MakeMyEvent-0.0.1-SNAPSHOT.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.406 s
[INFO] Finished at: 2018-08-23T16:16:19+05:30
[INFO] Final Memory: 16M/90M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-
plugin:2.2:war (default-war) on project MakeMyEvent: Error assembling WAR:
webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [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/MojoExecutionException
it is a jsp project and working fine on my local machine.
As per the information you have provided here, your war building triggers the error.
basically if you are using maven war plugin try considering adding <failOnMissingWebXml>false</failOnMissingWebXml>
Example :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

Error Maven with mvn test

I am using this tool for first time, and I can't build a project correctly.
when i try the life cycle commands it builds succesfully with clean validate and compile. but when i try mvn test, it gives me this error :
[INFO] ---------------------------------------------------------------------
---
[INFO] BUILD FAILURE
[INFO] ---------------------------------------------------------------------
---
[INFO] Total time: 4.410 s
[INFO] Finished at: 2018-05-25T11:33:07+02:00
[INFO] ---------------------------------------------------------------------
---
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-
plugin:2.20.1:test (default-test) on project gdp: Execution default-test of
goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test failed.
:NullPointerException
-> [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/PluginExecutionException
mvn -v 3.5.3
i am using a proxy and i did configure settings.xml file
Please help.
thank you
Change the version of maven-surefire-plugin via:
<project>
.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

Building SonarQube with maven and batch_boostrap/index cannot be found

I'm running mvn sonar:sonar in the directory of the project I'm running. I already have my pom.xml updated:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.7.1</version>
</plugin>
After running sudo mvn sonar:sonar (I am on ubuntu 14.04) in my terminal, I get the following error:
eschwartz#LATITUDE:~/ideaprojects/xQueryEngine$ sudo mvn sonar:sonar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xQueryEngine (Solr 4 REX) 1.11.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:2.7.1:sonar (default-cli) # xqe ---
[INFO] User cache: /root/.sonar/cache
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.854s
[INFO] Finished at: Wed Feb 17 15:56:59 EST 2016
[INFO] Final Memory: 17M/302M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar (default-cli) on project xqe: Fail to download libraries from server: Status returned by url : 'http://localhost:9000/batch_bootstrap/index' is invalid : 404 -> [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/MojoExecutionException
Anyone know how to fix this?
Thanks.
You have to set sonar.host.url=http://localhost:9000/sonar. You can do this by passing -Dsonar.host.url=... to mvn, or ideally set it in your Maven Global/Project Settings so that you don't always have to pass it as a command line argument.
Details: if your dashboard is at localhost:9000/sonar then it means you're using sonar.web.context=/sonar , which is different from the default (/). So you need to tell the scanner where to find SonarQube.

Wildfly command line deploy failure

I am able to run most of these tutorials in Eclipse provided in the Wildfly quickstart here:
https://github.com/wildfly/quickstart/
However, I am running into problem when I use command line to do the deployment. For the most basic HelloWorld tutorial, I received this message:
mvn clean install
is successful. However, the deployment fails:
mvn clean install wildfly:deploy
Error messages:
ackaging webapp
[INFO] Assembling webapp [wildfly-helloworld] in [/home/abigail/study/quickstart/helloworld/target/wildfly-helloworld]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/abigail/study/quickstart/helloworld/src/main/webapp]
[INFO] Webapp assembled in [2 msecs]
[INFO] Building war: /home/abigail/study/quickstart/helloworld/target/wildfly-helloworld.war
[INFO]
[INFO] <<< wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) < package # wildfly-helloworld <<<
[INFO]
[INFO] --- wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) # wildfly-helloworld ---
Dec 19, 2015 11:42:10 PM org.xnio.Xnio
INFO: XNIO version 3.2.2.Final
Dec 19, 2015 11:42:10 PM org.xnio.nio.NioXnio
INFO: XNIO NIO Implementation Version 3.2.2.Final
Dec 19, 2015 11:42:10 PM org.jboss.remoting3.EndpointImpl
INFO: JBoss Remoting version 4.0.3.Final
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.836 s
[INFO] Finished at: 2015-12-19T23:42:15-05:00
[INFO] Final Memory: 21M/162M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) on project wildfly-helloworld: Could not execute goal deploy on /home/abigail/study/quickstart/helloworld/target/wildfly-helloworld.war. Reason: I/O Error could not execute operation '{
[ERROR] "operation" => "read-attribute",
[ERROR] "address" => [],
[ERROR] "name" => "launch-type"
[ERROR] }': java.net.ConnectException: JBAS012144: Could not connect to http-remoting://127.0.0.1:9990. The connection timed out
[ERROR] -> [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/MojoExecutionException
You have to check if you created a user for the deployment.See this article where it is further explained .
I had same problem when the other application is usind default 9990 port.
I moved wildfly to the port 9991 (modifying standalone.xml and host.xml), admin console started to work, but deploy still was failed.
Then I figured out that wildfly plugin uses same 9990 by default.
I handled this by modiying pom.xml of my progect, put the other port (the same I was using in standalone) to the configuration of wildfly plugin.
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
<configuration>
<port>9991</port>
</configuration>
</plugin>

How to run a snapshot plugin

When I attempt to run below maven plugin using this command :
com.wordpress.pomfromjarmavenplugin:generate:0.0.1-SNAPSHOT:generatepom
I get this error :
Downloading:
https://oss.sonatype.org/content/repositories/snapshots/com/wordpress/pomfromjarmavenplugin/generate/0.0.1-SNAPSHOT/generate-0.0.1-SNAPSHOT.pom
[WARNING] The POM for
com.wordpress.pomfromjarmavenplugin:generate:jar:0.0.1-SNAPSHOT is
missing, no dependency information available [INFO]
------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 1.862s [INFO] Finished at: Fri Nov 09 11:15:47 GMT
2012 [INFO] Final Memory: 5M/15M [INFO]
------------------------------------------------------------------------ [ERROR] Plugin
com.wordpress.pomfromjarmavenplugin:generate:0.0.1-SNAPSHOT or one of
its dependencies could not be resolved: Failed to read artifact
descriptor for
com.wordpress.pomfromjarmavenplugin:generate:jar:0.0.1-SNAPSHOT: Could
not find artifact
com.wordpress.pomfromjarmavenplugin:generate:pom:0.0.1-SNAPSHOT in
apache.snapshots
(https://oss.sonatype.org/content/repositories/snapshots/) -> [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/PluginResolutionException
Problem seems to be that all of the pom files have timestamps associated with them :
https://oss.sonatype.org/content/repositories/snapshots/com/wordpress/pomfromjarmavenplugin/generate/0.0.1-SNAPSHOT/
How can I run this plugin ? Do I need to wait until the plugin is released or somehow instruct maven to run the latest version of the snapshot ?
Add these lines to your pom:
<pluginRepositories>
<pluginRepository>
<id>oss.sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
Then your command should work:
mvn com.wordpress.pomfromjarmavenplugin:generate:0.0.1-SNAPSHOT:generatepom
Or add these lines to your pom:
<build>
<plugins>
<plugin>
<groupId>com.wordpress.pomfromjarmavenplugin</groupId>
<artifactId>generate</artifactId>
<version>0.0.1-SNAPSHOT</version>
</plugin>
</plugins>
</build>
And then issue:
mvn generate:generatepom

Resources