Deploy with maven plugin on remote weblogic 12c - java

I have weblogic 12c on machine 192.168.1.3. I want to deploy ear from machine 192.168.1.2 with maven plugin:
<groupId>com.oracle.weblogic</groupId>
<artifactId>wls-maven-plugin</artifactId>
<version>12.1.1.0</version>
In the first phase I made in the project:
mvn wls:install
Plugin configuration looks like this:
<configuration>
<adminurl>t3://192.168.1.3:7001</adminurl>
<user>weblogic</user>
<password>welcome1</password>
<debug>true</debug>
<name>test-ear-dev01</name>
<remote>true</remote>
<upload>true</upload>
<advanced>true</advanced>
<failOnError>true</failOnError>
<artifactLocation>c:\Users\bartek\Downloads\wls1211_dev.zip</artifactLocation>
</configuration>
next I make
mvn wls:deploy
and I get following error
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Invalid file. Please provide an existing fully qualified path of the file.
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Invalid file. Please provide an existing fully qualified path of the file.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
...
...
...
Caused by: org.apache.maven.plugin.MojoExecutionException: Invalid file. Please provide an existing fully qualified path of the file.
at weblogic.tools.maven.plugins.deploy.DeployerMojo.handleDeployerException(DeployerMojo.java:459)
...
Caused by: org.apache.maven.plugin.MojoExecutionException: Invalid file. Please provide an existing fully qualified path of the file.
at weblogic.tools.maven.plugins.deploy.DeployerMojo.getSourceParameter(DeployerMojo.java:434)
...
Can you tell me what I'm doing wrong, when deploy ear to a remote server

The configuration you show looks like what you used to install WebLogic with the install goal of the plugin. <artifactLocation> is a configuration element for that goal, not deploy, per the documentation.
For the deploy goal, replace <artifactLocation> with <source>, which contains the name of your ear file.

Related

Spring Boot JAR file not working with ClassNotFoundException

I have a Spring Boot Application that is working.
I did
mvn clean package
and the .jar file is my target folder.
Then I try to execute the following command:
java -jar .\target\my-application-0.0.1-SNAPSHOT.jar
and I get the following Error:
Exception in thread "main" java.lang.ClassNotFoundException: C:\Users\test\example-application\example-app/src/main/test/ExampleApplication
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Researching on stackoverflow just recommend an issue that I already included ...
It was recommended to include this plugin in order to include the maven jars into the project .... spring-boot-maven-plugin
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
What else could be the reason for it not working?
The class name in the exception is a file name and not a class name. That makes me suspect that you have specified the main class incorrectly. Have you specified the name of the class in the spring-boot-maven-plugin with
<configuration>
<mainClass>foo.bar.ExampleApplication</mainClass>
</configuration>
or as a Main-Class in the manifest? Note that you should use dot notation for packages...
I had a similar issue to this a few weeks ago. Spring looks for the source for most classes to be in the /src/main folder.
It looks like you're missing the file from that folder. In my case, I had placed it in just /src instead of /src/main

Maven run Jetty Plugin by command line specifying contextPath

