What is the correct process of deploying a WAR OSGI file (WAB) to glassfish 3.1 server?
I am copying the war file to "glassfish3\glassfish\domains\domain1\autodeploy\bundles\" -> OSGI recognizes the file as bundle and add it to its container.
However, it doesn't deploy the war as web application (I cannot access its JSPs).
To make it a web application, I deploy the war from glassfish admin console.
Is it correct to deploy the same war twice? Shouldn't OSGI deploy it as WEB and OSGI?
To make OSGI discover the wab, I needed to add the following attributes to "maven-bundle-plugin" when creating the WAB:
<configuration>
<instructions>
<Web-ContextPath>/blabla</Web-ContextPath>
<Webapp-Context>/blabla</Webapp-Context>
</instructions>
</configuration>
With this configuration, war should be copied to autodeploy/bundles only.
More details (and other attributes) can be found here: http://leshazlewood.com/2010/09/08/osgi-maven-pax-and-web-applications/
You only Web-ContextPath as per the final OSGi EE spec. Webapp-Context was an intermediate name. No need to deploy the WAB again as a WAR as already answered in this thread.
Related
I have a web application deployed to jboss eap 7.0 on linux.
Within my java code I am using javax.json.JsonValue.asJsonArray method.
When I run locally on tomcat all runs fine.
Once I deploy to Jboss I get a nosuchmethod error on asJsonArray method. within my WEB-INF\lib folder I have the necessary json jar with that method javax.json-1.1.4.jar. I have discovered that under modules within Jboss it has its own version of javax.json \jboss-eap-7.0\modules\system\layers\base\org\glassfish\javax\json\main\javax.json-1.0.3.redhat-1.jar.
It is my speculation that when I run my application it is first looking at jar within the Jboss modules directory rather than the jar within the WEB-INF\lib folder in the war file. How do I direct the application to reference the jar within the WEB-INF\lib and not the jar withing the jboss modules?
You can exclude the JBoss provided dependency using jboss-deployment-structure.xml file which you need to place under the WEB-INF directory of your war. You have to specify the exclusion dependencies something like below.
`<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="$LIBRARY_OR_MODULE_YOU_WANT_TO_EXCLUDE"/>
</exclusions>
</deployment>
</jboss-deployment-structure>`
e.g. <module name="javax.json.api"/>
I have a situation in hand where I have no internet connectivity on my client's server (because it is an intra-net server) and I have to deploy my Spring Boot application on it which uses Maven build. The thing is, I am not allowed to connect the server to the internet due to security reasons but I am able to access internet on my development machine. So I have two questions:
How do I get all the dependencies on the server in question? Can I somehow copy the downloaded files from my development machine to the server? If so, how?
Do I need to setup Apache Tomcat or should I just run the war file from the command line? What are the best practices?
It's better to make a jar file instead of making a war file. That should help you to run without Tomcat since it embeds a web server.
Dependencies are packed with the jar when you do a Maven build. You need to have an internet connection to build it. Copy the jar to the production environment and run.
Here is striaght forward example to deploy spring boot application on tomcat server
Follow the example and add one more tomcat6/tomcat7 plugin
<!-- Tomcat 6 plugin -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<configuration>
<url>${serverUrl}:${port}/manager</url>
<path>/${contextpath}</path>
<username>${username}</username>
<password>${password}</password>
</configuration>
</plugin>
plugin properties as follows
<properties>
<!-- Server Details -->
<serverUrl>http://kpServer</serverUrl>
<port>8080</port>
<contextpath>kp-cxf</contextpath>
<username>admin</username>
<password></password>
<!-- Skip test execution during default steps -->
<skipTests>true</skipTests>
</properties>
And you can use mvn tomcat6:redeploy command to deploy to your server(in shore maven deownloads plugins/dependencies from internet to your development server, when you run mvn tomcat6:deploy/package it creates war by taking jars from you local maven directory)
I have a spring integration project deployed in jboss as a WAR file.
The project uses maven and structured to support any type of archival War or Jar.
However, the dependencies of the project (all spring jars and custom jars) should be externalized
The reason would be that, later there would be 100s of Spring Integration flows would be deployed and if we have the jars in WEB-INF/libs the size of WAR grows to ~ 50MB. As we have abstracted much of our functionality in a seperate jar (would be added as dependency to my spring integration project), Externalization will result in reducing the WAR file to ~ 5 KB.
I do not have a web.xml and use the WebInitializer for loading the context (Which is part of my common functionality and added as dependency)
Below is what I have tried with JBOSS.
Created a module com.xxx.yyy and added all my spring/third party and custom jars as resources.
Added the dependency to manifest file. (This did not work)
Added the jboss-deployment-structure.xml to my war WEB-INF (did not work)
If I give the wrong module name its throws errors as module
not found.
The war gets deployed, but not initialized. If I have the dependencies in my WEB-INF/lib, everything works as expected.
Below is the jboss deployment structure xml that I used.
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
<module name="com.xxx.yyy" services="import" >
<imports>
<include path="META-INF**"/>
<include path="org**"/>
</imports>
</module>
</dependencies>
</deployment>
</jboss-deployment-structure>
Here is the expectation,
Externalize the Jar dependencies.
Import the dependencies to my war(manifest or jboss-deployment-structure.xml)
Should be used Spring Service should be initialize.
The deployed war should be working as it does if the libraries are
in WEB-INF
Please help...
With JBOSS EAP 6, Its not possible to deploy the war without a web.xml, But such is possible only with tomcat or by using spring boot.
Also, to address this problem, we had to create a dummy web.xml and use jboss modules to load dependencies.
I have a stateless EJB SOAP Web Service that is packaged in jar file.
Is it possible to setup auto-deploy with Tomee maven plugin when the app consists of only one EJB jar file?
For example, this site indicates that a web context defined in server.xml is required. My synch setup is same as the site suggests.
mvn compile
command does nothing but compile the sources as it normally does.
Is there a possibility to setup something like this with EJB jar or is a WAR package needed in any case?
Thanks.
UPDATE
In order to get the TomEE Maven plugin to work at all with jar files, I added the following in pom.xml configuration section
<apps>
<app>my.group:my-ejb-app:1.0:jar</app>
</apps>
We use the maven tomcat7 plugin to do exactly this. Here's the trick, because Apache TomEE is JEE6, you can deploy EJBs in wars.
So there are two ways to do what you want... One, skip the Jar packaging for your application and make your EJBs be WARs. If this doesn't sound appealing, the other way is to create a separate project that's a WAR, but pulls in your EJB jar as a dependency.
In either case, then you can then use the tomcat7 plugin to deploy your projects easily to Apache TomEE like this mvn tomcat7:deploy provided you fill out the server section of your pom correctly. Example:
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<server>crabs</server>
<url>http://crabs/manager/text</url>
<path>/${project.artifactId}</path>
<update>true</update>
</configuration>
</plugin>
</plugins>
</build>
Make sure you have a user in tomcat-users.xml on the server that has the proper deployment permissions to manager-text. Also, put the server configuration into your ~/.m2/settings.xml:
...
<servers>
<server>
<id>crabs</id>
<username>deploy</username>
<password>your password</password>
</server>
...
I have a project that deploys an standalone OSGí Apache ServiceMix application. It has tons of dependencies and it is built with Maven. Now I want to deploy this application into a JBoss AS. I found an interesting Maven plugin called jboss-as-maven-plugin (org.jboss.as.plugins) to deploy anything. I use maven-bundle-plugin (org.apache.felix) to construct my bundles and it works fine, but when I deploy the project bundles, the deployment fails because dependencies are not satisfied.
How can I automatically bundle and deploy all the dependency tree with a Maven goal? Is it possible? My project has dozens of dependencies declared on the pom.xml and some of them are other projects in my workspace.
Currently the only solution to this I know are the Karaf features. You can create a feature file out of your pom dependencies.
I found that jboss seems to support subsystems. That may help to specify the bundles required to run your application. It does not seem to be the OSGi subsystem spec but for jboss this may already help. For OSGi spec 5 there is the standardized subsystem spec which may provide a standard way to do this across containers.
If jboss supports OBR (OSGi bundle repository) then you can limit the number of dependencies you have to specify.
If your application do not use OSGi per see, you may consider packing your application as a WAR which is deployable in JBoss.
Then you would need to use web.xml to bootstrap your application, such as using a Spring XML file.
There is a Camel example as a WAR here: http://camel.apache.org/servlet-tomcat-example.html
You can autoinstall your bundles with org.apache.sling plugin
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>maven-sling-plugin</artifactId>
<executions>
<execution>
<id>install-bundle</id>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<slingUrl>http://localhost:8181/system/console/install</slingUrl>
<user>karaf</user>
<password>karaf</password>
</configuration>
</plugin>
you can find detailed pom.xml from Adobe website :https://docs.adobe.com/docs/en/cq/5-6-1/developing/developmenttools/how-to-build-aem-projects-using-apache-maven.html
or http://www.cqblueprints.com/tipsandtricks/build-and-deploy-osgi/build-deploy-osgi-1.html