You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Devai Istvan <su...@t-online.hu> on 2008/08/03 13:23:36 UTC

tomcat webapp and eclipse

Dear Sirs,

Currently I'm developing a webapp in eclipse running on a tomcat 
instance. When I edit a .html or a .java file in eclipse, the 
modification can be immediately observed (because Automatic building is 
turned on in Eclipse and I'm using a context file that specifies the 
docbase of the context as the ouput directory of Eclipse).

Now, I'd like to convert the project to use maven and preserve the above 
way of development. How to do this?

The problem is that if I place stuff into the /src/main/webapp 
directory, it does not get copied to /target/classes, which means I 
cannot use target/classes as the docbase of the context.

Since my pom specifies war as a packaging mode, 
/target/myapp-1.0-SNAPSHOT contains the exploded WAR contents. If I 
specify this directory as a docbase for the tomcat context, everything 
works as intended, the only problem is that if I edit something in 
eclipse, the changes will be only visible after doing a mvn package..

Anyone has a solution for this?
What about Jetty, is there a solution for that too?

Best regards,
Istvan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: tomcat webapp and eclipse

Posted by Martin Gainty <mg...@hotmail.com>.
is the file in the repo?
did you apprise eclipse of your maven M2_REPO location?
Goto Window -> Preferences -> Java -> build path -> classpath variable -> New

Name M2_REPO
Path /path/to/your/.m2/repository

http://wiki.foochal.org/index.php/Maven_FAQ#Generating_an_eclipse_project_from_a_maven_project

HTH
Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. 


> Date: Thu, 7 Aug 2008 05:10:09 -0700
> From: eu@md.pp.ru
> To: users@maven.apache.org
> Subject: Re: tomcat webapp and eclipse
> 
> 
> 
> Istvan Devai wrote:
> > 
> > I've tried this. I've configured Jetty as a WTP server and added a Jetty 
> > context file to point to /target/myapp-1.0-SNAPSHOT. It worked, however, 
> > if I edited a random .html file in Eclipse, these changes were not 
> > copied to /target/myapp-1.0-SNAPSHOT, only after I ran mvn package.
> > How would you automate this? Maybe using one of the maven eclipse plugins?
> > 
> 
>   If you are doing your development with Eclipse and WTP, you may want to
> consider to look at Maven integration for Eclipse, such as m2eclipse.
> http://m2eclipse.codehaus.org/
> 
>   See, for example, WTP mini how to at
> http://docs.codehaus.org/display/M2ECLIPSE/WTP+mini+howto
> 
>   regards,
>   Eugene
> 
> 
> -- 
> View this message in context: http://www.nabble.com/tomcat-webapp-and-eclipse-tp18805558p18868985.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

_________________________________________________________________
Got Game? Win Prizes in the Windows Live Hotmail Mobile Summer Games Trivia Contest
http://www.gowindowslive.com/summergames?ocid=TXT_TAGHM

Re: tomcat webapp and eclipse

Posted by Eugene Kuleshov <eu...@md.pp.ru>.

Istvan Devai wrote:
> 
> I've tried this. I've configured Jetty as a WTP server and added a Jetty 
> context file to point to /target/myapp-1.0-SNAPSHOT. It worked, however, 
> if I edited a random .html file in Eclipse, these changes were not 
> copied to /target/myapp-1.0-SNAPSHOT, only after I ran mvn package.
> How would you automate this? Maybe using one of the maven eclipse plugins?
> 

  If you are doing your development with Eclipse and WTP, you may want to
consider to look at Maven integration for Eclipse, such as m2eclipse.
http://m2eclipse.codehaus.org/

  See, for example, WTP mini how to at
http://docs.codehaus.org/display/M2ECLIPSE/WTP+mini+howto

  regards,
  Eugene


-- 
View this message in context: http://www.nabble.com/tomcat-webapp-and-eclipse-tp18805558p18868985.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: tomcat webapp and eclipse

Posted by Istvan Devai <is...@istvandevai.com>.
Hi Johan,

I've tried this. I've configured Jetty as a WTP server and added a Jetty 
context file to point to /target/myapp-1.0-SNAPSHOT. It worked, however, 
if I edited a random .html file in Eclipse, these changes were not 
copied to /target/myapp-1.0-SNAPSHOT, only after I ran mvn package.
How would you automate this? Maybe using one of the maven eclipse plugins?