I'm on IntelliJ IDEA CE and I'm running a war application by means of the Maven Jetty Plugin.
I don't have the plugin in my pom.xml (and I don't want to), so I'm running directly the web server with this command:
mvn org.eclipse.jetty:jetty-maven-plugin:9.4.26.v20200117:run-exploded
It works fine but it doesn't apply the contextPath specified in the xml file src/main/webapp/META-INF/context.xml
I would like to specify the right contextPath from the terminal command.
The documentation doesn't say anything specific about this.
The tests I've made (without any successful result) are the following:
mvn org.eclipse.jetty:jetty-maven-plugin:9.4.26.v20200117:run-exploded -Dproject.artifactId='/project'
mvn org.eclipse.jetty:jetty-maven-plugin:9.4.26.v20200117:run-exploded -DcontextPath='/project'
mvn org.eclipse.jetty:jetty-maven-plugin:9.4.26.v20200117:run-exploded -Dconfiguration.webApp.contextPath="/project"
mvn org.eclipse.jetty:jetty-maven-plugin:9.4.26.v20200117:run-exploded -Djetty.configuration.webApp.contextPath="/project"
What am I missing?
This is ultimately a generic maven tip, not Jetty specific.
In other words, how to figure out what you can do with a maven plugin.
$ mvn org.eclipse.jetty:jetty-maven-plugin:9.4.26.v20200117:help
...(snip)...
jetty:help
Display help information on jetty-maven-plugin.
Call mvn jetty:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
So lets see what the details are on goal :run-exploded ...
$ mvn org.eclipse.jetty:jetty-maven-plugin:9.4.26.v20200117:help -Ddetail=true -Dgoal=run-exploded
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- jetty-maven-plugin:9.4.26.v20200117:help (default-cli) # standalone-pom ---
[INFO] Jetty :: Jetty Maven Plugin 9.4.26.v20200117
Jetty maven plugins
jetty:run-exploded
This goal is used to assemble your webapp into an exploded war and
automatically deploy it to Jetty.
Once invoked, the plugin runs continuously, and can be configured to scan for
changes in the pom.xml and to WEB-INF/web.xml, WEB-INF/classes or WEB-INF/lib
and hot redeploy when a change is detected.
You may also specify the location of a jetty.xml file whose contents will be
applied before any plugin configuration. This can be used, for example, to
deploy a static webapp that is not part of your maven build.
Available parameters:
contextHandlers
List of other contexts to set up. Consider using instead the <jettyXml>
element to specify external jetty xml config file. Optional.
contextXml
Location of a context xml configuration file whose contents will be
applied to the webapp AFTER anything in <webApp>.Optional.
dumpOnStart (Default: false)
Use the dump() facility of jetty to print out the server configuration to
logging
User property: dumponStart
excludedGoals
List of goals that are NOT to be used
httpConnector
A ServerConnector to use.
jettyXml
Comma separated list of a jetty xml configuration files whose contents
will be applied before any plugin configuration. Optional.
loginServices
List of security realms to set up. Consider using instead the <jettyXml>
element to specify external jetty xml config file. Optional.
nonBlocking (Default: false)
Determines whether or not the server blocks when started. The default
behavior (false) will cause the server to pause other processes while it
continues to handle web requests. This is useful when starting the server
with the intent to work with it interactively. This is the behaviour of
the jetty:run, jetty:run-war, jetty:run-war-exploded goals.
If true, the server will not block the execution of subsequent code. This
is the behaviour of the jetty:start and default behaviour of the
jetty:deploy goals.
reload (Default: automatic)
reload can be set to either 'automatic' or 'manual' if 'manual' then the
context can be reloaded by a linefeed in the console if 'automatic' then
traditional reloading on changed files is enabled.
User property: jetty.reload
requestLog
A RequestLog implementation to use for the webapp at runtime. Consider
using instead the <jettyXml> element to specify external jetty xml config
file. Optional.
scanIntervalSeconds (Default: 0)
The interval in seconds to scan the webapp for changes and restart the
context if necessary. Ignored if reload is enabled. Disabled by default.
Required: Yes
User property: jetty.scanIntervalSeconds
server
A wrapper for the Server object
skip (Default: false)
Skip this mojo execution.
User property: jetty.skip
stopKey
Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey>
-DSTOP.PORT=<stopPort> -jar start.jar --stop
stopPort
Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort>
-DSTOP.KEY=<stopKey> -jar start.jar --stop
supportedPackagings
Per default this goal support only war packaging. If your project use an
other type please configure it here.
systemProperties
System properties to set before execution. Note that these properties will
NOT override System properties that have been set on the command line or
by the JVM. They WILL override System properties that have been set via
systemPropertiesFile. Optional.
systemPropertiesFile
File containing system properties to be set before execution Note that
these properties will NOT override System properties that have been set on
the command line, by the JVM, or directly in the POM via systemProperties.
Optional.
User property: jetty.systemPropertiesFile
useProvidedScope (Default: false)
Whether or not to include dependencies on the plugin's classpath with
<scope>provided</scope> Use WITH CAUTION as you may wind up with duplicate
jars/classes.
war (Default: ${project.build.directory}/${project.build.finalName})
The location of the war file.
Required: Yes
webApp
An instance of org.eclipse.jetty.webapp.WebAppContext that represents the
webapp. Use any of its setters to configure the webapp. This is the
preferred and most flexible method of configuration, rather than using the
(deprecated) individual parameters like 'tmpDirectory', 'contextPath' etc.
This tells you that the configuration for the webApp is where you set the contextPath
Unfortunately, that's a complex object and you cannot specify that on the command line.
So edit your pom.xml to include it.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webApp>
<contextPath>/foo</contextPath>
</webApp>
</configuration>
</plugin>
...
See also How to define complex Maven properties in the comand line
Here is the link
https://www.eclipse.org/jetty/documentation/jetty-9/index.html#jetty-maven-plugin
Here is the commandline:
mvn jetty:run -Dcontext=/abc
This command line is for the following pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rahul.soAnswer</groupId>
<artifactId>jetty-run</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>jetty-answer</name>
<packaging>war</packaging>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.44.v20210927</version>
<configuration>
<webApp>
<contextPath>${context}</contextPath>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
</project>
You can choose to add more detail to the configuration as per your application needs

