Maven enterprise application run with -1.0 in the end - java

Sometimes when i run my maven web application, the application run with -1.0 in the end, and this make a problem, is there any explanation of this problem, and how we can solve it.
Normal url : http://localhost:8080/projectmvn-web
Wrong url : http://localhost:8080/projectmvn-web-1.0
I use server glassfish-3.1.2 and Netbeans 8.1.
EDIT:
application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application 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/application_6.xsd" version="6">
<description>description..</description>
<display-name>projectmvn-ear</display-name>
<module>
<ejb>projectmvn-ejb-1.0.jar</ejb>
</module>
<module>
<web>
<web-uri>projectmvn-web-1.0.war</web-uri>
<context-root>/projectmvn-web</context-root>
</web>
</module>
<library-directory>lib</library-directory>
</application>
Thank you.

Assuming the 1.0 is the project version in your pom.xml file, if you don't have the build element in your pom.xml add the following as a child of project element:
<build>
<finalName>projectmvn-web</finalName>
</build>
If you already have the build element add the filalName element as follows:
<build>
<finalName>projectmvn-web</finalName>
// the rest goes here
</build>
With this setting Maven should create projectmvn-web.war in the targetfolder, i.e., without the version information on the filename.

Related

Generating a .war file from a static html/css/js web app and .ear container