Regards,
Istvan

Johan Eltes wrote:
> Wtp and the maven plugin for eclipse works for me.
>
> Prereqs: wtp1.5, 2.x or 3.x
>
> 1. Define classpath variable M2_REPO in eclipse, pointing to your 
> maven repo.
>
> 2. Run mvn command...
> mvn -U -Dwtpversion=1.5 eclipse:clean eclipse:eclipse
>
> 3. Import the generated project into eclipse
>
> Ready to go!
> Re-run ...
> mvn -Dwtpversion=1.5 eclipse:eclipse
> ...every time the pom has changed. This Can be automated by a builder 
> in eclipse.
>
> /Johan
>
>
> Aug 3, 2008 kl. 13:23 skrev Devai Istvan <su...@t-online.hu>:
>
>> Dear Sirs,
>>
>> Currently I'm developing a webapp in eclipse running on a tomcat 
>> instance. When I edit a .html or a .java file in eclipse, the 
>> modification can be immediately observed (because Automatic building 
>> is turned on in Eclipse and I'm using a context file that specifies 
>> the docbase of the context as the ouput directory of Eclipse).
>>
>> Now, I'd like to convert the project to use maven and preserve the 
>> above way of development. How to do this?
>>
>> The problem is that if I place stuff into the /src/main/webapp 
>> directory, it does not get copied to /target/classes, which means I 
>> cannot use target/classes as the docbase of the context.
>>
>> Since my pom specifies war as a packaging mode, 
>> /target/myapp-1.0-SNAPSHOT contains the exploded WAR contents. If I 
>> specify this directory as a docbase for the tomcat context, 
>> everything works as intended, the only problem is that if I edit 
>> something in eclipse, the changes will be only visible after doing a 
>> mvn package..
>>
>> Anyone has a solution for this?
>> What about Jetty, is there a solution for that too?
>>
>> Best regards,
>> Istvan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: tomcat webapp and eclipse

Posted by Johan Eltes <jo...@callistaenterprise.se>.
Wtp and the maven plugin for eclipse works for me.

Prereqs: wtp1.5, 2.x or 3.x

1. Define classpath variable M2_REPO in eclipse, pointing to your  
maven repo.

2. Run mvn command...
mvn -U -Dwtpversion=1.5 eclipse:clean eclipse:eclipse

3. Import the generated project into eclipse

Ready to go!
Re-run ...
mvn -Dwtpversion=1.5 eclipse:eclipse
...every time the pom has changed. This Can be automated by a builder  
in eclipse.

/Johan


Aug 3, 2008 kl. 13:23 skrev Devai Istvan <su...@t-online.hu>:

> Dear Sirs,
>
> Currently I'm developing a webapp in eclipse running on a tomcat  
> instance. When I edit a .html or a .java file in eclipse, the  
> modification can be immediately observed (because Automatic building  
> is turned on in Eclipse and I'm using a context file that specifies  
> the docbase of the context as the ouput directory of Eclipse).
>
> Now, I'd like to convert the project to use maven and preserve the  
> above way of development. How to do this?
>
> The problem is that if I place stuff into the /src/main/webapp  
> directory, it does not get copied to /target/classes, which means I  
> cannot use target/classes as the docbase of the context.
>
> Since my pom specifies war as a packaging mode, /target/myapp-1.0- 
> SNAPSHOT contains the exploded WAR contents. If I specify this  
> directory as a docbase for the tomcat context, everything works as  
> intended, the only problem is that if I edit something in eclipse,  
> the changes will be only visible after doing a mvn package..
>
> Anyone has a solution for this?
> What about Jetty, is there a solution for that too?
>
> Best regards,
> Istvan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: tomcat webapp and eclipse

