Brand new to netbeans and working on the address-book tutorial. I am able to run the program without issues but when I build I get the following error. I have yet to find any possible solutions to the issue
Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.4:redeploy (deploy) on project address-book: Execution deploy of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.4:redeploy failed: Failed to create deployer with implementation class org.codehaus.cargo.container.glassfish.GlassFish4xInstalledLocalDeployer for the parameters (container [id = [glassfish4x]], deployer type [installed]). InvocationTargetException: The container configuration directory "c://glassfish4/glassfish/domains" does not exist. Please configure the container before attempting to perform any local deployment. Read more on: http://cargo.codehaus.org/Local+Configuration -> [Help 1]
How does Maven know which server to deploy to and where is it located?
It's all in the pom.xml file.
Sometimes you will have to trace up the parents of the pom.xml to find it.
In the case of Java EE tutorial, when I was building project hello1, Maven couldn't find the location of my GlassFish server.
I traced up the parents of pom.xml to find
C:\mine\tools_installation\glassfish4\docs\javaee-tutorial\examples\pom.xml(51):
<glassfish.home.prefix>c:/</glassfish.home.prefix>
Then I changed it to
<glassfish.home.prefix>c:/mine/tools_installation</glassfish.home.prefix>.
The container configuration directory "c://glassfish4/glassfish/domains" does not exist.
Maven / Cargo looks for a folder defined in pom.xml and it doesn't exist on your computer.
I the property you need to change is and you'll need to set it to your GlassFish installation directory.
So it is automatically taken from the parent examples folder pom.xml rather than from your open example. So you should edit the pom.xml from
YOUR_GLASSFISH_HOME\docs\javaee-tutorial\examples
It think it is a bug in the examples pom.xml
I encountered similar error, the solution is very simple You need to edit the pom.xml file as follows. Replace line 38:
${glassfish.home.prefix}/glassfish4
to your GlassFish home, I run GlassFish 4.1.1 installed in C:\ drive. So my modification is:
${glassfish.home.prefix}glassfish-4.1.1.
Please note the slash before glassfish was removed too. The slash after c: in line 51 suffice.
Build it again. Should be fine.
I resolved this error adding in pom.xml those lines:
<profiles>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<glassfish.home>C://Program Files//glassfish-4.1.1</glassfish.home>
</properties>
</profile>
</profiles>
I hope this help
I also usually install my glassfish development server under c:/opt so I had the same problem with the hello2 tutorial from the Java Platform, Enterprise Edition (Java EE) 8 Tutorial.
To solve this problem, I changed the "tutorial-examples/pom.xml" file which is the root parent of all the tutorial POM files. As I am using the J2EE8 tutorial, it is expected that glassfish5 is installed so this is reflected in the properties section:
<glassfish.home>${glassfish.home.prefix}/glassfish5</glassfish.home>
I not sure what tutorial version you are going through but as I see, it expects a glassfish 4 installation thus you need to edit the POM file accordingly.
Also (in the J2EE 8 tutorial), ${glassfish.home.prefix} is defined for every supported profile. For windows the windows profile, I had to change the line:
<glassfish.home.prefix>c:/</glassfish.home.prefix>
to
<glassfish.home.prefix>c:/opt</glassfish.home.prefix>
So the complete windows profile will be:
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<glassfish.home.prefix>c:/opt</glassfish.home.prefix>
<glassfish.executables.suffix>.bat</glassfish.executables.suffix>
</properties>
</profile>
Of course, you'll have to edit the POM file accordingly to your own setup.
Related
Sorry for asking a question that many will say it has been asked again and again, however I couldn't find a satisfactory or complete answer.
I have to build a maven project. Inside it I have the following:
<profile>
<id>windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<weblogic.home>${env.WEBLOGIC_SERVER_HOME}</weblogic.home>
<weblogic.precompilation.java.home>${env.JAVA_64_HOME}</weblogic.precompilation.java.home>
</properties>
</profile>
and I get the error:
[ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for weblogic:weblogic.jar must specify an absolute path but is ${env.WEBLOGIC_SERVER_HOME}/server/lib/weblogic.jar # ..\pom.xml
Of course, by setting the absolute path to the above:
<weblogic.home>c:/Oracle/Middleware/wlserver_10.3</weblogic.home>
the problem is solved, but how can I actually set env.WEBLOGIC_SERVER_HOME in my system so that maven finds it?
I setup a new environment variable:
WEBLOGIC_SERVER_HOME = c:/Oracle/Middleware/wlserver_10.3
in my Windows machine but no luck. I tried setting configuration environmentVariables in maven-surefire-plugin as explained in [How to set up an environment variable in mvn pom? (but didn't pass it via -D in the command line), tried to set a property like here [How to refer environment variable in POM.xml? but no chance.
I thought that once I setup the environment variable (WEBLOGIC_SERVER_HOME) in my OS, I could then access it from my pom using ${env.WEBLOGIC_SERVER_HOME}. But I guess this is not enough.
In my IDE (NetBeans), I cannot set the environment variable for the maven project since it displays the "Resolve Project Problems" dialog box instead.
Any help is appreciated.
I'm trying to run sonarQube through Jenkins but I have some difficulties right now. When I build a new job, I use Maven Project and inside the configuration I have to give à pom.xml path but what does it correspond to ?
Thank you in advance
You should find in any jenkins job a post action for sonarqube analyse.
The pom.xml you mention is the pom.xml for your maven project, because sometimes you can put your parent pom.xml in a subdirectory and this is the way for helping jenkins to find it.
Instead of adding Sonar Task to each project why not just configure Sonar at Global Level configuring the settings.xml for your maven configuration, just go to $HOME/someUser/.m2/settings.xml (if you don't have it created yet) with this content:
<settings>
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://myserver:9000
</sonar.host.url>
</properties>
</profile>
</profiles>
</settings>
After you you have done that you will be able to run sonar in all the projects this way:
mvn clean verify sonar:sonar
# In some situation you may want to run sonar:sonar goal as a dedicated step. Be sure to use install as first step for multi-module projects
mvn clean install
mvn sonar:sonar
# Specify the version of sonar-maven-plugin instead of using the latest. See also 'How to Fix Version of Maven Plugin' below.
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar
You may find more information in sonar official documentation:
https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven
I've got a Maven project for which i use org.apache.tomcat.maven:tomcat6-maven-plugin to deploy to a remote Tomcat.
This tomcat is configured so that i need to specify:
-Djavax.net.ssl.trustStore=mykeystore.jks -Djavax.net.ssl.trustStorePassword=mypassword
My problem is that by doing so, I can't download dependencies anymore from remote repositories through my company proxy as it tries to establish a secure connection using this truststore and it fails...
I'm looking for a way to connect to both ends (maven repo and my remote tomcat) without having to set/unset my MAVEN_OPTS variable every time...
I've seen that I can have a <configuration /> element in my settings.xml, but I can't find what to put in it.
Thanks...
Using different profiles with maven:
Define the active profiles in your pom (you can also define profiles in settings.xml but I think this should work for your case):
<profiles>
<profile>
<id>TOMCAT_DEPLOY</id>
<activation>
// Rules to active the profile
<activeByDefault>true</activeByDefault>
</activation>
<properties>
</properties>
// Add rest of profile specific configuration
</profile>
</profiles>
For executing maven with an specific profile, basically you have a list of active profiles and you can execute one of them according to different triggers:
A profile can be triggered/activated in several ways:
Explicitly, Through Maven settings, Based on environment variables OS settings or based on some Present or missing files
Please, read this link where you can have all information about profiles and how activate them for any execution
I currently work in big project built by Maven which has many integration tests modules which are marked as main (not testing) sources.
I am trying to create a profile which would skip compilation of these modules.
I expected gmaven plugin to allow "skip" configuration parameter but this is not the case.
Is there any way to skip module processing without pointing gmaven plugin to non-existent directory and without copy-paste of all modules except integration tests to a separate profile?
You can put the integration test modules in a separate profile of the parent pom where you list the modules. The profile should be active unless you disable it by setting a property when running the Maven build (-DskipIntegrationTestModules). (Don't use activeByDefault.)
<modules>
<module>my-project</module>
</modules>
<profiles>
<profile>
<id>build-integration-tests</id>
<activation>
<property>
<name>!skipIntegrationTestModules</name>
</property>
</activation>
<modules>
<module>my-project-integration-test</module>
</modules>
</profile>
</profiles>
You can find more details in the Maven Introduction to Build Profiles.
You should also know that it can be dangerous to have modules in build profiles because they could be accidentally left out when doing release builds. I think it should be OK in this case because the profile has to be deactivated explicitly.
I have maven installed on my local machine and I'm trying to test out Sonar installed on a remote box.
I found a few post online to configure settings.xml (maven\config\settings.xml) and append a profile entry...which I did but does not work
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- SERVER ON A REMOTE HOST -->
<sonar.host.url>http://remotebox:9000</sonar.host.url>
</properties>
</profile>
What is the cli way? I tried several options but nothing worked.
I tried: mvn sonar:sonar http://remotebox:9000
What is the correct syntax?
Thanks in advance.
Damian
PS. this works fine on the remote box where both maven and sonar are installed...i just want to try it my box to the remote box.
Running sonar with
mvn sonar:sonar -Dsonar.jdbc.url=jdbc:h2:tcp://ipaddr:9092/sonar -Dsonar.host.url=http://ipaddr:9000
,where ipaddr is your remote host, seems to work.
Up to Version 5.2 beside the sonar.host.url you also have to specify the database parameters as described here. That way it works for me.
Configuration example
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- EXAMPLE FOR MYSQL -->
<sonar.jdbc.url>
jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<!-- optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://myserver:9000
</sonar.host.url>
</properties>
</profile>
Since Version 5.2 this not not necessary anymore:
Quote:
Scanners don't access the database
This is the biggest change of this new version: scanners (e.g. Sonar Runner) no longer access the database, they only use web services to communicate with the server. In practice, this means that the JDBC connection properties can now be removed from analysis CI jobs:
sonar.jdbc.url,
sonar.jdbc.username,
sonar.jdbc.password
Just the following works for sonar-maven-plugin:3.2:
mvn sonar:sonar -Dsonar.host.url=http://<sonarqubeserver>:<port>
Problem 1
As explained you need to specify the JDBC connection details, otherwise Sonar will attempt to talk to the embedded Derby instance, it assumes is running on localhost.
Problem 2
Are you using Derby? Well, the default configuration of Derby does not accept remote connections, but only connections from the same host.
The SONAR-1039 issue explains how to work-around this problem, but my advise would be to setup a full-blown database such as MySQL or Postgresql.
I had some problem and then realized, I was running mavn on parent pom whereas sonar configuration was in a child pom, for which I wanted analysis report anyway, so running mvn sonar:sonar with child pom worked.