Adding Tomcat server remotely to Eclipse IDE - java

Normally in Eclipse we run, Tomcat v7.0 Server at localhost
Can we add a tomcat which is located remotely on another IP address?
Currently, I'm running programs in Windows. I need it to be run with tomcat server which is located on another IP address on Linux.

Convert your web project to Maven Project and copy and paste the below code to your pom file.
<project ...>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<url>http://yourhost:8080/manager/text</url>
</configuration>
</plugin>
</plugins>
</build>
</project>

Convert your web project to Maven Project and copy and paste the below code to your pom file.
org.apache.tomcat.maventomcat7-maven-plugin2.1http://yourhost:8080/manager/text
Yes the above code is working you need to configure remote ip to url section.

Related

How to access tomcat page when using tomcat maven plugin

I have created a SOAP service and using tomcat maven plugin for deploying in tomcat server.
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- <contextFile>${basedir}/src/main/webapp/META-INF/context.xml</contextFile> -->
</configuration>
</plugin>
</plugins>
</build>
I am able to start application and able to get wsdl also when using this end point - http://localhost:8080/soapapptest
everything is working, but when I used this endpoint http://localhost:8080 for getting tomcat home page then I got below page.
how I will get the tomcat home page where I can see my deployed war?
After starting application I am getting following logs
The home page is an application that gets deployed to the "ROOT" context. You'll find it in the downloadable Tomcat .tar.gz and .zip files. Unless your pom.xml deploys an application as ROOT, you are supposed to get a 404 response for /.

Converting Eclipse dynamic web project to maven project with modules

so I just started a new project at work where I've gotten some code, really strange code...
So the project structure was as follows:
simple-java-project-1 ---> eclipse java project which holds some database-connectors
simple-java-project-2 ---> holds the logic of converting, formatting etc of the data, uses the connectors from project-1
dynamic-web-project --> just gets the jars from project1 and project2 and offer's a websocket api to send this data etc.
I would like to convert this mess to a well structured maven project. So I created a master maven project with this pom:
......bla bla bla....
<modules>
<module>the-connectors</module>
<module>the-logic</module>
<module>the-dynamic-web-module</module>
</modules>
<dependencies>.....</dependencies/>
And the modules as well. I added the dependencies needed to them.
So now the hard part I didn't get : How can I achive that the whole project is deployed to the local tomcat and runs?
The web.xml and /WEB-INF/ stuff is in the "the-dynamic-web-module" module for now,...
Any ideas or hints?Thanks in advance.
You should add the tomcat7-maven-plugin to your the-dynamic-web-module:
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<uriEncoding>UTF-8</uriEncoding>
<systemProperties>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
After building and installing the 2 other modules (mvn install), go to the-dynamic-web-module and launch mvn tomcat7:run. Then with your browser, go to localhost:8080/ and you should get your app.

Maven War Plugin Websphere

I am trying to get a Rational Application Developer project to run on a websphere server. I am trying to get the maven-war-plugin to work. However, when trying to start the server, websphere can not find the UI Files. I have my plugin here:
<build>
<outputDirectory>${project.basedir}\WebContent\WEB-INF\classes</outputDirectory>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webXml>/WebContent/WEB-INF/web.xml</webXml>
<webappDirectory>WebContent</webappDirectory>
<source>/codeCoverageUI2/src/</source>
<encoding>utf-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
I feel the issue is with my webappDirectory but I do not know what else to put it to, besides the location of all my UI files.
Anyone have some insight?
I am assuming you are using WebSphere Classic V8 or earlier?
What we recommend because when developing a project in RAD/WDT, WAS Classic requires building the project in a "Single Root" structure. Add the following to your pom:
<build>
<outputDirectory>${project.basedir}\WebContent\WEB-INF\classes</outputDirectory>
<finalName>${project.name}</finalName>
...
This will build your source within the Web content folder. (Make sure you do a Project -> "Maven" -> "Update Project...") then rebuild...

maven adds version number to war - won't deploy

I'm using maven to build a war file for JBOSS AS 7. After a maven deploy, there is 'test.war' in the local repository, and a 'test-2.war' in the remote repository. This is all as expected (2 is the version in the POM).
If I manually deploy the 'test.war', everything works fine. If I deploy 'test-2.war' the deployment fails. If I rename 'test-2.war' to be 'test.war', the deployment works but trying to access it in a browser fails with error:
type Status report
message /test/Test
description The requested resource (/test/Test) is not available.
Since both war files are the result of the same maven build and deploy, why doesn't renaming the -2 version work the same as the first?
Is there a way I can deploy the -2 version without renaming, or what can I do to force the build so that I can rename the -2 version and have it deploy?
I know I can use maven's jboss deploy, but that's not an option in my case. I need the war file from the remote repository for manual deployments.
EDIT: The basic question here is why can't I rename the file {artifactId}-{version}.war to just {artifactId}.war and have it deploy in JBoss AS 7 properly?
You can rename the war like this:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>bird.war</warName>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
OR
<build>
<finalName>bird.war</finalName>
. . .
</build>
Take a look here

Start a web container then deploy a war with cargo maven2 plugin

I tried to use cargo-maven2-plugin to automate my WAR module deployment for testing.
I wonder how can I start the tomcat server (pre-installed in my machine) and deploy my war to the started server automatically?
Documentation from Cargo project mentions that cargo:start goal can optionally deploy deployables:
http://cargo.codehaus.org/Maven2+plugin#Maven2plugin-gettingstarted
cargo:start Start a container. That task can optionally install and configure a container; it can also optionally deploy deployables (WAR, EAR, etc.) to it.
However, I have no idea how to enable this option to make it deploy deployables when running cargo:start.
Here is my current pom configuration:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<wait>true</wait>
<container>
<containerId>tomcat6x</containerId>
<home>${tomcat.home}</home>
</container>
<configuration>
<type>standalone</type>
<home>target/tomcat6x</home>
</configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>my-war</artifactId>
<type>war</type>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>my-war</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
When I run "mvn cargo:start", the tomcat server will be started, however, the my-war deployable won't be deployed. And I have to run "mvn cargo:deploy" from another shell to deploy this war.
OK -- There are a few things going on here:
1) You mention that the Tomcat server is pre-installed on the machine, but yet you have the directory specified in your target directory. This is not a good idea as that will get wiped out after a mvn clean.
2) For pre-installed Tomcat you are not setting the type to existing inside the deployer configuration.
3) Where is your context definition? Do you have a context fragment file or are you using a tomcat.xml file inside the WEB-INF directory in the WAR?
Bottom line a combination of configuration errors are holding you back. Post an updated Maven configuration and addition details about the XML context definition and I can help you further.

Categories