Errors when using maven plugin for Weblogic deployment - eclipse

I have been trying to deploy application to Weblogic 10.3.6 using maven
I have created weblogic plugin for maven as mentioned in this article.
I have added the following to pom.xml
<build>
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.3</version>
<configuration>
<goalPrefix>weblogic</goalPrefix>
</configuration>
</plugin>
<plugin>
<groupId>weblogic</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>10.3.6.0</version>
<configuration>
<adminurl>t3://localdomain:7001</adminurl>
<user>weblogic</user>
<password>password</password>
<name>wldemo</name>
<remote>true</remote>
<upload>true</upload>
<targets>AdminServer</targets>
</configuration>
<executions>
<execution>
<id>deploy</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<source>target/EmployeesApp-1.0-SNAPSHOT.war</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
When I did mvn com.oracle.weblogic:weblogic-maven-plugin:deploy I am getting the following errors, how can I resolve these errors?
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.oracle.weblogic:weblogic-maven-plugin:10.3.6.
0:deploy (default-cli) on project EmployeesApp: The parameters 'source' for goal
com.oracle.weblogic:weblogic-maven-plugin:10.3.6.0:deploy are missing or invali
d

You have specified the source parameter in the execution configuration, so in order to make it taken into account you should invoke this particular execution. It can be done using the phase key you specified, so e.g.:
mvn integration-test
Maven will go through the whole lifecycle and on the pre-integration-test test phase (which precedes the integration-test one) it will run the execution of weblogic-maven-plugin you configured.

Related

Mulesoft - Cloudhub deployment error: Deployment configuration is not valid, : No deployment configuration was defined

This is my build details in POM:
<build>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<deploymentType>${deploymentType}</deploymentType>
<muleVersion>${muleVersion}</muleVersion>
<redeploy>${redeploy}</redeploy>
<businessGroup>${businessGroup}</businessGroup>
<username>${username}</username>
<password>${password}</password>
<applicationName>${applicationName}</applicationName>
<environment>${environment}</environment>
<region>${region}</region>
<workers>${workers}</workers>
<workerType>${workerType}</workerType>
<uri>${anypoint.uri}</uri>
</configuration>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<args>-parameters</args>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
These are my properties:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<app.runtime>4.2.1</app.runtime>
<mule.maven.plugin.version>3.2.7</mule.maven.plugin.version>
<deploymentType>cloudhub</deploymentType>
<muleVersion>4.2.1</muleVersion>
<redeploy>true</redeploy>
<businessGroup>****</businessGroup>
<username>****</username>
<password>****</password>
<applicationName>****</applicationName>
<environment>Sandbox</environment>
<region>us-east-1</region>
<workers>1</workers>
<workerType>Micro</workerType>
<anypoint.uri>https://anypoint.mulesoft.com</anypoint.uri>
</properties>
Following is my terminal command:
mvn clean deploy -DmuleDeploy -X
and I am getting following error:
[ERROR] Failed to execute goal org.mule.tools.maven:mule-maven-plugin:3.2.7:deploy (default-deploy) on project helloworld: Deployment configuration is not valid, : No deployment configuration was defined. Aborting. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.mule.tools.maven:mule-maven-plugin:3.2.7:deploy (default-deploy) on project helloworld: Deployment configuration is not valid,
If I use following configuration, it deploys successfully in cloudhub:
<configuration>
<cloudHubDeployment>
<uri>${anypoint.uri}</uri>
<muleVersion>${muleVersion}</muleVersion>
<businessGroup>${businessGroup}</businessGroup>
<username>${username}</username>
<password>${password}</password>
<applicationName>${applicationName}</applicationName>
<environment>${environment}</environment>
<region>${region}</region>
<workers>${workers}</workers>
<workerType>${workerType}</workerType>
</cloudHubDeployment>
</configuration>
Not sure where I am doing wrong in the first config.
The configuration in the first example is for the older version of the Mule Maven Plugin (2.2.x or earlier) for Mule 3.x. The versions for Mule 4.x (3.3.x) always used the format of your second example. See the documentation at https://docs.mulesoft.com/mule-runtime/4.2/mmp-concept#deploying-to-cloudhub
The last version of the Mule Maven Plugin for Mule 3 (2.3.x) uses the same format than the Mule 4 version.
In summary, the first example is obsolete and not compatible with a Mule 4 deployment.

Custom unit test folder/path doesn't see custom src folder/path in Maven project when using terminal

