You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by ju...@hsbc.ca on 2006/09/30 02:55:29 UTC

[M2] Where to place servlet code in a WAR project?

In my web project, I have the following:

src
----main
--------java
-------------com/my/package/MyServlet
--------webapp
------------*.jsp
------------WEB-INF

In the WAR file that is generated, MyServlet ends up in a folder called 
imported_classes. It cannot be reference after I deploy my WAR as it is 
not in the classpath. Can anybody please advise how I would go about 
making it visible and what the point of having a src/main/java/... path 
would be in a web project?

Thanks,

-j

---------------------------------------------------
Justin Fung
justin_fung@hsbc.ca
Consultant, Business Systems
IT Banking Systems, e-Business
HSBC Bank Canada
http://www.hsbc.ca
p: (604) 643-6605
f: (604) 643-6727

***************************************************************
This email may contain confidential information, and is intended only for the named recipient and may be privileged. Distribution or copying of this email by anyone other than the named recipient is prohibited. If you are not the named recipient, please notify us immediately and permanently destroy this email and all copies of it. Internet email is not private, secure, or reliable.  No member of the HSBC Group is liable for any errors or omissions in the content or transmission of this email. Any opinions contained in this email are solely those of the author and, unless clearly indicated otherwise in writing, are not endorsed by any member of the HSBC Group.
***************************************************************
Ce courriel peut renfermer des renseignements confidentiels et privil�gi�s et s'adresse au destinataire d�sign� seulement.   La distribution ou la copie de ce courriel par toute personne autre que le destinataire d�sign� est interdite.  Si vous n'�tes pas le destinataire d�sign�, veuillez nous en aviser imm�diatement et d�truire de fa�on permanente ce courriel ainsi que toute copie de celui-ci. La transmission de courriel par Internet ne constitue pas un mode de transmission confidentiel, s�curitaire ou fiable. Aucun membre du Groupe HSBC ne sera responsable des erreurs ou des omissions relatives au contenu ou � la transmission de ce courriel.  L'auteur de ce courriel est seul responsable des opinions �mises dans ce courriel, lesquelles, � moins  d'un avis contraire fourni par �crit, ne sont pas endoss�es par aucun membre du Groupe HSBC.
***************************************************************

"SAVE PAPER - THINK BEFORE YOU PRINT!"

"�CONOMISEZ LE PAPIER � PENSEZ-Y � DEUX FOIS AVANT D'IMPRIMER!"


Re: [M2] Where to place servlet code in a WAR project?

Posted by Neeraj Bisht <ne...@daffodildb.com>.
put your servlet class inside src/main/java and check your pom
On 9/30/06, Owen Jacobson <an...@gmail.com> wrote:
>
> On 9/29/06, Max Cooper <ma...@maxcooper.com> wrote:
> > Justin,
> >
> > I am not sure where the "imported_classes" directory is coming from.
> > That is not the normal behavior for Maven.
> >
> > Normally, the setup you describe would result in the sources from
> > src/main/java being compiled into WEB-INF/classes inside the war file.
> > However, be aware that I *DON'T* mean src/main/webapp/WEB-INF/classes.
> > All the files produced during the build (including .class files) end up
> > inside the "target" dir.
> >
> > Search your pom.xml file for the string "imported_classes". Perhaps you
> > adapted your pom.xml from another project and inherited an unwanted
> setting.
>
> Agreed.  Examine the pom and all parent poms to see if one of them is
> reconfiguring either the javac plugin or the war plugin.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: [M2] Where to place servlet code in a WAR project?

Posted by Owen Jacobson <an...@gmail.com>.
On 9/29/06, Max Cooper <ma...@maxcooper.com> wrote:
> Justin,
>
> I am not sure where the "imported_classes" directory is coming from.
> That is not the normal behavior for Maven.
>
> Normally, the setup you describe would result in the sources from
> src/main/java being compiled into WEB-INF/classes inside the war file.
> However, be aware that I *DON'T* mean src/main/webapp/WEB-INF/classes.
> All the files produced during the build (including .class files) end up
> inside the "target" dir.
>
> Search your pom.xml file for the string "imported_classes". Perhaps you
> adapted your pom.xml from another project and inherited an unwanted setting.

