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>
Related
I am having maven web project with name XYZwebApp and i generated war inside that as ABCWebApp while running the project as (Right click -->Run As--> Run on Server)
it shows the XYZwebApp in the configured AddorRemove window
And also after running the application its opening the 404 page with the url http://localhost:9090/ABCWebApp/
But if i am changing the url as http://localhost:9090/XYZWebApp/ its working fine.
Above thing is happening in Jboss server in eclipse, i need application should be working fine with this url http://localhost:9090/ABCWebApp/
But the above problem is not happing when i start the server in cmd and pasting the war in webapps folder is working fine.
Confused by this issue, please help me why it is happening and how to resolve.
Give comments if you need more input.
i added path as ABCWebApp doesnt work and
i changed name as ABCWebApp doesnt work.
My pom.xml is
<artifactId>XYZwebApp</artifactId>
<packaging>war</packaging>
<name>ABCWebApp</name>
<build>
<finalName>ABCWebApp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<path>/ABCWebApp</path>
</configuration>
</plugin>
</plugins>
</build>
have you configured the context root correctly? Eclipse>WarProject>Properties>Web>Context Root
Double-click on the tomcat server on which you are deploying you application in Servers view, go to modules tab and check the Path for the application is correct as you need. If it is not then select and edit the path, save it and re-run the application (Right click -->Run As--> Run on Server).
Edit 1:
Modules tab and path to edit can be found highlighted in below image,
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>
It seems Maven keep using use an old version of my code when packaging a war archive.
I build my war using a simple "mvn clean install".
I deleted the /target folder by hand and checked that there were no .class elsewhere in my project (as described here).
Each time I check the generated archive, an old version of my code has been packaged inside. Yet, the same code is properly packaged on my colleague's machine (he uses m2e).
Does anyone have the same problem ?
Here is the most relevant part of the POM:
<packaging>war</packaging>
...
<build>
<plugins>
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</build>
It appears that the old code is still present somewhere; my guess would be your local repository. Try deleting any entry there that could contain the old code and then building your project again.
Check the <dependency> entry in pom.xml for that jar file. Change the <version> of that dependency to the latest one.
What I do is:
Create a new project with IntelliJ with Maven module.
Add Framework support to this project and pick: JSF.
Go to pom.xml and add: packaging: war.
And from Maven window in IntelliJ I click: Clean Install.
Well build fails, because maven is looking for a webapp directory instead of a directory called web. For building the project.
So, if I rename the folder web to webapp build goes fine.
However, I want to learn more about IntelliJ and maven, so I want to force maven to use the folder web. How can I properly do this
Using the command line? I mean without invvolving IntelliJ at all?
Using Intellij?
Regards.
You can configure this in the pom.xml file for your project.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>web</warSourceDirectory>
</configuration>
</plugin>
</plugins>
You can find the documentation here
If IntelliJ behaves as expected, it should pick up this new configuration.
Have a look at this post, which explains how to change the default webapp directory:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>web</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
Well I'm running Eclipse with Tomcat runtime environment (it is run from Eclipse) and I've recently turned my web project to Maven project. Now it finally compiles well, however when I try running it on server it doesn't seem to load the compiled classes and hibernate configuration files to the Tomcat working directory in :
**D:\Dropbox\EclipseWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\myProject**
So I have to copy all the compiled classes and practically all the missing files manually everytime I now change anything...
Can I change anything in Eclipse settings? Also where should I output my compiled classes from Maven? At the moment the build in pom.xml looks like this:
<build>
<sourceDirectory>src/</sourceDirectory>
<directory>${basedir}/build</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Can anyone help me with this? Thanks in advance.