I have a custom structure in my project of
Development -
- src
- test
and running tests works fine through eclipse but when I use the terminal on my mac to run the test (mvn test), the src classes are not found (fails during maven compile plugin). I figure it has to be an issue with my pom not guiding the plugins to the right folders. If I comment out this line,
<outputDirectory>Development/build</outputDirectory>
it works fine because the .class files r now being placed in the target folder. Instead of looking at the target folder for the.class files, I need maven to look at the
Development/build
directory if I'm not mistaken. Right?
I would like to continue to use my custom file structure and correct my pom so that it compiles and runs unit test through my mac's terminals.
<build>
<sourceDirectory>Development/src/main</sourceDirectory>
<testSourceDirectory>Development/src/test</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<outputDirectory>Development/build</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<classesDirectory>Development/build</classesDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>Development/build</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptors>
<descriptor>Development/src/assembly/assembly.xml</descriptor>
</descriptors>
<tarLongFileMode>posix</tarLongFileMode>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
</plugins>
</build>
This is the console output
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) # weatherdetails ---
[INFO] Deleting /Users/username/git/weatherdetails/target
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (auto-clean) # weatherdetails ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # weatherdetails ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/username/git/weatherdetails/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # weatherdetails ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2503 source files to /Users/username/git/weatherdetails/Development/build
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # weatherdetails ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/username/git/weatherdetails/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) # weatherdetails ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/username/git/weatherdetails/Development/build
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/username/git/weatherdetails/Development/src/test/com/wfc/schedulers/WeeklySchedulerTest.java:[12,26] cannot find symbol
symbol: class WeeklyScheduler
location: package com.wfc.schedulers
Any suggestions on what's not configured correctly?
I was able to get this work shortly after making this post but wanted to see if someone had a different answer. While formatting this post to meet the stackoverflow standards, I noticed the compiler plugin was writing the classes to /Users/username/git/weatherdetails/Development/build. i said wait thats wrong. it should write them to /Users/username/git/weatherdetails/Development/build/classes and /Users/username/git/weatherdetails/Development/build/test-classes. i googled how to change the target directory in the pom and ran into this tag
<directory>Development/build</directory>
I added it to the build and removed the
<outputDirectory>Development/build</outputDirectory>
tag from the compiler plugin because i added it there thinking that it was creating the custom target folder in the path. Ran it and it worked. So now my build looks like this
<build>
<sourceDirectory>Development/src/main</sourceDirectory>
<testSourceDirectory>Development/src/test</testSourceDirectory>
<!-- if you put just Development, it will erase everything in the development folder -->
<directory>Development/build</directory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<classesDirectory>Development/build</classesDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>Development/build</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptors> <descriptor>Development/src/assembly/assembly.xml</descriptor>
</descriptors>
<tarLongFileMode>posix</tarLongFileMode>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
</plugins>
</build>
Hope this helps someone!

How to build a Maven project with Eclipse with a pom.xml that imports an external properties file?

I have looked around from various questions on stackoverflow, but I have not found the answer that solve my purpose.
I want to import a properties file in a pom.xml; my purpose is to replace the <properties> section with the properties loaded from the external file.
Each property refers to the version of a particular maven dependency.
I have tried the properties-maven-plugin, but the properties are not solved and the project is not built.
I'm looking for a way that preserve the standard build of Eclipse, and also the mvn install goal of Maven.
As an example, I want that this section:
<properties>
<dependency1.version>1.0.0</dependency1.version>
</properties>
will be replaced with the property declared in a dependency.properties file, like this one:
dependency1.version=1.0.0
How can I implement my pom.xml in order to obtain this behaviour?
Thanks in advance.
EDIT
This is what I have tried:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/dependencies.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>my version: ${dependency1.version}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Well, if I do a simple mvn install, in maven console it prints:
[INFO] Executing tasks
[echo] my version: 1.0.0
[INFO] Executed tasks
So, the plugin solve the property, but when I try to import the dependency with this:
<dependencies>
<dependency>
<groupId>dependency1</groupId>
<artifactId>dependency1</artifactId>
<version>${dependency1.version}</version>
</dependency>
</dependencies>
I obtain this error:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for dependency1:dependency1:jar must be a valid version but is '${dependency1.version}'. # line 21, column 13
#
The property is solved in the maven-antrun-plugin, but if it is used in the dependencies section, it doesn't work.

m2e shade eclipse "project main artifact does not exist"

I'm trying to make a deployment package that bundles all the dependencies of my maven module that has dependencies to another maven project in eclipse.
I have this in my pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.proj</groupId>
<artifactId>AAA</artifactId>
<version>0.0.2-SNAPSHOT</version>
<name>btc</name>
<dependencies>
<dependency>
<groupId>com.another.proj</groupId>
<artifactId>BBB</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.group.id.Launcher1</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I use that "m2 Maven Build" in eclipse with the goal "org.apache.maven.plugins:maven-shade-plugin:shade" and the "Resolve Workspace artifacts" ticked.
It's failing with
--- maven-shade-plugin:1.6:shade (default-cli) # AAA ---
[ERROR] The project main artifact does not exist. This could have the following
[ERROR] reasons:
[ERROR] - You have invoked the goal directly from the command line. This is not
[ERROR] supported. Please add the goal to the default lifecycle via an
[ERROR] <execution> element in your POM and use "mvn package" to have it run.
[ERROR] - You have bound the goal to a lifecycle phase before "package". Please
[ERROR] remove this binding from your POM such that the goal will be run in
[ERROR] the proper phase.
I ran out of idea at this point.
[ERROR] The project main artifact does not exist. This could have the following
We were getting this problem recently. What resolved it for us was to not do mvn shade:shade but instead use:
mvn package
This does additional compilation and package work before running the shade plugin and so the main class was available on the classpath.
The shade plugin is attempting to include the project's artifact in the shaded JAR. Since it doesn't exist (yet), you're getting this error. You either need to build/package the project artifact first (e.g., by attaching the shade goal to the package phase)
If you don't have any project artifact to include in the shaded JAR, you can add an excludes node to remove the project's artifact.
Here's an example:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.group.id.Launcher1</mainClass>
</transformer>
</transformers>
<excludes>
<exclude>com.my.proj:AAA</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>

Maven auto-clean on package

I'm having some troubles trying to auto-clean each time i run mvn package.
I've added in the POM :
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
But i'm getting the following error from M2Eclipse :
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-clean-plugin:2.5:clean (execution: auto-clean, phase: initialize)
I've tried other phases like "validate" or "generate-resources" but i'm always getting the same error.
It's not a Maven problem, it's m2eclipse. I haven't used it in a long time, but apparently when you add some plugin executions, you have to add additional configuration to m2eclipse. There's a lengthy description of this error on the Eclipse wiki.