Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #19789 > unrolled thread
| Started by | Laura Schmidt <ls@mailinator.com> |
|---|---|
| First post | 2012-11-18 17:53 +0100 |
| Last post | 2012-11-19 09:41 -0500 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.java.programmer
problem creating WAR file with ant Laura Schmidt <ls@mailinator.com> - 2012-11-18 17:53 +0100
Re: problem creating WAR file with ant Arne Vajhøj <arne@vajhoej.dk> - 2012-11-18 12:01 -0500
Re: problem creating WAR file with ant Laura Schmidt <ls@mailinator.com> - 2012-11-19 04:21 +0100
Re: problem creating WAR file with ant Lew <lewbloch@gmail.com> - 2012-11-18 20:18 -0800
Re: problem creating WAR file with ant Arne Vajhøj <arne@vajhoej.dk> - 2012-11-19 09:41 -0500
| From | Laura Schmidt <ls@mailinator.com> |
|---|---|
| Date | 2012-11-18 17:53 +0100 |
| Subject | problem creating WAR file with ant |
| Message-ID | <k8b3pr$7k7$1@news.m-online.net> |
Hello,
I have a web project W, which uses a java library L. This "usage" is
based on the eclipse confguration: I just told eclipse that W uses L.
Since then, the java compiler finds the source files of L when compiling W.
I delpoy the web project as a war file using ant:
<target name="buildwar">
<war basedir="war" destfile="myproject.war"
webxml="war/WEB-INF/web.xml">
</war>
When I deploy this war file to a tomcat server, the class files of L are
missing.
I tried to resolve this by adding a symbolic link pointing from
$W/WEB-INF/classes to $L/classes. This worked, but after some rebuilds
this link was deleted somehow. I assume that the contents of
$w/WEB-INF/classes is deleted sometimes by some build procedures.
Then, I tried to add the dependency in the ant file:
<target name="buildwar">
<war ...>
<fileset dir="path/to/L/classes"/>
</war>
</target>
But this also didn't work.
Within the produced war file, the class files of L were in the root
directory. I believe that the class files should be placed into the
WEB-INF/classes directory of the war file.
However, this problem cannot be new and there must be a standard way to
do it. I would be glad if someone can tell me how to do it right.
Thanks
Laura
[toc] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-11-18 12:01 -0500 |
| Message-ID | <50a9144e$0$293$14726298@news.sunsite.dk> |
| In reply to | #19789 |
On 11/18/2012 11:53 AM, Laura Schmidt wrote: > I have a web project W, which uses a java library L. This "usage" is > based on the eclipse confguration: I just told eclipse that W uses L. > Since then, the java compiler finds the source files of L when compiling W. > > I delpoy the web project as a war file using ant: > > <target name="buildwar"> > <war basedir="war" destfile="myproject.war" > webxml="war/WEB-INF/web.xml"> > </war> > > When I deploy this war file to a tomcat server, the class files of L are > missing. > > I tried to resolve this by adding a symbolic link pointing from > $W/WEB-INF/classes to $L/classes. This worked, but after some rebuilds > this link was deleted somehow. I assume that the contents of > $w/WEB-INF/classes is deleted sometimes by some build procedures. > > Then, I tried to add the dependency in the ant file: > > <target name="buildwar"> > <war ...> > <fileset dir="path/to/L/classes"/> > </war> > </target> > > But this also didn't work. > > Within the produced war file, the class files of L were in the root > directory. I believe that the class files should be placed into the > WEB-INF/classes directory of the war file. > > However, this problem cannot be new and there must be a standard way to > do it. I would be glad if someone can tell me how to do it right. The war task has a nested lib element. There is an example at the bottom at: http://ant.apache.org/manual/Tasks/war.html Use that! Arne
[toc] | [prev] | [next] | [standalone]
| From | Laura Schmidt <ls@mailinator.com> |
|---|---|
| Date | 2012-11-19 04:21 +0100 |
| Message-ID | <k8c8ic$vab$1@news.m-online.net> |
| In reply to | #19790 |
On 11/18/2012 06:01 PM, Arne Vajhøj wrote: > On 11/18/2012 11:53 AM, Laura Schmidt wrote: Hi Arne! >> Within the produced war file, the class files of L were in the root >> directory. I believe that the class files should be placed into the >> WEB-INF/classes directory of the war file. >> >> However, this problem cannot be new and there must be a standard way to >> do it. I would be glad if someone can tell me how to do it right. > > The war task has a nested lib element. > > There is an example at the bottom at: > http://ant.apache.org/manual/Tasks/war.html > > Use that! If I use that I''ll have to create a jar file for the library every time I make changes to it. Instead of the lib element I used a symbolic link in the WEB-INF/lib directory of the project pointing to the library's jar file. This is the way I always did it. But now I find it useful to avoid this step by directly including the library's class files, which are located under $L/classes. What about this? If including the class files directly, where in the war file do they belong? Thanks! Laura
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-11-18 20:18 -0800 |
| Message-ID | <916d09c7-5ca5-4f8e-b986-08afd365b738@googlegroups.com> |
| In reply to | #19802 |
Laura Schmidt wrote: >>> Within the produced war file, the class files of L were in the root >>> directory. I believe that the class files should be placed into the >>> WEB-INF/classes directory of the war file. Neither is correct. The JAR of L should be in the lib/ subdirectory within the WAR. RTFM. >>> However, this problem cannot be new and there must be a standard way to >>> do it. I would be glad if someone can tell me how to do it right. There is, and the documentation tells you what it is. >> The war task has a nested lib element. As indeed, a WAR has a nested lib/ subdirectory. As per the docs. >> There is an example at the bottom at: >> http://ant.apache.org/manual/Tasks/war.html >> >> Use that! > If I use that I''ll have to create a jar [sic] file for the library every time > I make changes to it. Yeah, so? Why wouldn't you? You say that like it's an argument against doing things the right way. > Instead of the lib element I used a symbolic link > in the WEB-INF/lib directory of the project pointing to the library's > jar file. This is the way I always did it. It's the wrong way. > But now I find it useful to avoid this step by directly including the > library's class files, which are located under $L/classes. What about this? Terrible idea, and the wrong way to do it. > If including the class files directly, where in the war [sic] file do they belong? They don't. Libraries belong in JAR files. RTFM. Really. You're doing it all ass-backwards. http://www.oracle.com/technetwork/java/javaee/documentation/tutorials-137605.html -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-11-19 09:41 -0500 |
| Message-ID | <50aa450a$0$285$14726298@news.sunsite.dk> |
| In reply to | #19802 |
On 11/18/2012 10:21 PM, Laura Schmidt wrote: > On 11/18/2012 06:01 PM, Arne Vajhøj wrote: >> On 11/18/2012 11:53 AM, Laura Schmidt wrote: >>> Within the produced war file, the class files of L were in the root >>> directory. I believe that the class files should be placed into the >>> WEB-INF/classes directory of the war file. >>> >>> However, this problem cannot be new and there must be a standard way to >>> do it. I would be glad if someone can tell me how to do it right. >> >> The war task has a nested lib element. >> >> There is an example at the bottom at: >> http://ant.apache.org/manual/Tasks/war.html >> >> Use that! > > If I use that I''ll have to create a jar file for the library every time > I make changes to it. You want to do that anyway. You could even say that if it is not in a jar then it is not a library. > Instead of the lib element I used a symbolic link > in the WEB-INF/lib directory of the project pointing to the library's > jar file. This is the way I always did it. That makes the war file tied to your PC. Not a good way. > But now I find it useful to avoid this step by directly including the > library's class files, which are located under $L/classes. What about this? Extracting class files out of libraries jar files is not good as it complicates updating and will confuse people working with it. > If including the class files directly, where in the war file do they > belong? The war task also has a nested classes element. It is all in the docs. Arne
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web