war

deploying multiple applications to Tomcat

守給你的承諾、 提交于 2019-11-29 19:47:06
I want to deploy two applications foo.war and bar.war to the same Tomcat instance. Is it possible for them to listen for connections on different ports, e.g. foo listens on port 81 and bar listens on port 82? If so, how can I configure this? I realise that it is not necessary for the applications to listen on different ports, but that is what I want to achieve. Also, am I right in saying that if I rename foo.war to ROOT.war such that it runs in the root context, then all requests to this Tomcat instance will be handled by the foo app and therefore bar would have to be deployed to a separate

JAR vs WAR file specification

一曲冷凌霜 提交于 2019-11-29 15:16:23
I noticed that WAR files are supposed to have classes/ and lib/ directories for containing their classfile root and dependencies, respectively. I also noticed that it is not common practice for JARs to contain such a lib/ directory and to contain their own dependencies. So now I'm wondering why JARs shouldn't/usually-don't contain their own dependencies, but WAR files are expected to. Unless I'm missing something, both require their dependencies to be on the classpath at runtime (JARs won't run if they're missing dependencies, just like WARs won't run). So to me, all the arguments for putting

让Tomcat7识别War包的Class-Path(MANIFEST.MF)属性动态加载类路径

痴心易碎 提交于 2019-11-29 14:59:25
一、背景 几个Web项目需要打包到一个发布包中,问题是War包都各自包含了自己的WEB-INF/lib,其中不少依赖Jar有重复。所以希望把War包的所有的lib都放到外部的一个公共目录减小总工程大小。但放在一个目录,以目录方式加载到全局Classpath就会产生类库冲突问题,如:web1使用spring2,web2使用spring3。 二、分析 一般Jar包中都包含一个META-INF/MANIFEST.MF文件。在这个配置文件中可以指定一个Class-Path属性,再执行java -jar xxx.jar时,Java会以这个Class-Path属性中定义为准。 War包中也有MANIFEST.MF文件,当然也可以添加Class-Path属性(Maven)。但问题是这个属性从Java规范上讲并没有约定,所以应用服务器一般都不识别。 我们需要解决的是类路径加载的问题。还好Tomcat上下文配置文件的Context标签中有Loader标签,允许我们重写WebappLoader。 三、开发 1、Tomcat应用上下文XML配置样例 在Tomcat应用上下文配置文件中,定义Web工程的Loader指定到自定义WebappLoader。 <?xml version="1.0" encoding="UTF-8"?> <Context docBase="${xxx.home}/apps/xxx

Maven 是怎样创建War 包?

て烟熏妆下的殇ゞ 提交于 2019-11-29 14:58:14
最近在网上看到一篇介绍maven基础知识的文章,觉得对初学Maven的 朋友一定有帮助。水平有限,翻译的不好,请大家见谅。 介绍 在处理WEB应用的时候,最终使用的工程文件是以War包的形式交付。Maven编译系统可以轻松的创建War包。接下来就让我们看看Maven是如何把一个源文件的工程转换成War包的。 Maven 版本 Apache Maven 3.0.4 工程实例 让我们来看看这个非常典型的Maven化的WEB工程 对应的POM.xml如下: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>mygroup.com</groupId> <artifactId>myprojectname</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name

Ant script: Prevent duplication of JAR in javac-classpath war-lib

北城余情 提交于 2019-11-29 13:27:51
问题 I have a ANT script and I have a lot of duplicated path to same set JAR files. But there is so many double wording in the classpath and also in the war element. <path id="my.classpath"> <pathelement location="folderA/subFolderA/1.0/A.jar"/> <pathelement location="folderC/subFolderB/1.0/B.jar"/> <pathelement location="folderF/subFolderZ/2.0/Z.jar"/> <pathelement location="compile/subFolderX/1.0/onlyForJavac.jar"/> </path> .... <javac ...> <classpath refid="my.classpath" /> </javac> .... <war .

How to create a WAR file using the commandline?

不羁岁月 提交于 2019-11-29 13:19:12
I installed JBoss Developer Studio and it's possible to create a WAR file by "right mouse project > Export > WAR file" but I want to export my project to a WAR file using the commandline. I have maven installed which is one of the requirements of the Studio and I read that I can generate a WAR file using maven but I require a file called pom.xml. When I searched through my workspace and project, pom.xml was missing. I may need to manually create pom.xml but I'm unsure how to. My directory tree for my project is the following: Siesta ├── build │ └── classes ├── src └── WebContent ├── extjs ├──

Sharing an application context between two WARs?

荒凉一梦 提交于 2019-11-29 12:43:32
问题 Is there a way to share an app-context between two deployed wars? One war needs to wire-in the services of another, and I don't know where to start with this. 回答1: The general purpose of a web application container like tomcat is that each application is able to run independently (so you can stop and start individual apps without affecting others), which means that there has probably been a lot of effort put into their development specifically to prevent you from doing this. So even if you

Is it possible to use multiple ehcache.xml (in different projects, same war)?

六眼飞鱼酱① 提交于 2019-11-29 09:11:53
I have a services project and a web project. I need to have eh-cache in both projects. The idea is that if the service project is updated, it's cache-related changes (like keys and invalidation rules) will also be available, while no changes are made to the web project. Being so independent, the service project can also be used with another projects without them even knowing of eh-cache. At this point, my web project also uses eh-cache for its own purposes. I am not much experienced with eh-cache and I fear that the two projects might clash when deployed together. I also did not find relevant

Using Maven, how to properly deploy WAR depending on J2EE/JPA JAR?

人盡茶涼 提交于 2019-11-29 08:45:18
I'm creating a modular Maven project. Project is deployed on Glassfish 3.1. Project (webapp) consists of three modules: "Common", consisting of core functionality (persistence, authentication logic, etc.), built into a JAR "User", depending on Common, built into a WAR "Admin", also depending on Common and WARred Both WAR use heavy annotated (@Entity, @Inject, @EJB, ...) classes from Common. Currently Common is a JAR, but it's not a requirement. The question is: How to properly deploy such project? By my current (google and stackoverflow influenced) knowledge: Common cannot be a JAR, because

Is there any way to tell maven war plugin to use folder other than target/classes

烂漫一生 提交于 2019-11-29 06:53:59
when i use maven war plugin, by default, this plug-in will copy all class files(*.class) from target/classes to {warfile}/web-inf/classes. The problem is if i have compiled classes (*.class) that stay in another folder : basedir/other-classes (they are *.class file not *.java file, i know, it is weird. But those classes is generated from 3rd party). Is there any way to tell maven war plugin to copy all classes in (basedir/other-classes) and (target/classes) into {warfile}/web-inf/classes This might work for you. Make sure the directory and targetPath are what you need. <build> <plugins>