How do I conditionally map a directory with Maven RPM plugin?

I have written a master parent pom for use with multiple projects.
In this pom we have setup the RPM plugin to package things. I am starting to create a new standard where we want a new top level folder to exist in every repo.
The problem is I need to not fail to create an RPM if the directory does not exist, at least for now.
I have added a mapping like so
<mapping>
<directory>/var/lib/appName/${service}/deploy</directory>
<filemode>775</filemode>
<username>${serviceuser}</username>
<groupname>${servicegroup}</groupname>
<sources>
<source>
<location>deploy</location>
</source>
</sources>
</mapping>
The build fails when the folder does not exist.
The error is
Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1-alpha-4:attached-rpm (default) on project example-service: Source location deploy does not exist -> [Help 1]

How to build the war files for oAuth2-sample project?

I cloned the project here https://github.com/OhadR/oAuth2-sample
Set appropriate version for parent in pom.xml of all 3 projects oauth2-client, oauth2-auth-server, resource-sercer to
<version>1.6.2-SNAPSHOT</version>
I added the 3 projects to modules section in auth-parent. I built war files using mvn install.
<modules>
<module>auth-common</module>
<module>common-crypto</module>
<module>authentication-flows</module>
<module>oauth2-auth-server</module>
<module>oauth2-client</module>
<module>oauth2-resource-server</module>
</modules>
I put the 3 generate war file in jetty/webapps. Client and Resource-server seem to load fine but oauth2-auth-server doesnt. At localhost:8080 I get UNAVAILABLE for oauth2-auth-server.
I tried debugging by adding maven-jetty plugin and mvn jetty:run for oauth2-auth-server. But I get
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'authenticationSuccessHandler' for bean class [com.ohadr.auth_flows.core.AuthenticationSuccessHandler] conflicts with existing, non-compatible bean definition of same name and class [com.ohadr.oauth_srv.web.OhadAuthenticationSuccessHandler]
Not sure I see the problem - did you try build it from the main directory, by using maven command "mvn clean install"?
Maven will then build all sub-modules, which are common-crypto and authentication-flows.
My oAuth-Sample project is in use as an oAuth example as well as "authentication-flows" logic.
Do you build this oAuth-sample for oAuth-sample, or for "authentication-flows"?
Hope that helps (and sorry about the delay)

How are related maven GAV naming an jar naming?

For the following GAV defined in my pom.xml:
groupID : org.test
artifactID : test-spring-kie
version : 0.1.8-SNAPSHOT
I have an exception when my java program looks for a maven resource:
org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact org.test:test-spring-kie:pom:0.1.8-SNAPSHOT in local (file:///home/superseed77/.m2/repository)
or
org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact org.test:test-spring-kie:jar:0.1.8-SNAPSHOT in local (file:///home/superseed77/.m2/repository)
I believe it's a reference to a jar named
test-spring-kie[some separator]0.1.8-SNAPSHOT.jar
in the directory
.m2/repository/org.test/test-spring-kie/
Am I right ?
What is the mechanism (transformation rules) to find jar name and location against this org.test:test-spring-kie:jar:0.1.8-SNAPSHOT?
The directory hierarchy is :group/:artifact/:version/jarfile.
For example, commons-lang 2.4 is in the following location:
~/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
If you're using Maven to build your jar file you should really do mvn install to ensure it is placed in the correct location

Categories