I have a static site built using HTML/CSS/JS that I want to wrap up in a .war file and wrap that up in a .ear file to deploy on a Glassfish java server. However I am unsure of how best to generate the .war and .ear files.
Currently I have zipped and renamed / changed the type of containing folders to make the .war and .ear files, creating a META-INF/application.xml in the .ear and a META-INF/MANIFEST.MF and WEB-INF/web.xml inside the .war alongside the build files:
my-app.ear
--- META-INF
--- application.xml
--- my-app.war
--- META-INF
--- MANIFEST.MF
--- WEB-INF
--- web.xml
--- website build files (various folders and html/css/js files)
When I deploy the .ear on Glassfish I get no errors however the localhost root only shows the welcome page. I have also tried various different contexts such as localhost/my-app which return 404s (although that is expected given my applicaiton.xml context route is set to '/'.
Is my folder/file structure correct or am I missing something in setting up the .war and .ear files?
Serving the site in this way is a requirement for this project and I am not a regular Java user so I may be have missed something basic.
EDIT:
My application.xml file looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_ID" version="6" 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/application_6.xsd">
<display-name>my-app</display-name>
<module>
<web>
<web-uri>my-app.war</web-uri>
<context-root>/</context-root>
</web>
</module>
</application>
My web.xml looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="my-app" version="3.0">
<display-name>my-app</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Use Eclipse / Export / Java EE / EAR file within a dynamic web project. May be a small test project first and then look at differences. There is too much information missing to answer your question without guessing.

Can't create cron job in Google App Engine app that has multiple services

When I deploy my application which has multiple services, I can't see the cron job to be registered in App Engine Console, despite following directory hierarchy described in Configuration files overview .
This is my cron.xml file, which I placed in my default service's WEB-INF directory:
<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<url>/cron</url>
<description>Execute scheduled tasks</description>
<schedule>every 5 minutes</schedule>
</cron>
</cronentries>
This is my default service's appengine-web.xml file:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>default</application>
<version>1</version>
<threadsafe>true</threadsafe>
<sessions-enabled>true</sessions-enabled>
<manual-scaling>
<instances>1</instances>
</manual-scaling>
</appengine-web-app>
My GAE application has 4 services, all defined in application.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
<display-name>modules-ear</display-name>
<module>
<web>
<web-uri>module-default-1.0</web-uri>
<context-root>module-default</context-root>
</web>
</module>
<module>
<web>
<web-uri>module-1-1.0</web-uri>
<context-root>module-1</context-root>
</web>
</module>
<!-- declared other modules likewise -->
<library-directory>lib</library-directory>
</application>
My project structure:
Can you please tell me what am I doing wrong that my cron job doesn't run?
Try deploying cron configuration in a separate command:
If you're using gcloud cli: gcloud app deploy cron.yaml
Or gradle appengine plugin: ./gradlew appengineUpdateCron
Or maven appengine plugin: mvn appengine:update_cron
I had the same problem and running the command after the deployment solved it!

Gradle adds all modules as EJBs in application.xml

I have the following EAR project in my Gradle script having 2 deploy dependencies:
An EJB jar
An EJB client jar
What I want to do is create an EAR with the 2 jars in ear root but only the actual EJB jar in application.xml, i.e. something like this:
<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_ID" version="6" 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/application_6.xsd">
<display-name>MyEJBEAR</display-name>
<module>
<ejb>MyEJB.jar</ejb>
</module>
</application>
Here is my build.gradle file:
project(':MyEJBEAR'){
apply plugin: 'ear'
dependencies {
deploy project(':MyEJBClient')
deploy project(':MyEJB')
earlib <common jars>
}
}
The produced EAR structure is what I want however it contains an application.xml file like this (i.e. adds all deploy dependencies as EJBs):
<?xml version="1.0"?>
<application 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/application_6.xsd" version="6">
<display-name>MyEJBEAR</display-name>
<module>
<ejb>MyEJB.jar</ejb>
</module>
<module>
<ejb>MyEJBClient.jar</ejb>
</module>
<library-directory>lib</library-directory>
</application>
I have tried to play with deploymentDescriptor like this but I had no luck:
ear {
deploymentDescriptor{
module("MyEJB.jar", "ejb")
}
}
Any idea on how could I exclude the MyEJBClient.jar reference from the application.xml file?
EDIT:
I have found a workaround solution to this by throwing my existing (IDE Generated) META-INF folder that contains a valid application.xml from the EAR project root to a dir(e.g. MyEJBEAR/resources) and adding the following
lines in project(':MyEJBEAR') closure:
ear {
appDirName = 'resources'
}
This done based on this section of Gradle Documentation but I still need to somehow generate a valid application.xml from my build script.

jboss 6.4 ignoring webapp directory structure

we are moving from jboss 5.1 to jboss 6.4 and i have below entries in my xxx.ear/META-INF/application.xml. it seems like jboss 6.4 is not able to identify webapp but when I change this to webapp.war then it is deployed, due to this I need to rename my webapp folder to webapp.war.
With jboss 5.1 it is working fine but jboss 6.4 needs this change, is their any way I can suppress this?
Application scripts needs update to rename webapp to webapp.war every where and I want to avoid it.
Thanks in advance.
<?xml version='1.0' encoding='UTF-8'?>
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>Web App</display-name>
<module>
<web>
<web-uri>webapp</web-uri>
<context-root>/app</context-root>
</web>
</module>
</application>

How can I get Wildfly to load my EAR deployments in the correct order?

According to Wildfly's documentation, it should be possible to declare the order by which subdeployments are deployed within an EAR. However, I am not able to get it to respect the order of dependencies I have defined within my application.
The EAR has specified the initialize-in-order AND I have specified a dependency chain of webapp-three -> webapp-two -> webapp-one in the JBoss-specific file.
Am I missing something about how to declare this?
application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<application 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/application_6.xsd" version="6">
<display-name>ear</display-name>
<initialize-in-order>true</initialize-in-order>
<module>
<web>
<web-uri>webapp-one-1.0-SNAPSHOT.war</web-uri>
<context-root>/one</context-root>
</web>
</module>
<module>
<web>
<web-uri>webapp-two-1.0-SNAPSHOT.war</web-uri>
<context-root>/two</context-root>
</web>
</module>
<module>
<web>
<web-uri>webapp-three-1.0-SNAPSHOT.war</web-uri>
<context-root>/three</context-root>
</web>
</module>
</application>
jboss-deployment-structure.xml:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<sub-deployment name="webapp-one-1.0-SNAPSHOT.war">
</sub-deployment>
<sub-deployment name="webapp-two-1.0-SNAPSHOT.war">
<dependencies>
<module name="deployment.wildfly-deployment-order.ear.webapp-one-1.0-SNAPSHOT.war" />
</dependencies>
</sub-deployment>
<sub-deployment name="webapp-three-1.0-SNAPSHOT.war">
<dependencies>
<module name="deployment.wildfly-deployment-order.ear.webapp-two-1.0-SNAPSHOT.war" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
I would expect the deployment order to be:
webapp-one
webapp-two
webapp-three
Here is how Wildfly deploys:
11:27:31,046 INFO MSC service thread 1-1 [deployment] JBAS015973: Starting subdeployment (runtime-name: "webapp-two-1.0-SNAPSHOT.war")
11:27:31,046 INFO MSC service thread 1-1 [deployment] JBAS015973: Starting subdeployment (runtime-name: "webapp-three-1.0-SNAPSHOT.war")
11:27:31,047 INFO MSC service thread 1-1 [deployment] JBAS015973: Starting subdeployment (runtime-name: "webapp-one-1.0-SNAPSHOT.war")
Even though we start deploying all of them at the same time, initialise-in-order means that the individual components in the deployment will be initialised in order, so EJB's Servlets etc in webapp-two will not be started until webapp-one has started.
We still parse the deployments and build deployment metadata in parallel, because there is no reason not to.
I had the same problem with a sub deployment. You can define a sub deployment deployment order with dependencies in every sub deployment. You need to add a Class-Path: webapp-one-1.0-SNAPSHOT.war to the MANIFEST.MF file of webapp-two-1.0-SNAPSHOT.war. If you use maven, you can use in the config described in the maven-war-plugin documentation. It puts the dependency entries, defined in the pom.xml into the Class-Path: section, but this works not, if the dependencies defined as provided. In this case use the following configuration in the pom.xml:
<archive>
<manifestEntries>
<Class-Path>webapp-one-1.0-SNAPSHOT.war</Class-Path>
</manifestEntries>
</archive>
I found the solution in the Class Loading in Wildfly section of the Wildfly documentation posted in the question. In this documentation section is a green box with a green checkmark:
Portability
The Java EE specification says that portable applications should not rely on sub deployments having access to other sub deployments unless an explicit Class-Path entry is set in the MANIFEST.MF. So portable applications should always use Class-Path entry to explicitly state their dependencies.

Categories

Resources