Posted by Kalle Korhonen <ka...@gmail.com>.
Both Q4E and m2eclipse plugins (for Maven support in Eclipse) do resource
filtering. I suppose you could point to the webapp target directory for
src/main/webapp and then use that as a context, but in general I think
filtering all of your webapp resource files is a bad idea (because I imagine
it'd be slow and error-prone as your app grows). This is obviously web
framework dependent but for example with Tapestry, you wouldn't need to
filter the resources but the framework would allow to set the context path
for resources that need it. In a traditional servlet/jsp-environment, a CSS
file could be a JSP file.

Kalle


On Mon, Aug 4, 2008 at 12:38 AM, Istvan Devai <is...@istvandevai.com>wrote:

> Hi Kalle,
>
> Thank you for your reply.
>
> Yesterday I spent a few hours tinkering with various setups and realized
> that mvn jetty:run basically works in the way you described below (classes
> from /target/classes, webapp resources from /src/main/webapp). This works
> nicely, and - as you kindly describe - could be a working setup for Tomcat,
> too.
>
> My only problem with this setup, is that the servlet container sees the
> unfiltered resources in the webapp directory. Imagine I've got a .css file
> in webapp, and in the CSS file, i've got an absolute path to an image. I
> would like to have a filter variable for the servlet context, so the CSS
> file will work in various deployment environments..
>
> Another possibility would be to start Jetty with mvn jetty:run-exploded
> which would use the directory /target/myapp-1.0-SNAPSHOT (the extracted war
> contents). However, the problem with this one is that when I edit a file in
> Eclipse, the changes will not be copied to this directory, only to
> /target/classes, etc. Which means, that Jetty (or Tomcat if run with
> war-exploded) won't pick up the changes until I issue a mvn package).
> Maybe a solution could be to write a shell script that monitors the
> /src/main folder and if there is any change, automatically runs mvn package?
> (which will update /target/myapp-1.0-SNAPSHOT contents with filtered
> resources, new classfiles, etc.)
>
> Best regards,
> Istvan
>
>
> Kalle Korhonen wrote:
>
>> If you use Sysdeo's Eclipse Tomcat Launcher plugin (
>> http://www.eclipsetotale.com/tomcatPlugin.html) and its devloader, you
>> can
>> point to src/main/webapp for context, pick up the class files from
>> target/classes and the libraries from your local m2 repo directories. It's
>> both faster and more reliable than Eclipse WTP's built-in container
>> support.
>> There's also http://merve.sourceforge.net/, which offers less options
>> than
>> Sysdeo's but is more automatic. Similarly for Jetty you can use
>> run-jetty-run (http://code.google.com/p/run-jetty-run/). I never create a
>> war while developing a webapp and I even try to avoid container restarts
>> (several solutions exist for hot-code swapping depending on your web
>> framework and platform).
>>
>> Kalle
>>
>>
>> On Sun, Aug 3, 2008 at 4:23 AM, Devai Istvan <su...@t-online.hu> wrote:
>>
>>
>>
>>> Dear Sirs,
>>>
>>> Currently I'm developing a webapp in eclipse running on a tomcat
>>> instance.
>>> When I edit a .html or a .java file in eclipse, the modification can be
>>> immediately observed (because Automatic building is turned on in Eclipse
>>> and
>>> I'm using a context file that specifies the docbase of the context as the
>>> ouput directory of Eclipse).
>>>
>>> Now, I'd like to convert the project to use maven and preserve the above
>>> way of development. How to do this?
>>>
>>> The problem is that if I place stuff into the /src/main/webapp directory,
>>> it does not get copied to /target/classes, which means I cannot use
>>> target/classes as the docbase of the context.
>>>
>>> Since my pom specifies war as a packaging mode,
>>> /target/myapp-1.0-SNAPSHOT
>>> contains the exploded WAR contents. If I specify this directory as a
>>> docbase
>>> for the tomcat context, everything works as intended, the only problem is
>>> that if I edit something in eclipse, the changes will be only visible
>>> after
>>> doing a mvn package..
>>>
>>> Anyone has a solution for this?
>>> What about Jetty, is there a solution for that too?
>>>
>>> Best regards,
>>> Istvan
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: tomcat webapp and eclipse

Posted by Istvan Devai <is...@istvandevai.com>.
Hi Kalle,

Thank you for your reply.

Yesterday I spent a few hours tinkering with various setups and realized 
that mvn jetty:run basically works in the way you described below 
(classes from /target/classes, webapp resources from /src/main/webapp). 
This works nicely, and - as you kindly describe - could be a working 
setup for Tomcat, too.

My only problem with this setup, is that the servlet container sees the 
unfiltered resources in the webapp directory. Imagine I've got a .css 
file in webapp, and in the CSS file, i've got an absolute path to an 
image. I would like to have a filter variable for the servlet context, 
so the CSS file will work in various deployment environments..

Another possibility would be to start Jetty with mvn jetty:run-exploded 
which would use the directory /target/myapp-1.0-SNAPSHOT (the extracted 
war contents). However, the problem with this one is that when I edit a 
file in Eclipse, the changes will not be copied to this directory, only 
to /target/classes, etc. Which means, that Jetty (or Tomcat if run with 
war-exploded) won't pick up the changes until I issue a mvn package).
Maybe a solution could be to write a shell script that monitors the 
/src/main folder and if there is any change, automatically runs mvn 
package? (which will update /target/myapp-1.0-SNAPSHOT contents with 
filtered resources, new classfiles, etc.)

Best regards,
Istvan

Kalle Korhonen wrote:
> If you use Sysdeo's Eclipse Tomcat Launcher plugin (
> http://www.eclipsetotale.com/tomcatPlugin.html) and its devloader, you can
> point to src/main/webapp for context, pick up the class files from
> target/classes and the libraries from your local m2 repo directories. It's
> both faster and more reliable than Eclipse WTP's built-in container support.
> There's also http://merve.sourceforge.net/, which offers less options than
> Sysdeo's but is more automatic. Similarly for Jetty you can use
> run-jetty-run (http://code.google.com/p/run-jetty-run/). I never create a
> war while developing a webapp and I even try to avoid container restarts
> (several solutions exist for hot-code swapping depending on your web
> framework and platform).
>
> Kalle
>
>
> On Sun, Aug 3, 2008 at 4:23 AM, Devai Istvan <su...@t-online.hu> wrote:
>
>   
>> Dear Sirs,
>>
>> Currently I'm developing a webapp in eclipse running on a tomcat instance.
>> When I edit a .html or a .java file in eclipse, the modification can be
>> immediately observed (because Automatic building is turned on in Eclipse and
>> I'm using a context file that specifies the docbase of the context as the
>> ouput directory of Eclipse).
>>
>> Now, I'd like to convert the project to use maven and preserve the above
>> way of development. How to do this?
>>
>> The problem is that if I place stuff into the /src/main/webapp directory,
>> it does not get copied to /target/classes, which means I cannot use
>> target/classes as the docbase of the context.
>>
>> Since my pom specifies war as a packaging mode, /target/myapp-1.0-SNAPSHOT
>> contains the exploded WAR contents. If I specify this directory as a docbase
>> for the tomcat context, everything works as intended, the only problem is
>> that if I edit something in eclipse, the changes will be only visible after
>> doing a mvn package..
>>
>> Anyone has a solution for this?
>> What about Jetty, is there a solution for that too?
>>
>> Best regards,
>> Istvan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: tomcat webapp and eclipse

Posted by Kalle Korhonen <ka...@gmail.com>.
If you use Sysdeo's Eclipse Tomcat Launcher plugin (
http://www.eclipsetotale.com/tomcatPlugin.html) and its devloader, you can
point to src/main/webapp for context, pick up the class files from
target/classes and the libraries from your local m2 repo directories. It's
both faster and more reliable than Eclipse WTP's built-in container support.
There's also http://merve.sourceforge.net/, which offers less options than
Sysdeo's but is more automatic. Similarly for Jetty you can use
run-jetty-run (http://code.google.com/p/run-jetty-run/). I never create a
war while developing a webapp and I even try to avoid container restarts
(several solutions exist for hot-code swapping depending on your web
framework and platform).

Kalle


On Sun, Aug 3, 2008 at 4:23 AM, Devai Istvan <su...@t-online.hu> wrote:

> Dear Sirs,
>
> Currently I'm developing a webapp in eclipse running on a tomcat instance.
> When I edit a .html or a .java file in eclipse, the modification can be
> immediately observed (because Automatic building is turned on in Eclipse and
> I'm using a context file that specifies the docbase of the context as the
> ouput directory of Eclipse).
>
> Now, I'd like to convert the project to use maven and preserve the above
> way of development. How to do this?
>
> The problem is that if I place stuff into the /src/main/webapp directory,
> it does not get copied to /target/classes, which means I cannot use
> target/classes as the docbase of the context.
>
> Since my pom specifies war as a packaging mode, /target/myapp-1.0-SNAPSHOT
> contains the exploded WAR contents. If I specify this directory as a docbase
> for the tomcat context, everything works as intended, the only problem is
> that if I edit something in eclipse, the changes will be only visible after
> doing a mvn package..
>
> Anyone has a solution for this?
> What about Jetty, is there a solution for that too?
>
> Best regards,
> Istvan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>