在我的开发团队中,我们有框架和业务开发人员。
该框架已经是一个JEE6 webapp,业务开发人员使用该框架通过框架提供的Web界面构建他们的网页,并中调对业务服务的调用。
每个业务应用程序都构建为外部JAR文件,该文件将添加到tomcat启动类路径中。此外,它们是eclipse中的“Web Fragment Projects”(WFP),因为它也可以添加自定义JSP,HTML,CSS等等,还有一些使用web-fragment.xml。
到目前为止,这么好,在日食之外一切都很好......
在eclipse中,使用WFP和框架作为“动态Web项目”(DWP),一切都很好......
但是对于业务开发人员,我想在eclipse中创建Tomcat服务器并直接将其指向WAR并使其部署WFP。
我尝试在.launch文件中将WFP添加到classpath中,我还尝试在tomcat“VirtualWebappLoader”中添加bin dir,但是web-fragment.xml无法读取。
如何实现它的任何线索???
Ps:在eclipse外运行tomcat并远程调试WFP不是一种选择。
答案 0 :(得分:2)
This is an old thread and it it seems I'm the only one with this scenario, but still, I would like to share the answer.
The WFPs are now Maven projects and the build output goes to /target/classes.
There is a normal wtp-tools web container (tomcat) pointing to a WAR file in file system.
Solution: I've kept with VirtualWebappLoader and added a new flag for JarScanner as shown below:
<!-- List of Apps Jars -->
<Loader
className="org.apache.catalina.loader.VirtualWebappLoader"
virtualClasspath="apptest/target/classes;
customtest/target/classes"/>
<!--
Treat directory as expanded jar.
For details: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Virtual_webapp
-->
<JarScanner scanAllDirectories="true" />
UPDATE
The ones using Tomcat 8 will notice the VirtualWebappLoader is no longer there. So take a look at Resources. It has been replaced by Pre, Jar and Post resources.
However, I didn't find a proper way to load an exploded Jar with META-INF/resources and META-INF/web-fragment.xml to WEB-INF/lib as required for Servlet 3.0 spec.
When using the proposed examples from Tomcat documentation and mapping exploded Jar directory to WEB-INF/classes everything seems to be 'OK', but META-INF/resources and web-fragment.xml declared elements are not available:
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-6" id="form-container">
<%= form_for @entry do |form| %>
<br>
<%= form.text_field :entry_title, :size => 59, :placeholder => "Entry Title"%>
<br><br>
<%= form.text_field :book_title, :size => 59, :placeholder => "Book Title"%>
<br><br>
<%= form.text_field :img_url, :size => 59, :placeholder => "Image URL"%>
<br><br>
<%= form.text_area :text, :placeholder => "Text" %>
<br><br>
<%= form.text_field :tag, :placeholder => "Tag" %>
<br><br>
<%= form.submit %>
<% end %>
</div>
<div class="col-md-4"></div>
</div>
Then, changing webAppMount to "/WEB-INF/lib" give me some ClassNotFoundException in startup.
In the end, after several attempts I came up with a workaround:
<Resources>
<PreResources
className="org.apache.catalina.webresources.DirResourceSet"
base="/home/reginaldosantos/apptest/target/classes"
webAppMount="/WEB-INF/classes"
/>
</Resources>
Not too sure about that though.
Hope it helps some one ;-)