Agreed.  Examine the pom and all parent poms to see if one of them is
reconfiguring either the javac plugin or the war plugin.

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


Re: [M2] Where to place servlet code in a WAR project?

Posted by Max Cooper <ma...@maxcooper.com>.
Justin,

I am not sure where the "imported_classes" directory is coming from. 
That is not the normal behavior for Maven.

Normally, the setup you describe would result in the sources from 
src/main/java being compiled into WEB-INF/classes inside the war file. 
However, be aware that I *DON'T* mean src/main/webapp/WEB-INF/classes. 
All the files produced during the build (including .class files) end up 
inside the "target" dir.

Search your pom.xml file for the string "imported_classes". Perhaps you 
adapted your pom.xml from another project and inherited an unwanted setting.

Are you using an IDE? Maybe it is compiling the sources to that location.

Here is a link to the maven-war-plugin documentation, which is very 
helpful for setting up a war project in maven (or figuring out why a war 
project isn't building the way you expect it to):
http://maven.apache.org/plugins/maven-war-plugin/

src/main/java is the standard location for Java sources in Maven. If you 
are asking "why not in src/main/webapp/WEB-INF/src (or similar)?", I 
have two responses:
* most projects don't want their source code in the war file structure
* using the Maven standard location means you can use all the Maven 
reports, etc. without having to configure a "custom" location

-Max

justin_fung@hsbc.ca wrote:
> In my web project, I have the following:
> 
> src
> ----main
> --------java
> -------------com/my/package/MyServlet
> --------webapp
> ------------*.jsp
> ------------WEB-INF
> 
> In the WAR file that is generated, MyServlet ends up in a folder called 
> imported_classes. It cannot be reference after I deploy my WAR as it is 
> not in the classpath. Can anybody please advise how I would go about 
> making it visible and what the point of having a src/main/java/... path 
> would be in a web project?
> 
> Thanks,
> 
> -j
> 
> ---------------------------------------------------
> Justin Fung
> justin_fung@hsbc.ca
> Consultant, Business Systems
> IT Banking Systems, e-Business
> HSBC Bank Canada
> http://www.hsbc.ca
> p: (604) 643-6605
> f: (604) 643-6727
> 
> ***************************************************************
> This email may contain confidential information, and is intended only for the named recipient and may be privileged. Distribution or copying of this email by anyone other than the named recipient is prohibited. If you are not the named recipient, please notify us immediately and permanently destroy this email and all copies of it. Internet email is not private, secure, or reliable.  No member of the HSBC Group is liable for any errors or omissions in the content or transmission of this email. Any opinions contained in this email are solely those of the author and, unless clearly indicated otherwise in writing, are not endorsed by any member of the HSBC Group.
> ***************************************************************
> Ce courriel peut renfermer des renseignements confidentiels et privilégiés et s'adresse au destinataire désigné seulement.   La distribution ou la copie de ce courriel par toute personne autre que le destinataire désigné est interdite.  Si vous n'êtes pas le destinataire désigné, veuillez nous en aviser immédiatement et détruire de façon permanente ce courriel ainsi que toute copie de celui-ci. La transmission de courriel par Internet ne constitue pas un mode de transmission confidentiel, sécuritaire ou fiable. Aucun membre du Groupe HSBC ne sera responsable des erreurs ou des omissions relatives au contenu ou à la transmission de ce courriel.  L'auteur de ce courriel est seul responsable des opinions émises dans ce courriel, lesquelles, à moins  d'un avis contraire fourni par écrit, ne sont pas endossées par aucun membre du Groupe HSBC.
> ***************************************************************
> 
> "SAVE PAPER - THINK BEFORE YOU PRINT!"
> 
> "ÉCONOMISEZ LE PAPIER – PENSEZ-Y À DEUX FOIS AVANT D'IMPRIMER!"
> 
> 

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