Maven cargo during merging web.xml not include all error-page - java

I trying to merge two war files using maven cargo plugin. The problem is that. I have only one web.xml in one archive. Other archives not include web.xml. So the situation looks like below:
first.war --> with web.xml
second.war --> without web.xml
third.war --> without web.xml
So after merging my merged file uberwar.war file should contain exactly the same web.xml which is included in first.war.
Every tags in merged web.xml are the same instead of error-page. There is only taken first error-page from web.xml. Rest of the error-page tags are skipped. I dont know why. Have someone exeprience with this plugin and could help with issue?? I will be grateful for any help.
1. assemble.xml
<?xml version="1.0"?>
<uberwar>
<wars>
<war>org.vcm.modules:core-web</war>
<war>org.vcm.modules:attributes-web</war>
<war>org.vcm.modules:delivers-web</war>
<war>org.vcm.modules:movies-web</war>
<war>org.vcm.modules:zones-web</war>
<war>org.vcm.modules:opinions-web</war>
<war>org.vcm.modules:payments-web</war>
<war>org.vcm.modules:storages-web</war>
<war>org.vcm.modules:taxes-web</war>
<war>org.vcm.shops:shops-web</war>
</wars>
2. pom.xml
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.9</version>
<extensions>true</extensions>
<configuration>
<descriptor>src/assemble/merge.xml</descriptor>
</configuration>
</plugin>

I found cause. The problem was with my web.xml version. I used 3.1 when I change to 2.3 the merging process working correct. It seems the cargo plugin analyze the xml in different way when is newest version.

Related

How to deploy one .war after another on JBoss

Is there a way to define order of .war deployments on JBoss 7?
What I would like to accomplish is that on startup of JBoss it first deploys .war A and then .war B.
I need this because .war A is a service which is consumed on a startup of .war B!
You have to specify the dependency on the B war by creating a jboss-all.xml file on the META-INF folder,with a content like this:
<jboss umlns="urn:jboss:1.0">
<jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
<dependency name="A.war" />
</jboss-deployment-dependencies>
</jboss>
The procedure is explained here Control the order of Deployed Applications on JBoss
As mentioned in this JBoss's Forum thread, in order to ensure that A.war is deployed first than B.war, you should create a MANIFEST file under your B.war's src/main/webapp/META-INF folder, with the following entry:
dependencies: deployment.A.war
Furthermore, if you need to access A.war classes from B.war, you should also add a jboss-deployment-structure.xml, under your B.war's src/main/webapp/WEB-INF folder, with the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:deployment-structure:1.2 http://www.jboss.org/schema/jbossas/jboss-deployment-structure-1_2.xsd">
<deployment>
<dependencies>
<module name="deployment.A.war" export="true"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
You can also take a look at JBoss AS 7 class loading documentation.

Why java dynamic server just works on stand alone Tomcat but not eclipse

First of all, i don't know if i wrote the question correctly or not.
I have a dynamic web server that I developed on eclipse, and when I run it on eclipse, using Tomcat 8.0.33 i get this
however, if i compiled and build the project and extracted the war file, then put that war file into the work web apps folder into Tomcat installation directory, and then run Tomcat from terminal using startup.sh, it works perfectly, see please
i tried another version of Tomcat, 8.0.24, and the same problem happened.
i am using eclipse Luna Service Release 2 (4.4.2) on mac os El Captine
Update 1
Maybe because I deleted the web content folder and i am putting my files in src/main/webapp
and that is what I do in pom
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>true</failOnMissingWebXml>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
</configuration>
</plugin>
Do you think so? if yes how to solve it please ?
If the project is webtools dynamic project, you can edit the file $PROJECT_HOME/.settings/org.eclipse.wst.common.component. Modify the attribute value of source-path of wb-resource element.
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="SemanticRecommenderWebservices">
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/java"/>
<property name="context-root" value="SemanticRecommenderWebservices"/>
<property name="java-output-path" value="src/main/webapp/WEB-INF/classes"/>
</wb-module>
</project-modules>

Wildfly exploded war hot deployment

