I have just set up a basic Jetty project named music-store-api. To access my project through Jetty I would go to http://localhost:8090/music-store-api/hello-world. I am wondering how I would remove the music-store-api part from the URL so it becomes http://localhost:8090/hello-world?
Change the context path to root, aka "/".
Depending on how you have your music app deployed, there's a few different ways to accomplish this.
Since you are using jetty-maven-plugin and it's jetty:run goal, you'll need to edit your pom.xml.
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.31.v20200723</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath> <!-- this line is the important one -->
</webApp>
</configuration>
</plugin>
From: https://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#configuring-your-webapp
I followed the instructions tp modify the contextPath on https://www.eclipse.org/jetty/documentation/current/configuring-specific-webapp-deployment.html
Related
I'm currently trying to run a REST service for which I did the code of the services in java, and originally I was trying to get some client to test it. My problem right now is that the tomcat does not work with any path other than home (I do see the main page of tomcat, but whenever I try to access to any defined path I get a 404).
I've been trying this for several days, and I know there are a lot of posts about this because I've read a good amount of them, nevertheless, I don't know what I might be doing wrong, and at this point I would rather understand what is going on that simply fix it (not that I can right now anyway).
My configuration right now is: eclipse mars with tomcat 6, 7 and 8 currently installed (first I only had 6, but it didn't work so as I tried more options I installed more versions). I have maven 3.3.1 plugin, and what I currently do is: create a maven project, add whatever facets I need (I have some code servlets I did I'd like to test, but even a path to a helloworld is giving me a 404).
Then I right click maven install, then I try several things, all fail, main one that I think I should be doing is maven build with options deploy, so that the tomcat gets the war, and I can test the code. The problem is that when I manage to get a build success, I also get this message: 403
I don't really mind what option I use as long as I use it in some tomcat, locally, and I can test the rest service I'm trying to build
My current configuration (I've tried several, same result):
maven setting.xml
<server>
<id>myTomcat</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager-script"/>
<user username="admin1" password="admin" roles="manager-script"/>
</tomcat-users>
Pom:
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<server>myTomcat</server>
<url>http://localhost:8080/manager/html</url>
<path>/${project.build.finalName}</path>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
I hava a maven project, pom.xml contains tomcat plugin.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
I've downloaded Tomcat 7, so I've got Tomcat directory (apache-tomcat-7.0.56). I tried three goals to run my project:
tomcat7:run, tomcat7:run-war, tomcat7:run-war-only
My application is running at http://localhost:8080/projectname, if I run tomcat7:run-war, projectname-0.0.1-SNAPSHOT.war appears in the /target directory of my project.
I want to run my application at http://localhost:8080/.
I know this question was asked before, but unfortunately those solutions didn't help me.
I tried both methods from the first answer of this.
First method didn't work for me, after renaming war nothing changed, tomcat7:run-war-only requires war with name like projectname-0.0.1-SNAPSHOT.war.
The second method changed nothing (I tried both
<Context path="" docBase="projectname-0.0.1-SNAPSHOT" debug="0" reloadable="true"></Context>
and
<Context path="" docBase="projectname" debug="0" reloadable="true"></Context>)
I have also looked throw this, but I don't have <catalina_home>/conf/Catalina/localhost/ directory in my Tomcat directory.
Have you tried changing the context path by setting it in the configuration section of the Maven plugin?
FYI: Find the current version of the plugin here
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
</configuration>
</plugin>
I am using tomee and it works for me.
Add the context tag to the pom file as follows:-
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
..
<context>ROOT<context>
..
</configuration>
</plugin>
Please, someone help me, I'm desperate. I've been trying all night. The problem I have is this: Weird NoClassDef-s with Eclipse Jetty's Maven plugin
Basically: I can't make recent versions of the Jetty plug-in to work properly in an integration test. Indeed, everything works fine until the Jetty's shutdown stage, when I'm told that org.eclipse.jetty.util.FutureCallback is missing.
I've included the dependencies told in the link above. Initially they were ignored, then I've added them in project/build/extensions. Now I've several other ClassNotFoundExceptions and I can't fix that.
This is what I have in my POM:
<plugins>
<!-- This is activated before tests and uses the overlay import mechanism -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<systemProperties>
<!-- Triggers test data creation in uk.ac.ebi.fg.myequivalents.webservices.server.test.WebTestDataInitializer -->
<systemProperty>
<name>uk.ac.ebi.fg.myequivalents.test_flag</name>
<value>true</value>
</systemProperty>
</systemProperties>
<scanIntervalSeconds>10</scanIntervalSeconds>
<useTestScope>true</useTestScope>
<httpConnector>
<!-- 8080 is often busy on EBI hosts -->
<port>10973</port>
</httpConnector>
<stopPort>10974</stopPort>
<stopKey>KILL</stopKey>
</configuration>
<executions>
<!--
starts jetty before tests and stops it afterwards. Note that no stop goal is needed, it magically stops
after tests
-->
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
And these are the extesions I've set up:
<extensions>
<extension>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
</extension>
<extension>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>${jetty.version}</version>
</extension>
<extension>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<version>${jetty.version}</version>
</extension>
<extension>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jaspi</artifactId>
<version>${jetty.version}</version>
</extension>
</extensions>
${jetty.version} is defined in the parent and = 9.1.3.v20140225, but I've tried many, down to 7.x
Moreover, Maven is 3.2.1, Java is 1.7.0_51, running on OS X 10.9.2
Thank you in advance for any help for this nasty issue.
I've found it!!! Apparently, the problem is the 'stop' goal is (rightly) attached to the 'post-integration-test' phase. So, if you issue 'mvn integration-test', such phase, as far as I understand, is not reached (http://tinyurl.com/omwulm5). By just giving 'mvn verify' or 'install', and without adding any Jetty-related dependency to the POM (everything needed should now be included in 9.1.x), Maven completed without any complaint (hooray!).
This might look silly to readers smarter than me, I'm reporting it nonetheless, just in case you're struggling as much as I've just done for hours.
You should not be using the "run" goal with an execution binding. Instead, you should be using the "start" goal. See the documentation here: http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#jetty-start-goal
The difference is that the "run" goal will run a fresh build up until the "test-compile" phase. The "start" goal does not invoke a parallel build and simply runs at whatever phase it is bound to.
Jan
Just try to add <stopWait>10</stopWait> to plugin configuration.
Full configuration you can see in this answer.
I'm using maven and jetty for my web application. I give the command mvn jetty:run to run the maven/jetty which also will load my web application. But the path I get to use to access is http://localhost:8080/filename.jsp while I want it to be http://localhost:8080/myappname/filename.jsp
How to get this done ? Please let me know if I've to post specific files from my web app for you to be able to solve this.
I found other way around at Remove application name after localhost in jetty
From these docs: http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#jetty-run-goal
I think you just need to configure the contextPath in your pom.xml:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/test</contextPath>
</webApp>
</configuration>
</plugin>
I am using Maven with Jetty / Tomcat. My pom.xml declares the ID of my application as <artifactId>webapp</artifactId>. Consequently, all my webapp source is located in src/main/java/webapp. Now, whenever I run any of the webserver, my URL looks like this:
http://localhost:8080/webapp/index.html
and I haven't found a clue that tells me how to get rid of the application or dir name and make the URL look like this:
http://localhost:8080/index.html
Any hints?
Couple of ways you could do this:
In Tomcat, rename the webapp.war to ROOT.war (note the capitalization)
Configure Apache on top of that and create a rewrite rule for pointing root to correct webapp.
Use Jetty's contextPath
Assuming you mean using the jetty:run and tomcat:run mojos (if not, please specify what you mean):
In Jetty, use the contextPath argument:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<!-- version omitted -->
<configuration>
<contextPath>/</contextPath>
<!-- other config -->
</configuration>
</plugin>
In Tomcat it's the path argument
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<!-- Version omitted -->
<configuration>
<path>/</path>
<!-- Other configuration -->
</configuration>
</plugin>