Weblogic 11g Maven deploy Issue - java

I am trying to deploy a war file on Weblogic 11g server using Maven (weblogic-maven-plugin) v 10.3.4
But I am getting below error on running mvn wls:deploy
Cannot find MW_HOME at location.....C:\work_maven\springmvc\Oracle\Software. You must define the middlewareHome parameter for the Maven goal.
I have installed weblogic at C:\bea11g
I also have MW_HOME set to above weblogic path.
My project's pom.xml build looks like this:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>10.3.4</version>
<configuration>
<middlewareHome>C:\bea11g</middlewareHome>
<adminurl>t3://localhost:7001</adminurl>
<user>weblogic</user>
<password>weblogic1</password>
<upload>true</upload>
<action>deploy</action>
<remote>false</remote>
<verbose>true</verbose>
<source>
${project.build.directory}/${project.build.finalName}.${project.packaging}
</source>
<name>${project.build.finalName}</name>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Any help is greatly appreciated.
Thanks.

MW_HOME should be set to C:\bea11g, the directory where you installed WebLogic.
However, it looks like it is set to C:\work_maven\springmvc\Ora cle\Software.
Double check your environment variable setup and retry.
[Edit]
See here for reference:
http://docs.oracle.com/cd/E24329_01/web.1211/e24368/maven.htm
It looks like you need to set weblogicHome rather than middlewareHome in your plugin configuration.

It looks like something was wrong with the weblogic-maven-plugin installation and configuration.
I followed the link http://docs.oracle.com/cd/E21764_01/web.1111/e13702/maven_deployer.htm and now it is working fine.

Related

How to Remove version number from file name with Maven Build in Spring Boot 2.1.4 version?

I am trying to upgrade Spring Boot from 2.0 to 2.1.4. When building the application as war file
In 2.1.4 - getting the version number in build filename like as shown below:
War filename : demo-0.0.1-SNAPSHOT-bootified.war
But in 2.0 - not getting the version number in build filename like as shown below:
War filename: demo-bootified.war.
Please find the plugin as shown below:
pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.java.main.test.DemoApplication</mainClass>
<classifier>bootified</classifier>
<build><finalName>${project.artifactId}</finalName></build>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
How to remove the version in build filename in 2.1.4 Spring Boot version? Please suggest on this?
Althogh it worked in previous versions (up to 2.1.3), the behavour is now to include the version. See https://github.com/spring-projects/spring-boot/issues/16457 for more info. Use standard Maven to provide your artifact's final name.
You can add this in your execution configuration:
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<outputDirectory>${basedir}</outputDirectory>
<finalName>${project.artifactId}</finalName>
</configuration>
</execution>
</executions>
Easiest way is to add <finalName> in your <build> section. For example:
<build>
...
<finalName>${project.artifactId}</finalName>
...
</build>

Deploy Java app to Heroku using Git

My project written using the Spark framework has this build config.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<verbose>true</verbose>
<fork>true</fork>
<compilerVersion>1.7</compilerVersion>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<plugin>
<groupId>org.avaje</groupId>
<artifactId>ebean-maven-enhancement-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>main</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<configuration>
<classSource>target/classes</classSource>
<packages>somepath.domain.**</packages>
<transformArgs>debug=1</transformArgs>
</configuration>
</plugin>
</plugins>
</build>
Its main class resides in somepath.Bootstrap.
The Procfile sits next to the pom.
What should the contents of the Procfile be?
(I am deploying via git.)
Procfile contains command, that will be executed after deploying your appliaction (git push heroku master for you example i guess).
I do not very familiar with spark, but i guess it can be something like this:
web: mvn exec:java -Dexec.mainClass="somepath.Bootstrap"
A Procfile is a mechanism for declaring what commands are run by your application’s dynos on the Heroku platform.
Here is an example for a Java app:
web: java -cp target/classes:target/dependency/* Main
This is taken from a Heroku Java sample app that uses Spark.
Be aware that build tools, such as Maven, will not be available at runtime.

Maven WebApp tomcat7 system properties

We are using a maven dependency to add embedded tomcat on our webapplication. It works fine, but I need to add systemProperties to embedded tomcat, so that our webapp can use this systemProperties.
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<executions>
<execution>
<id>tomcat-run</id>
<goals>
<goal>exec-war-only</goal>
</goals>
<phase>package</phase>
<configuration>
<path>/html5</path>
<enableNaming>true</enableNaming>
<finalName>html5.jar</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I tried to add system properties like this, but it didn't work. I added it
<build>
<plugins>
<plugin>
<configuration>
<systemProperties>
<dashboard.oracle.host>1.1.1.1</dashboard.oracle.host>
<dashboard.oracle.port>1521</dashboard.oracle.port>
<dashboard.oracle.sid>orcl</dashboard.oracle.sid>
<dashboard.oracle.url>
jdbc:oracle:thin:#${dashboard.oracle.host}:${dashboard.oracle.port}:${dashboard.oracle.sid}
</dashboard.oracle.url>
<dashboard.oracle.username>username</dashboard.oracle.username>
<dashboard.oracle.password>password</dashboard.oracle.password>
</systemProperties>
</configuration>
...
</plugin>
</plugins>
</build>
In general the way you have added the system properties to the tomcat plugin is correct:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<systemProperties>
<example.value.1>alpha</example.value.1>
<example.value.2>beta</example.value.2>
</systemProperties>
</configuration>
</plugin>
Taken from the Apache Docu.
the system properties in the Maven Plugin are only for when running the tomcat7:run mojo ... in order to pass in the system properties to the executable war (jar), you must do it on the command line:
java -DsysProp1=value -DsysProp2=value -jar exec-war.jar

Could not find dependencies for aspectj-maven-plugin

I have a problem with CTW aspects using aspectj-maven-plugin. I get the following error (execution entry is being highlighted):
Multiple annotations found at this line:
- Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.5:compile failed: Plugin
org.codehaus.mojo:aspectj-maven-plugin:1.5 or one of its dependencies could not be resolved: Could not find artifact
com.sun:tools:jar:1.7.0_21 at specified path C:\Program Files\Java\jre7/../lib/tools.jar (org.codehaus.mojo:aspectj-maven-
plugin:1.5:compile:default:compile)
- Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.5:test-compile failed: Plugin
org.codehaus.mojo:aspectj-maven-plugin:1.5 or one of its dependencies could not be resolved: Could not find artifact
com.sun:tools:jar:1.7.0_21 at specified path C:\Program Files\Java\jre7/../lib/tools.jar (org.codehaus.mojo:aspectj-maven-
plugin:1.5:test-compile:default:test-compile)
On the configuration:
<build>
<plugins>
<!-- http://mojo.codehaus.org/aspectj-maven-plugin/usage.html -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<outxml>true</outxml>
<source>1.7</source>
<target>1.7</target>
<sources>
<source>
<basedir>src/main/java</basedir>
<includes>
<include>**/*Aspect.java</include>
</includes>
</source>
</sources>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
What am I doing wrong? It looks like as if this plugin was unable to find jdk? But why?
Is your JAVA_HOME set properly? Please check that. It worked perfectly for me. So I think you should add below mentioned plugin and try:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
Run mvn compile after that.
Please check the JAVA_HOME env variable. This happened to me when JAVA_HOME is pointed to JRE folder rather than jdk folder.
I had this problem running with java 11, seems like it is only compatible with java 8.
Looking into the project, aspectj-maven-plugin it looks like the update was committed but never actually merged.

