I was wondering what would be the best practice to deploy a maven packaged WAR file to tomcat.
Using maven release plugin I get a versioned war file for my project
eg: myservice-1.0.0.war
I would like to deploy it to tomcat so that I can access it as follows
eg: http://localhost:8080/myservice
By default tomcat explodes the war file as a directory with a name myservice-1.0.0 under CATALINA_HOME/webapps. But I want to to explode the war as a directory with a name myservice for the reasons mentioned above.
I know I can simply rename myservice-1.0.0.war >> myservice.war and then deploy it in Tomcat.
I wanted to find out what others do?
I would do it by mentioning myservice as artifactId and final name and using maven cargo plugin to deploy to tomcat.
http://cargo.codehaus.org/Maven2+Plugin+Tips
You can package file /META-INF/context.xml with content like this:
<?xml version="1.0"?>
<!DOCTYPE Context>
<Context path="myapp">
</Context>
See documentation at http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
I ran into the same problem. What worked for me was inserting this properties element into the cargo deployable configuration:
<deployable>
<groupId>org.something</groupId>
<artifactId>something-idm-esb</artifactId>
<properties>
<context>something-idm-esb</context>
</properties>
<type>war</type>
</deployable>
Without this properties element, the app would be deployed to localhost:8080/something-idm-esb-0.9.14.2 which is not what the app needs at runtime. With the properties section, the app is deployed to localhost:8080/something-idm-esb/
Instead of renaming the war file you could do this:
Just add following in your tomcat-dir/conf/server.xml in between <Host>..<\Host> tags.
for : myservice-1.0.0.war file
<Context path="/myservice" docBase="/myservice-1.0.0" debug="0" reloadable="true"></Context>
Reference
Related
I'm using Wildfly 11 with Java 8. Previously I was building a WAR file, which required the dom4j JAR file. Rather than including it in the WAR's WEB-INF/lib directory, I linked to the Wildfly modules JAR by adding an entry in the WEB-INF/jboss-deployment-structure.xml. Now I want to package this WAR as part of an EAR. So I created a jboss-deploymebnt-structure.xml file at teh root of the EAR, with these lines
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<sub-deployment name="myapp.war">
<dependencies>
...
<module name="org.dom4j" />
Now when I deploy the EAR, the WAR is failing to deploy with errors like
service jboss.undertow.deployment.default-server.default-host./myapp: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./orgsclient: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/spring/infrastructure.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/dom4j/io/STAXEventReader
What else do I need to do to tell the EAR file that the WAR is using the Wildly module dom4j as opposed to one I'm packaging with the EAR itself?
Check if your jboss-deploymebnt-structure.xml is correctly placed in META-INF subfolder (beside with application.xml) of your built ear package. If you're using maven ear plugin you should put the xml file in:
ear/src/main/application/META-INF/jboss-deploymebnt-structure.xml
Please note the application folder is default resource folder for ear plugin.
If you still have a problem with NoClassDefFound, try to redeclare the dependency as 'ear global' and set it as exported
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.dom4j" slot="main" export="true"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
If you still have a problem then declare the module as a global module in wildlfy config (under the ee subsystem). Then you can get rid off the the jboss deployment descriptor at all.
<subsystem xmlns="urn:jboss:domain:ee:4.0">
<global-modules>
<module name="org.dom4j">
</global-modules>
...
I'm trying to deploy a war file for local development and I want to modify tomcat's context.xml to provide datasource via jndi. This works when using tomcat7-maven-plugin:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<contextFile>../../tomcat-test-context.xml</contextFile>
</configuration>
</plugin>
The problem is, that tomcat7-maven-plugin doesn't work with overlays which I use in the project, so I have to use another approach. I can deploy the war artifact in intellij idea, but I don't see any option to specify the contextFile like in the tomcat7-maven-plugin. Is there some option to do similar thing in intellij idea tomcat configuration?
Of course I can modify the context.xml under the catalina home, but I'd like to have it configured per project and don't want to have many tomcats.
The application is deployed on weblogic in production and I use tomcat only locally for testing.
I have a project where I am packaging a WAR using simple maven-war-plugin. Along with all other dependencies one of the dependency say 'abc.jar' which is getting packaged in war contains a default spring configurations which I would like to update with the custom one before packaging. I have maven profile configured to be activated if following build command applied;
mvn clean install -DframeworkPacakging=XYZ
I am trying to use 'truezip-maven-plugin' to overwrite my custom spring configurations inside in 'abc.jar' present in 'target/aretfacts-id/WEB-INF/lib' but when maven-war-plugin finishes I loose my changes because war plugin takes the file from dependency definition. How can I solve this issue and what are my options?
P.S. Distributing configuration is not desirable as this setup would be used for Embedded Jetty Server running within Eclipse
to prevent inclusion of the original jar file, I would use go for approach suggested on: https://www.mail-archive.com/users#maven.apache.org/msg38537.html
Use <scope>provided</scope> for this dependency to keep it out of the
lib directory.
to include the repackaged one, I'd follow suggestion from: How to make Maven copy resource file into WEB-INF/lib directory?
Try changing the configuration of the maven war plugin to include a webResource:
<configuration>
<webResources>
<resource>
<directory>pathtorepackagedjar</directory>
<includes>
<include>**/abc.jar</include>
<includes>
<targetPath>WEB-INF/lib</targetPath>
</resource>
</webResources>
</configuration>
UPDATE: It seems to be SoapUI maven plugin specific issue at first, but it's not, really, so please read through.
I'm running SoapUI plugin with Maven2 like this:
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<settingsFile>${basedir}/src/test/resources/soapui-settings.xml</settingsFile>
<projectFile>${basedir}/src/test/resources/my-soapui-project.xml</projectFile>
<outputFolder>${project.build.directory}/soapui-output</outputFolder>
<printReport>true</printReport>
<junitReport>true</junitReport>
<exportAll>true</exportAll>
<soapuiProperties>
<property>
<name>soapui.logroot</name>
<value>${project.build.directory}/soapui-logs/</value>
</property>
</soapuiProperties>
</configuration>
</plugin>
It works perfectly and puts all soapui log files into ${project.build.directory}/soapui-logs/ with one exception: global-groovy.log which goes into basedir (seems to be bug in SoapUI log4j configuration).
I need an option to override soapui-log4j.xml file that comes with SoapUi maven plugin and fix GLOBAL_GROOVY_LOG appender from:
<param name="File" value="global-groovy.log"/>
to this:
<param name="File" value="${soapui.logroot}global-groovy.log"/>
In the past I ran SoapUI test programmatically from JUnit test and just placed updated soapui-log4j.xml file into src/test/resources/com/eviware/soapui/resources/conf/soapui-log4j.xml and it worked. Maven copies it into target/test-classes and adds that path to classpath to run unit tests.
Now the problem with SoapUI maven plugin is that I don't know how to add src/test/resources/com/eviware/soapui/resources/conf/soapui-log4j.xml to plugin's classpath. Is there anything similar to Surefire's additionalClasspathElements configuration option?
So in other words I want to know how to add additional class path entries to any generic maven plugin execution environment, not only SoapUI plugin.
It's possible to add to a plugins dependencies using the dependencies element. From the POM reference:
Additional dependencies that this project needs to introduce to the plugin's classloader.
I don't know how maven treats these dependencies, so it might place them after the plugin's own classes which effectively prevents overriding the log4j configuration, but give it a try; package the log4j configuration file in a jar and add it as a dependency to the plugin.
I am trying to get the Cargo plugin works on my maven project in order to benefit from war hot-deployment targetting the Jonas server.
The official documentation is not that clear on what is supported and what is not (for example you can find this: http://cargo.codehaus.org/Hot+Deployment but also this http://cargo.codehaus.org/JOnAS+4.x).
Anyway I have the following coniguration in for my war's POM:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<container>
<containerId>jonas4x</containerId>
<home>C:\JOnAS-4.8.4\nt\bin</home>
</container>
<configuration>
<type>existing</type>
<home>C:\JOnAS-4.8.4</home>
</configuration>
</configuration>
</plugin>
And when I run
mvn cargo:deploy
on my project, the war is copied to the Jonas webapps folder but there is no hot deployment. The file is only copied but the hot deploy Jonas command is not called so that my modifications are not available immediatly.
EDIT: I also tried to add a deployer configuration as suggested on the answers but the behaviour is the same (ie: war is copied but the Jonas hot deploy command is not called so that the war is not reloaded in Jonas).
Am I missing something or am I right saying the Cargo Maven plugin does not support Jonas Hot Deployement?
Thanks in advance!
The cargo page on deploying to a running container links to a table listing the version where hot deployment was introduced for that container. According to the table, JOnAS 4.x is supported from version 1.0 (which you are using), so it should work.
On that page it also has some guidelines for configuring the plugin for deployment, I've attempted to interpret them below.
From the home element in your configuration I assume you are attempting a local deployment. The configuration in the running container page implies that the hot-deployment should be automatic in this line at the end:
Just type mvn cargo:deploy. Notice that we haven't specified a element nor a one. This is because the plugin is smart enough to create default instances for you. Cool, isn't it?
However the earlier configuration block indicates you should configure the deployer section to make the cargo plugin aware of the war to be deployed. The configuration for the deployer would be something like this:
<deployer>
<type>local</type>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<properties>
<context>optional root context</context>
</properties>
<pingURL>optional url to ping to know if deployable is done or not</pingURL>
<pingTimeout>optional timeout to ping (default 20000 milliseconds)</pingTimeout>
</deployable>
</deployables>
</deployer>
If the automatic option isn't working for you, consider declaring the configuration for your war.