When I am deploying maven project using the command
mvn clean install
I got the following error
error :
Failed to execute goal org.codehaus.mojo: tomcat-maven-plugin:1.1 :
deploy-only (deault - cli) on project testapp : Cannot invoke Tomcat
Manager : Server returned HTTP response code : 403 for URL : http
: //localhost : 8080/manager/html/deploy?path=%2Ftestapp&war = ->
I changed the code in pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<url>http://localhost:8080/manager/html</url>
<warFile>target/testapp.war</warFile>
</configuration>
</plugin>
when I changed the configuration url
http://localhost:8080/manager/html
chaned to
http://localhost:8080/manager/text
then my maven project was deployed successfully.
am I doing correct?
May I know the exact difference between them?
Thank You.
Basically, maven is trying to invoke commands in tomcat.
Tomcat 7 provides separate manager roles for the GUI (manager-gui), status (manager-status), scripting (manager-script) and JMX proxy (manager-jmx), defined in webapps/manager/WEB-INF/web.xml.
A user with role - manager-script can't use tomcat's web-interface ( i.e. /html URL of manager) while manager-script role is the one used by maven plug in.
So basically, you have to understand difference between Tomcat's manager-script and manager-gui manager roles. /html is not accessible for role - manager-script and only accessible for manager-gui role.
Coming to your original question, /text URL means that you are using tomcat's text-based-interface and /html URL means that you are using tomcat's web-interface.
Some additional information is here
The /manager/html path is the HTML interface to the Tomcat manager. The /manager/text path is the text based interface to the Tomcat manager that allows you to run commands such as deployments or reloads and considered the tools friendly interface. /manager/text is the path used by the Tomcat Maven plugin.
Related
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
I have a Spring Boot project that works perfectly when run in IDE. I would like to run this via AWS CodeStar. Unfortunately, the default Spring template created by CodeStar uses Spring MVC.
I cannot just overwrite the default Spring MVC project with my Spring Boot project (it doesn't work). I can copy some of my resources to the MVC project, for example index.html and that works. But then features like Thymeleaf don't work. For this and other reasons, I would like to change the provided Spring MVC into the Spring Boot structure I already have.
I followed the instructions here: https://www.baeldung.com/spring-boot-migration
Unfortunately, this doesn't help. I can create Application Entry Point and add Spring Boot dependencies without the app breaking. But when I remove the default dependencies or the configuration associated with the MVC, the app breaks. When trying to reach the URL, I get a 404 error with description:
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Debugging this error message (e.g. https://www.codejava.net/java-ee/servlet/solved-tomcat-error-http-status-404-not-found) didn't help.
The message seems like it's connected to the web resource. I have my web resources in folder resources as well as webapp/resources. And Spring Boot doesn't need any location configuration, right? It uses this location by default.
Can somebody tell me what things to remove and what to add to be able to use my existing Spring Boot project?
EDIT:
This is a link to a default template for AWS CodeStar Spring web application: https://github.com/JanHorcicka/AWS-codestar-template
And this is my Spring Boot project structure:
I realize that you indicated that previously you tried to use your Spring Boot project with some modifications without success, but I think it could be actually a possibility to successfully deploy your application on AWS CodeStar, and it will be my advice.
I also realized that in your screenshot you included several of the required artifacts and classes, but please, double check that you followed these steps when you deployed your application to AWS CodeStar.
Let's start with a pristine version of your Spring Boot project running locally, without any modification, and then, perform the following changes.
First, as indicated in the GitHub link you shared, be sure that you include the following files in your project. They are required for the deployment infrastructure of AWS:
appspec.yml
buildspec.yml
template.yml
template-configuration.json
The whole scripts directory
Please, adapt any necessary configuration to your specific needs, especially, template-configuration.json.
Then, perform the following modifications in your pom.xml. Some of them are required for Spring Boot to work as a traditional deployment and others are required by the deployment in AWS CodeStar.
Be sure that you indicate packaging as war:
<packaging>war</packaging>
To ensure that the embedded servlet container does not interfere with the Tomcat to which the war file is deployed, either mark the Tomcat dependency as being provided as suggested in the above-mentioned documentation:
<dependencies>
<!-- … -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- … -->
</dependencies>
Or exclude the Tomcat dependency in your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
If necessary, apply this exclusion using some kind of profile that allows you to boot Spring Boot locally and in an external servlet container at the same time.
Next, parameterize the maven war plugin to conform to the AWS CodeStar deployment needs:
<build>
<pluginManagement>
<plugins>
<!-- ... -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>ROOT</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<!-- ... -->
<plugins>
</pluginManagement>
</build>
I do not consider it necessary, but just to avoid any kind of problem, adjust the name of your final build:
<finalName>ROOT</finalName>
Lastly, as also indicated in the Spring documentation, be sure that your MyProjectApplication - I assume this class is your main entry point subclass SpringBootServletInitializer and override the configure accordingly, something like:
#SpringBootApplication
public class MyProjectApplication extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(MyProjectApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(MyProjectApplication.class, args);
}
}
Please, feel free to adapt the class to your specific use case.
With this setup, try to deploy your application and see if it works: perhaps you can find some kind of library dependencies problem, but I think for the most part it should work fine.
At a first step, you can try to deploy locally the version of the application you will later deploy to AWS CodeStar following the instructions you provided in your project template, basically, once configured with the necessary changes described in the answer, by running:
mvn clean package
And deploying the generated war on your local tomcat environment. Please, be aware that probably the ROOT application already exists in a standard tomcat installation (you can verify it by inspecting the webapps folder): you can override that war file.
For local testing you can even choose a different application name (configuring build.finalName and the warName in your pom.xml file): the important thing is verify if locally the application runs successfully.
If you prefer to, you can choose to deploy the app directly to AWS CodeStar and inspect the logs later it necessary.
In any case, please, pay attention on two things: on one hand, if you have any absolute path configured in your application, it can be the cause of the 404 issue you mention in the comments. Be aware that your application will be deployed in Tomcat with context root '/'.
On the other hand, review how you configured your database access.
Probably you used application.properties and it is fine, but please, be aware that when employing the application the database must be reachable: perhaps Spring is unable to create the necessary datasources, and the persistence manager or related stuff associated with and, as a consequence, the application is not starting. Again, it may be the reason of the 404 error code.
To simplify database connectivity, for testing, at first glance, I recommend you to use simple properties for configuring your datasource, namely the driver class, connection string, username and password. If that setup works properly, you can later enable JNDI or what deemed necessary.
Remember that if you need to change your context name and/or define a datasource pool in Tomcat you can place a context.xml file under a META-INF directory in your web app root path.
This context.xml should look like something similar to:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/">
<Resource name="jdbc/myDS"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
url="jdbc:mysql://localhost:3306/myds"
driverClassName="com.mysql.jdbc.Driver"
username="root"
password="secret"
/>
</Context>
I'm developing a simple web app that i need to deploy to Azure as an App Service.
It's a Spring Boot project and i've followed the instructions from this website:
https://learn.microsoft.com/en-us/java/azure/spring-framework/deploy-spring-boot-java-app-with-maven-plugin
I've done few changes, like adding some configuration to pom.xml so that the right subscription is chosen. When i run mvn azure-webapp:deploy it completes without errors and i see a bunch of stuff is uploaded. But when i visit my site at the given url xxx.azurewebsites.net all i get is a Error 404. I even tried the Azure Toolkit for Intellij, it completes successfully but site still gives error.
I've watched hours of youtube videos and lots of tutorials on this and i can't see that i've missed any steps.
Combining the steps in the official tutorials and my deployment procedure, I provide the following check points for you:
Point 1: Please use mvn package to bulid the JAR package in the directory under which the pom.xml file is located.
]
Point 2: Please make sure that the jar package name configured in web.config is the same as the uploaded jar package name.
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\<your project name>"">
</httpPlatform>
</system.webServer>
</configuration>
Point 3: Please use FTP to publish jar files and web.config to D:\home\site\wwwroot\ directory on KUDU.
Point 4: Please make sure ApplicationSettings matches your project such as jdk version,tomcat version.
If you want to deploy a war file, you need to configure the ApplicationSettings of your app service on Azure portal, then upload the war file into the path D:\home\site\wwwroot\webapps.
In addition, you could check the log files on KUDU : https://<your project name>.scm.azurewebsites.net/DebugConsole.
As references, please refer to the documents and threads below.
1.Configure web apps in Azure App Service
2.Create a Java web app in Azure App Service
3.Deploying Springboot to Azure App Service.
Hope it helps you.
I have a maven multi module project set up for an AEM application:
core
ui.apps
it.launcher
it.tests
ui.workflows (added more recently)
The application is deployed through Jenkins via a Maven build using the 0.0.24 version of the com.day.jcr.vault content-package-maven-plugin:
mvn clean install -PautoInstallPackage (-D... [admin creds] -D... [server info])
Intermittently, the Jenkins build will fail because the deployment of ui.workflows to http://{server}.{port}/crx/packmgr/service.jsp will fail with the following message:
[ERROR] Missing response status information in response:
Checking in the logs of successful and unsuccessful deployments, I can see that the successful deployment requests returns an XML response that begins with
<crx version="1.4.1" user="admin" workspace="crx.default">
and ends with
Package installed in 4098ms.
</log>
</data>
<status code="200">ok</status>
</response>
</crx>
The unsuccessful deployment requests returns an HTML response that begins with
<html>
<head>
<title>Content modified /crx/packmgr/service.jsp</title>
</head>
<body>
<h1>Content modified /crx/packmgr/service.jsp</h1>
<table>
<tbody>
<tr>
<td>Status</td>
<td><div id="Status">200</div></td>
</tr>
I surmise that the request to the service endpoint in AEM was successful but that the plugin could not parse the HTML response. It looks like AEM in 6.2 is moving away from the /crx/packmgr/service.jsp endpoint, as well as XML responses in this documentation here
In the Adobe Nexus Repo for the maven plugin, there is a new version (0.5), which is a significant leap in version number from the previous number, and also coincides with the AEM 6.2 version release (April 2016) but I cannot find any documentation on how to configure the new plugin.
If anyone has experienced this issue, how did you resolve it?
For help on the latest plugin you could do following -
mvn com.day.jcr.vault:content-package-maven-plugin:0.5.1:help
This will give you list of goals available with new plugin. Given that you are looking into installing the package, the goal to get details will be install, you could type following command to get the details for configuring the goal -
mvn com.day.jcr.vault:content-package-maven-plugin:0.5.1:help -Ddetail=true -Dgoal=install
This will give you configuration details, something like -
[INFO] Adobe Content Package Maven Plugin 0.5.1 Maven Plugin
supporting creation of content packages and controlling the package
manager on a remote system.
content-package:install Install a Content Package on a remote CRX or
Communique 5 system.
Available parameters:
artifact
A string of the form groupId:artifactId:version[:packaging].
User property: vault.artifact
artifactId
The artifactId of the artifact to install
User property: vault.artifactId
failOnError (Default: false)
If true, fail the build if there is an error while installing.
User property: vault.failOnError
groupId
The groupId of the artifact to install
User property: vault.groupId
install (Default: true)
Whether to install (unpack) the uploaded package automatically or not.
User property: vault.install
name (Default: ${project.artifactId})
The name of the content package
User property: vault.name
packageFile (Default:
${project.build.directory}/${project.build.finalName}.zip)
The name of the content package file to install on the target system. If
not set, the primary artifact of the project is considered the content
package to be installed.
User property: vault.file
packaging (Default: zip)
The packaging of the artifact to install
User property: vault.packaging
password (Default: admin)
The password to authenticate against the remote CRX system.
Required: Yes
User property: vault.password
relaxedSSLCheck (Default: false)
User property: vault.relaxedSSLCheck
repositoryId (Default: temp)
The id of the repository from which we'll download the artifact
User property: vault.repoId
repositoryUrl
The url of the repository from which we'll download the artifact
User property: vault.repoUrl
serverId
The server id with which to get the username and password from the user's
settings file.
User property: vault.serverId
serviceURL (Default: http://localhost:4502/crx/packmgr/service/.json)
Required: Yes
User property: vault.serviceURL
targetURL (Default: http://localhost:4502/crx/packmgr/service.jsp)
The URL to the HTTP service API of the CRX package manager. See HTTP
Service Interface for details on this interface.
Required: Yes
User property: vault.targetURL
timeout (Default: 5)
The connection timeout to set when communicating with the package manager
service. Default value is 5 seconds. Value is specified in seconds.
User property: vault.timeout
useProxy (Default: true)
Setting this to false disables considering the use of any of the active
proxies configured in the Maven Settings. By default the first active
proxy configuration in the Maven Settings is used to proxy any request to
the package manager.
User property: vault.useProxy
userId (Default: admin)
The user name to authenticate as against the remote CRX system.
Required: Yes
User property: vault.userId
verbose (Default: false)
Enable verbose logging when set to true.
User property: vault.verbose
version
The version of the artifact to install
User property: vault.version
I had the same problem for my multimodule project:
module 1: simple content
module 2: simple content, assets and bundle
module 3: simple content
Packages for these modules were installed in the order shown above and it seemed to be the issue.
It turned out that the problem occurred when installing the third package and in error.log there was a problem with some workflows for assets. I don't know what's the exact reason, but changing the order of packages actually helped, so what I had to do is to install the package with assets and bundle at the end. You may consider a similar solution depending on your project structure.
I know it's an old problem but we encountered this issue recently. Updating to version 0.5.24 of content-package-maven-plugin resolves the issue.
The deploy profile on local machines works ok but failed in CI environment for which I'll create another story and link it here.
<plugins>
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<executions>
<execution>
<id>install-package</id>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<version>0.0.24</version>
<extensions>true</extensions>
<configuration>
<failOnError>true</failOnError>
<username>${crx.username}</username>
<password>${crx.password}</password>
</configuration>
</plugin>
</plugins>
Following is the error log I'm getting:
I'm using
wrapper-windows-x86-32-3.5.25-pro
in order to make my already developed application in Spring-boot. I wanted to execute this application as a windows service but I'm not.
This problem is specific to Tanukisoftware as I'm unable to configure it.
PFB the configuration I'm using for setting up the class path here:
wrapper.java.classpath.1=../lib/wrappertest.jar
wrapper.java.classpath.2=../lib/wrapper.jar
wrapper.java.classpath.3=../lib/slf4j-api-1.7.5
wrapper.java.classpath.4=../lib/myApp.jar
even if myApp.jar contains the slf4j classpath already and its running already. I think this is library specific problem and its not finding up the classpath even if I explicitly set it like did above.
Can you please let me know how it can be solved?
Did you try building a fat jar of your application ? You can add following lines to your Spring Boot project's pom.xml to repackage jar file:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Besides, your following property line seems invalid:
wrapper.java.classpath.3=../lib/slf4j-api-1.7.5
Is it pointing a jar file actually ?
slf4j-api-1.7.5 should have a .jar extension. That is possibly confusing things.
Also, even just as a debugging step, try running your Windows service using Apache ProcRun to see if your results are any different.