Setup Java 6 annotation processing configuration for eclipse compiler with maven

What's the best way to setup the eclipse project compiler configuration for Java 6 annotation processors?
My solution is to setup the org.eclipse.jdt.apt.core.prefs and factorypath files manually. This is a bit cumbersome:
Reference the processor jar in the factorypath file
Configure the eclipse annotation processor output directory (org.eclipse.jdt.apt.genSrcDir property in org.eclipse.jdt.apt.core.prefs)
Add the eclipse annotation processor output directory as source folder
One problem is that eclipse generated sources will be compiled with maven. Only maven clean compile is reliable as it removes the eclipse generated source files. (Eclipse and javac generated source files could be out of sync.)
Is there are better solution to configure maven without eclipse generated source files at the maven source path?
<project>
<properties>
<eclipse.generated.src>${project.build.directory}/eclipse</eclipse.generated.src>
</properties>
<build>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals> <goal>add-source</goal> </goals>
<configuration>
<sources>
<source>${eclipse.generated.src}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<additionalConfig>
<file> <name>.factorypath</name>
<content><![CDATA[<factorypath>
<factorypathentry kind="VARJAR" id="M2_REPO/processor/processor.jar" enabled="true" runInBatchMode="false"/>
</factorypath>
]]> </content>
</file>
<file>
<name>.settings/org.eclipse.jdt.apt.core.prefs</name>
<content><![CDATA[
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=${eclipse.generated.src}
org.eclipse.jdt.apt.reconcileEnabled=true
]]> </content>
</file>
</additionalConfig>
</configuration>
</plugin>
</plugins>
</build>
</project>
Update: You could try using the apt-maven-plugin. It currently provides three goals:
apt-process Executes apt on project sources.
apt:test-process Executes apt on project test sources.
apt:eclipse Generates Eclipse files for apt integration.
You can configure the goals to run as part of your build as follows:
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<goals>
<goal>process</goal>
<goal>test-process</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
By default the output directory is set to ${project.build.directory}/generated-sources/apt,
There is an open Jira against the compiler plugin to add APT support for Java 6, you can go and vote for it if this is something you want to to see in future versions.
I am using http://code.google.com/p/maven-annotation-plugin/ wich is simpler to configure. You can use it in two ways:
generate sources during compilation (configuration below)
generate sources "by hand" to src/main/generated and keep them on SCM
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<compilerArguments>-encoding ${project.build.sourceEncoding}</compilerArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process-test</id>
<goals>
<goal>process-test</goal>
</goals>
<phase>generate-test-sources</phase>
<configuration>
<compilerArguments>-encoding ${project.build.sourceEncoding}</compilerArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding>
<!-- Disable annotation processors during normal compilation -->
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
There is a simpler solution in Eclipse Juno (I'm not sure about previous versions). In Preferences / Maven / Annotation Processing there are three modes for annotation processing. It is disabled by default, but I've tested both other options and worked like a charm for me. This way, you don't need to configure APT processing for every project or modify its pom.xml.

Categories