I have a web application deployed as exploded war using wildfly. What I want to get is
Changes in jsp files are automatically reflected, without redeploying the app
Changes in .class files enforce an app redeployment.
At the moment I am in a situation in which either I can get one option or the other, but not both at the same time (meaning that either every jsp change forces a new deployment or that .class files do not force a new deployment).
Current configuration of wildfly (using version 8.1.0) is
<deployment-scanner
path="deployments"
relative-to="jboss.server.base.dir"
scan-enabled="true"
scan-interval="1000"
auto-deploy-exploded="true"
runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"
/>
...
<servlet-container name="default">
<jsp-config development="true"/>
</servlet-container>
Also, something I have found is that no matter what I set in the deployment-scanner config, once the server is up and running, if I go to the wildfly web console, the parameter auto-deploy-war is marked as true and auto-deploy-exploded is marked as false, even the scan-interval is always set to 5000 ms, which makes me think that the deployment scanner config is somehow being ignored.
I am kind of lost here quite frankly, it has to be possible for wildfly to reload the app if the change is a .class file and not do it if it is a jsp.
Have you tried JRebel? following my blog entries would help also.
http://www.nailedtothex.org/roller/kyle/entry/evaluating-jrebel-for-wildfly-and
http://www.nailedtothex.org/roller/kyle/entry/exploded-deployment-for-wildfly-on
Manik Hot deploy is an open source Maven Plugin that simplifies your web development. The plugin provides both deployment modes - the auto-deployment and also the hot-deployment. It can be easily configured in a maven project by adding the plugin to the pom.xml
....
<build>
<plugins>
.....
<!-- Manik Hotdploy -->
<plugin>
<groupId>org.imixs.maven</groupId>
<artifactId>manik-hotdeploy-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- List Source and Target folders for Autodeploy and Hotdeploy -->
<autodeployments>
<deployment>
<!-- wildcard deployment -->
<source>target/*.{war,ear,jar}</source>
<target>/opt/wildfly/standalone/deployments/</target>
<unpack>true</unpack>
</deployment>
</autodeployments>
<hotdeployments>
<deployment>
<source>src/main/webapp</source>
<target>/opt/wildfly/standalone//deployments/my-app.war</target>
</deployment>
</hotdeployments>
</configuration>
</plugin>
.....
</plugins>
</build>
....

Java RestFull WebService: JAX-RS implementation with Jersey 2.3.1 libraries

I am trying to run a simple "Hallo World" application Jersey 2.3.1 REST service on JBoss jboss-eap-6.1 AS. In web.xml i have disabled restEasy library. During deployment i am getting the error:
JBWEB000289: Servlet
com.sun.jersey.samples.helloworld.resources.MyApplication threw load()
exception: java.lang.NoSuchMethodError:
javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
In POM i put these dependencies:
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
This is my web.xml with restEasy tags disabling:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>com.sun.jersey.samples.helloworld.resources.MyApplication</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.sun.jersey.samples.helloworld.resources.MyApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.providers</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.resources</param-name>
<param-value>false</param-value>
</context-param>
<servlet-mapping>
<servlet-name>com.sun.jersey.samples.helloworld.resources.MyApplication</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
And my resource config java class:
package com.sun.jersey.samples.helloworld.resources;
import org.glassfish.jersey.server.ResourceConfig;
public class MyApplication extends ResourceConfig {
public MyApplication() {
packages("com.sun.jersey.samples.helloworld.resources");
//super(HelloWorldResource.class);
}
}
Someone have any idea to solve it?
thanks in advance,
Roberto
NoSuchMethodError usually means you are having two different versions of the class on your classpath. As the javax.ws.rs.core.Application class does have the getProperties() method in its JAX-RS 2 version, but not in JAX-RS 1.x, I would guess that somehow you are combining the old 1.x Jersey (or old REST api) with the current (2.3.1) one.
Also the package you are working in (com.sun.jersey - the 'old' Jersey package) points a bit towards this direction (although just placing your code into that package itself cannot cause the mentioned problem), you obviously started with the Jersey 1.x example as a base (there are samples in Jersey 2 as well, see helloworld-webapp on Jersey GitHub).
Is it possible, that restEasy (also definitely containing the javax.ws.rs.core.Application class) is not completely switched off and somehow defaults to JAX-RS 1.x version?
I would start with inspecting your pom file, look at the effective pom (if your project descriptor has some parent) and check carefully what is on your classpath - I believe there is a 1.x version of javax.ws.rs-api somewhere. Also try to clean all the compiled stuff and rebuild from scratch.
Speaking of dependencies, if your list is exhaustive (regarding Jersey), you will most likely have to add jersey-common (2.3.1) dependency, as already during the initialization, the ResourceConfig.packages() method calls the PackageScanner constructor, which contains call to ReflectionHelper - and this is not a part of the server jar any more.
Hope this helps.
I faced same problem recently. I thought share my steps for you. As the other answers state, the problem is mainly because of having two different versions of the same class on your classpath. So when you add maven dependencies in your pom be careful.
These kind of problems are normally called as Jar Hell. You can use jhades API for investigate the classes overlap one another. Here is the simple steps i have followed.
Add jhades dependency into your pom.
<dependency>
<groupId>org.jhades</groupId>
<artifactId>jhades</artifactId>
<version>1.0.4</version>
</dependency>
Show the report
Call new JHades().overlappingJarsReport(); in your main method, it will output to stdout.
Sample Output:
file:/Users/justin/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar overlaps with
file:/Users/justin/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.0/javax.ws.rs-api-2.0.jar - total overlapping classes: 55 - same classloader ! This is an ERROR!
Remove one of overlap maven dependency in your pom.
Also you can use another approach like maven's dependency exclusions.
Source: Blog post on jhades
Hope this will help someone :)
Just got this working on JBoss EAP 6.1.1 - Jersey 2.3.1.
The usual things don't seem to work/are not enough on their own:
disabling the jaxrs-subsystem in standalone.xml/domain.xml
or, excluding the jax-rs modules in jboss-deployment-structure.xml
Additionaly you need to disable the loading of the jax-rs 1.1 API completely by modifying module.xml in
jboss-eap-6.1/modules/system/layers/base/javax/ws/rs/api/main/module.xml like this:
<module xmlns="urn:jboss:module:1.1" name="javax.ws.rs.api">
<resources>
<!-- Disable the next line -->
<!-- resource-root path="jboss-jaxrs-api_1.1_spec-1.0.1.Final-redhat-2.jar"/ -->
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="org.jboss.resteasy.resteasy-jaxrs" services="export"/>
</dependencies>
</module>
Please note that this will disable the jax-rs implementation of JBoss (RestEasy) for all other applications as well (as does disabling the jaxrs subsystem in standalone/domain.xml).
This is a Jersey version conflict problem. I had the same problem. Here is how it is resolved:
See your package dependencies "mvn dependency:tree"
If there is a library dependency that depends on an old Jersey version, you could add an exclusions section in the dependency tag for that library in pom.xml
Using mvn dependency:tree (thanks for suggestion above) I was able to identify that the culprit (in my case) was: javax.ws.rs:jsr311-api:1.1
Removing this dependency solved my problem.

Supporting i18n in GWT

Till now, our web application supports only English. Now we have to provide support for Italian as well. There is GWT module for some functionality. To support the Italian language I have added below line in the file "APP_Module.gwt.xml"
<extend-property name="locale" values="it"/>
I have also placed "XXX_it.properties" file under the source code where the properties file for en is kept.
Setting the locale in the jsp by following line:
<meta name="gwt:property" content="locale=${locale}">
Now, the issue is how to compile the code. I am debugging the application but it is not hitting the client code of GWT presented under WEB-INF/src.
I am very new to GWT. Please suggest how can I compile the code or there is no need of compilation. It will automatically take the changes done in "APP_Module.gwt.xml" and there is some other issue. How can I see logs of GWT?
To add support for locales to GWT application, you need to do the following in your xxx.gwt.xml:
under <module> add this to include the support:
<inherits name="com.google.gwt.i18n.I18N" />
and this to configure it:
<extend-property name="locale" values="en,it"/>
<set-property-fallback name="locale" value="en"/>
Add all your property files under some package like this:
src/main/resources/foo/bar/client/i18n/MyMessages.properties
src/main/resources/foo/bar/client/i18n/MyMessages_it.properties
Then you need to tell GWT to compile them into classes. This is example from a pom.xml file (if you don't use maven, you will have to use a different way, but you still need to configure it).
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.3.1.google</version>
<executions>
<execution>
<goals>
<goal>i18n</goal>
<goal>generateAsync</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<i18nMessagesBundles>
<resourceBundle>foo.bar.client.i18n.MyMessages</resourceBundle>
</i18nMessagesBundles>
</configuration>
</plugin>
Then you need to recompile the code. In maven mvn compile. And that's all, you will have your messages in generated sources folder ready to use.
For seeing the logs of gwt you can use gradlew gwt also you can use it to compile the code too.

Categories