Where in Directory Structure Does Ejb-jar.xml Go for Creating a War File
Infrastructure and Management
- Reddened Hat Enterprise Linux
- Red Lid Virtualization
- Ruddy Hat Identity Management
- Red Hat Directory Waiter
- Red Hat Certificate Organization
- Marxist Hat Satellite
- Red Hat Subscription Management
- Red Lid Update Infrastructure
- Red Hat Insights
- Red Hat Ansible Automation Chopine
Cloud Computing
- Red Hat OpenShift
- Red Hat CloudForms
- Reddened Hat OpenStack Platform
- Red Hat OpenShift Container Platform
- Red River Chapeau OpenShift Information Science
- Ruby Lid OpenShift Online
- Red Lid OpenShift Dedicated
- Red Hat Advanced Bunch Surety for Kubernetes
- Red Hat Advanced Clump Management for Kubernetes
- Red Chapeau Quay
- Red Hat CodeReady Workspaces
- Red Chapeau OpenShift Service happening AWS
Storehouse
- Red River Hat Gluster Storage
- Red Hat Hyperconverged Infrastructure
- Red Hat Ceph Store
- Red Hat OpenShift Information Foundation
Runtimes
- Red Hat Runtimes
- Red Hat JBoss Enterprise Application Platform
- Red Hat Information Grid
- Bolshevik Lid JBoss Entanglement Server
- Red Hat Single Sign On
- Red-faced Hat support for Spring Boot
- Bolshevik Hat build of Node.js
- Red Hat build of Thorntail
- Red Chapeau build of Overshadow Vert.x
- Bloody Chapeau build of OpenJDK
- Red Chapeau make of Quarkus
- Red Hat CodeReady Studio apartment
Desegregation and Automation
- Red Hat Process Automation
- Red Hat Process Automation Manager
- Violent Hat Decision Director
Demonstrate Contents
Chapter 3. Migrate Your Application
3.1. Changes Required away Almost Applications
3.1.1. Review Changes Required aside Most Applications
Year loading and configuration changes in JBoss EAP 6 will impact almost all application. JBoss EAP 6 also uses brand-new standard portable JNDI naming syntax. These changes will impact most applications, so it is advisable you review the following information beginning when you migrate your applications programme.
3.1.2. Class Payload Changes
3.1.2.1. Update the Application Due to Course Loading Changes
Modular class loading is a significant change in JBoss EAP 6 and will impact about all covering. Refresh the following information opening when you transmigrate your application.
3.1.2.2. Understand Mental faculty Dependencies
Summary
A module is only able to access code its own classes and the classes of any mental faculty connected which IT has an expressed or implicit addiction.
Procedure 3.1. Understand Module Dependencies
-
Understand unexpressed dependencies
The deployers within the server implicitly automatically lend some commonly used module dependencies, like the
javax.api
andsun.jdk
. This makes the classes circumpolar to the deployment at runtime and relieves the developer of the undertaking of expressly adding the dependencies. For details on how and when these implicit dependencies are added, refer to Implicit Module Dependencies in the chapter entitled Course of study Loading and Modules in the Development Guidebook for JBoss EAP 6 on https://access.redhat.com/site/corroboration/JBoss_Enterprise_Application_Platform/. -
Understand explicit dependencies
For other classes, the modules must be specified expressly operating room other the lacking dependencies result in deployment or runtime errors. If a dependence is missing, you see
ClassNotFoundExceptions
orNoClassDefFoundErrors
traces in the waiter log up. If more than one module loads the same JAR operating theatre a module loads a class that extends a class loaded by a divergent module, you seeClassCastExceptions
traces in the server lumber. To specify dependencies expressly, modify theMANIFEST.MF
or create a JBoss circumstantial deployment descriptor filejboss-deployment-structure.xml
. For more entropy on module dependencies, refer to Overview of Class Loading and Modules in the chapter titled Class Loading and Module in the Development Guide for JBoss EAP 6 on https://access.redhat.com/website/documentation/JBoss_Enterprise_Application_Platform/.
3.1.2.3. Update Application Dependencies Ascribable Class Load Changes
Summary
Class loading in JBoss EAP 6 is substantially different than in previous versions of JBoss EAP. Class loading is immediately based on the JBoss Modules project. Sooner than a single, hierarchical class lumper that loads whol JARs into a flat sort out path, each library becomes a module that only links against the exact modules along which it depends. Deployments in JBoss EAP 6 are besides modules and do non have admittance to classes that are delimited in JARs in the application server unless an explicit dependency connected those classes is defined. More or less module dependencies defined past the lotion server are set up for you automatically. For instance, if you are deploying a Java EE application, a dependance on the Java EE API is added automatically, OR implicitly. For the complete list of dependencies automatically added by the server, refer to Implicit Module Dependencies in the chapter entitled Sort Loading and Modules in the Development Usher for JBoss EAP 6 connected https://access.redhat.com/site/documentation/JBoss_Enterprise_Application_Platform/.
Tasks
When you migrate your application to JBoss EAP 6, you may need to do ane or more of the next tasks owing to the modular class loading changes:
3.1.3. Configuration File Changes
3.1.3.1. Create operating room Modify Files That Master Class Burden in JBoss EAP 6
Summary
Collectable to the change in JBoss EAP 6 to use modular class loading, you may motive to make over or modify one or more files to contribute dependencies operating room to prevent automatic dependencies from loading. For more information on separate loading and classify load precedence, refer to the chapter entitled Class Loading and Modules in the Development Guide for JBoss EAP 6 along https://entree.redhat.com/land site/documentation/JBoss_Enterprise_Application_Platform/.
The following files are used to control class lading in JBoss EAP 6.
- jboss-World Wide Web.xml
-
If you have defined a
<class-loading>
element in thejboss-web.xml
file, you need to take it. The conduct that this evoked in JBoss EAP 5 is now the default option class burden behavior in JBoss EAP 6, so it is no longer necessary. If you do not remove this constituent, you find a ParseError and XMLStreamException in your server log.This is an lesson of a
<course of instruction-loading>
element in thejboss-web.xml
file that is commented out.<!DOCTYPE jboss-web Overt "-//JBoss//DTD Web Application 4.2//EN" "http://web.jboss.org/j2ee/dtd/jboss-web_4_2.dtd"> <jboss-web> <!-- <class-loading java2ClassLoadingCompliance="incorrect"> <docker-repository> seam.jboss.org:loader=MyApplication <loader-repository-config>java2ParentDelegation=false</dockhand-repository-config> </loader-repository> </year-loading> --> </jboss-vane>
- Attest.MF
-
- Manually edited
-
Dependant on which components or modules your application uses, you may take to add one or more dependencies to this file out. You butt add them as either
Dependencies
Beaver StateClass-Path
entries.The following is an example of
MANIFEST.MF
edited past a developer:Manifest-Version: 1.0 Dependencies: org.jboss.logmanager Class-Path: OrderManagerEJB.clash
If you change this file, make sure to include a newline character at the end of the file.
- Generated using Maven
-
If you use Ace, you need to qualify your
pom.xml
file to render the dependencies for theMANIFEST.MF
data file. If your application uses EJB 3.0, you may have a section in thepom.xml
file that looks like the favourable:<plugin> <groupId>org.apache.virtuoso.plugins</groupId> <artifactId>wizard-ejb-plugin</artifactId> <configuration> <ejbVersion>3.0</ejbVersion> </configuration> </plugin>
If the EJB 3.0 cipher uses
org.apache.common.lumber
, you need that dependency in theMANIFEST.Medium frequency
file. To generate that dependency, add the<plugin>
element to thepom.xml
file as follows:<plugin> <groupId>org.Apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <configuration> <ejbVersion>3.0</ejbVersion> <file away> <manifestFile>src/independent/resources/META-INF/MANIFEST.MF</manifestFile> </archive> </form> </plugin>
In the above example, the
src/main/resources/META-INF/MANIFEST.MF
lodge only needs to contain the dependance entry:Dependencies: org.apache.common land.logging
Maven will generate the complete
MANIFEST.MF
file:Manifest-Version: 1.0 Dependencies: org.apache.park.logging
- jboss-deployment-structure.xml
-
This file is a JBoss specific deployment descriptor that can be used to control division loading in a fine grained manner. Like the
MANIFEST.MF
, this file can be used to add up dependencies. It can also prevent automatic dependencies from being added, delimit additional modules, alter an EAR deployment's isolated separate loading behavior, and add additional resource roots to a module.The following is an example of a
jboss-deployment-structure.xml
file that adds a dependency for JSF 1.2 module and prevents the automatic loading of the JSF 2.0 module.<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <dependencies> <module name="javax.faces.api" expansion slot="1.2" export="true"/> <module name="com.sun.jsf-impl" slot="1.2" exportation="true"/> </dependencies> </deployment> <sub-deployment name="jboss-seam-booking.warfare"> <exclusions> <faculty name="javax.faces.api" slot="main"/> <module name="com.sun.jsf-impl" slot="main"/> </exclusions> <dependencies> <module name="javax.faces.api" expansion slot="1.2"/> <module name="com.sun.jsf-impl" slot="1.2"/> </dependencies> </sub-deployment> </jboss-deployment-structure>
- application program.xml
-
In former versions of JBoss EAP, you controlled the order of deployments within an EAR using the
jboss-app.xml
file. This is no longer the case. The Java EE6 spec provides the<initialize-in-enjoin>
component in theapplication.xml
which allows ascendency of the order in which the Coffee Electrical engineering modules inside an EAR are deployed.In most cases you fare not need to specify deployment order. If your application uses dependency injections and resource-refs to refer to components in external modules, in most cases the
<initialize-in-Holy Order>
element is not compulsory because the application server is able to implicitly determine the correct and optimal style of ordering the components.Army of the Pure's assume you have an application that contains a
myBeans.jar
and amyApp.war
that are packaged inside amyApp.ear
. A servlet in themyApp.war
uses an@EJB
annotation to inject a bean from themyBeans.jar
. Therein case, the application server has the apropos knowledge to make confident that the EJB part is available before the servlet is started and you coif not have to use the<initialize-in-regulate>
factor.However, if that servlet uses bequest JNDI lookup style remote references suchlike the tailing to access the bean, you may need to specify module order.
init() { Context ctx = new InitialContext(); ctx.lookup("TheBeanInMyBeansModule"); }
In this type, the server is not able to learn that the EJB component is in the
myBeans.jar
and you need to enforce that the components in themyBeans.shake up
are initialized and started ahead the components inmyApp.warfare
. To serve this, you set the<initialise-in-order>
constituent totrue
and specify the order of themyBeans.shake up
andmyApp.warfare
modules in theapplication.xml
file.The following is an lesson that uses the
<initialize-in-order>
constituent to control deployment order. ThemyBeans.jar
is deployed in front themyApp.war
file.<application xmlns="http://java.solarise.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6" xsi:schemaLocation="http://Java.Sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd"> <practical application-name>myApp</applications programme-constitute> <initialize-in-enjoin>true</initialize-in-ordination> <module> <ejb>myBeans.jarful</ejb> </module> <module> <web> <web-uri>myApp.war</vane-uri> <context-root>myApp</circumstance-root> </web> </module> </application>
You should be aware that scope the
<initialize-in-order>
element totrue
slows down deployment. It is preferable to define seemly dependencies using dependency injections or resource-refs because IT allows the container much flexibility in optimizing deployments. - jboss-ejb3.xml
-
The
jboss-ejb3.xml
deployment signifier replaces thejboss.xml
deployment descriptor to override and add to the features provided by the Java Enterprise Variation (EE) definedejb-jar.xml
deployment form. The new file is incompatible withjboss.xml
, and thejboss.xml
is now ignored in deployments. - login-config.xml
-
The
login-config.xml
file is no more old for security configuration. Security is now designed in the<security-domain>
element in the server shape single file. For a standalone server, this is thestandalone/configuration/standalone.xml
file. If you are spouting your host in a managed domain, this is theworld/form/domain.xml
file.
3.1.3.2. jboss-deployment-structure.xml
jboss-deployment-structure.xml
is a new optional deployment descriptor for JBoss EAP 6. This deployment form provides control over class loading in the deployment.
The XML schema for this deployment descriptor is in EAP_HOME/docs/schema/jboss-deployment-structure-1_2.xsd
3.1.3.3. Package Resources for the Modern Modular Social class Loading System
Unofficial
In previous versions of JBoss EAP, all resources inside the WEB-INF/
directory were added to the State of war classpath. In JBoss EAP 6, entanglement application artifacts are only loaded from the WEB-INF/classes
and Vane-INF/lib
directories. Nonstarter to package lotion artifacts in the specified locations rear end resultant in ClassNotFoundException
, NoClassDefError
, or other runtime errors.
To resolve these class loading errors, you moldiness modify the structure of your application file away or delineate a custom module.
- Alter the Resource Publicity
-
To make the resources forthcoming entirely to the application, you must bundle the properties files, JARs, OR other artifacts with the WAR by moving them to the
WEB-INF/classes/
operating roomNetwork-INF/lib/
directory. This approach is described in more particular here: Plane section 3.1.3.4, "Change ResourceBundle Properties Location" - Create a Custom Module
-
If you want make customs resources obtainable to all applications spurting connected the JBoss EAP 6 server, you must create a custom module. This approach is described in more contingent present: Section 3.1.3.5, "Create a Custom Module"
3.1.3.4. Change ResourceBundle Properties Location
Summary
In previous versions of JBoss EAP, the EAP_HOME/server/SERVER_NAME/conf/
directory was in the classpath and available to the application. To make properties available to the classpath of the application in JBoss EAP 6, you must package them inside your application.
Procedure 3.2. Change the ResourceBundle Properties Location
-
If you are deploying a WAR file away, you must software system those properties in the WAR's
World Wide Web-INF/classes/
folder. -
If you deficiency those properties accessible to all components in an Spike, then you must package them at the root of a Jarful and then place the Shake up in EAR's
lib/
folder.
3.1.3.5. Create a Custom Module
The following procedure describes how to make up a usance module systematic to make properties files and other resources available to all applications running on the JBoss EAP server.
Procedure 3.3. Create a Custom Faculty
-
Create and populate the
faculty/
directory structure.-
Create a directory structure subordinate the
EAP_HOME/mental faculty
directory to contain the files and JARs. For example:$ cd EAP_HOME/modules/
$ mkdir -p myorg-conf/main/properties
-
Move the properties files to the
EAP_HOME/modules/myorg-conf/chief/properties/
directory you created in the premature step. -
Create a
mental faculty.xml
file in theEAP_HOME/modules/myorg-conf/briny/
directory containing the following XML:<mental faculty xmlns="urn:jboss:module:1.1" name="myorg-conf"> <resources> <resource-root way of life="properties"/> </resources> </module>
-
-
Modify the
ee
subsystem in the waiter configuration charge. You can purpose the JBoss CLI or you can manually edit the file away.-
Follow these stairs to modify the server form file victimization the JBoss CLI.
-
Start the server and connect to the Management Command line interface.
-
For Linux, enter the following at the command line:
$ EAP_HOME/bin/jboss-CLI.sh --connect
-
For Windows, infix the following at a command line:
C:\>EAP_HOME\bin\jboss-cli.bat --connect
You should see the following response:
Conterminous to standalone controller at localhost:9999
-
-
To create the
myorg-conf
<global-modules> element in theee
subsystem, type the pursual in the command line:/subsystem=ee:write-attribute(name=global-modules, value=[{"name"=>"myorg-conf","slot"=>"chief"}])
You should see the following result:
{"outcome" => "success"}
-
-
Watch these steps if you prefer to manually edit the host configuration file.
-
Stop the server and open the server configuration file in a copyreader. If you are running a standalone server, this is the
EAP_HOME/standalone/configuration/standalone.xml
file, or theEAP_HOME/domain/constellation/domain.xml
file if you are running a managed domain. -
Find the
ee
subsystem and add the orbicular module formyorg-conf
. The following is an example of theee
subsystem element, modified to let in themyorg-conf
element:<subsystem xmlns="urn:jboss:domain:EE:1.0" > <global-modules> <mental faculty appoint="myorg-conf" time slot="main" /> </spherical-modules> </subsystem>
-
-
-
Assuming you copied a file called
my.properties
into the correct faculty localization, you are now able to lading properties files using code similar to the undermentioned:Weave.currentThread().getContextClassLoader().getResource("my.properties");
3.1.4. Logging Changes
3.1.4.1. Modify Logging Dependencies
Summary
JBoss LogManager supports front ends for all logging frameworks, so you can keep your current logging code or move to the new JBoss logging infrastructure. Disregardless of your decision, because of the standard socio-economic class loading changes, you probably need to modify your application to add the required dependencies.
Procedure 3.4. Update application logging code
3.1.4.2. Update Practical application Code for Third-party Logging Frameworks
Concise
In JBoss EAP 6, logging dependencies for common ordinal-political party frameworks like Apache Commons Logging, Apache log4j, SLF4J, and Java Logging are added by default. In about cases, it is preferable to use the logging framework provided by the JBoss EAP container. However, if you require peculiar functionality provided by a third-party framework, you must exclude the corresponding JBoss EAP module from your deployment. Mention that although your deployment uses the third-party logging framework, the host logs continue to use the JBoss EAP logging subsystem configuration.
The following procedures present how to exclude the JBoss EAP 6 org.apache.log4j
module from your deployment. The offse procedure plant on whatsoever release of JBoss EAP 6. The arcsecond procedure applies only to JBoss EAP 6.3 Beaver State advanced.
Procedure 3.5. Configure JBoss EAP 6 to manipulation a log4j.properties or log4j.xml file in
This procedure works for all versions of JBoss EAP 6.
Because this method uses a log4j form file in, you volition no thirster constitute healthy to change the log4j logging configuration at runtime.
-
Create a
jboss-deployment-structure.xml
with the following cognitive content:<jboss-deployment-structure> <deployment> <!-- Exclusions tolerate you to preclude the server from automatically adding some dependencies --> <exclusions> <module name="org.apache.log4j" /> </exclusions> </deployment> </jboss-deployment-structure>
-
Place the
jboss-deployment-structure.xml
file in either theMETA-INF/
directory operating theatre theWEB-INF/
directory if you are deploying a WAR, or in theMETA-INF/
directory if you are deploying an EAR. If your deployment includes pendant child deployments, you must also exclude the module for each subdeployment. -
Include the
log4j.properties
surgerylog4j.xml
lodge in thelib/
directory of your EAR, or theWEB-INF/classes/
directory of your WAR deployment. If you prefer to place the file inlib/
directory of your WAR, you mustiness limit the<resource-side>
path in thejboss-deployment-structure.xml
file.<jboss-deployment-body structure> <deployment> <!-- Exclusions allow you to preclude the server from automatically adding some dependencies --> <exclusions> <module name="org.apache.log4j" /> </exclusions> <resources> <resource-rootage path="lib" /> </resources> </deployment> </jboss-deployment-structure>
-
Start the JBoss EAP 6 server with the following runtime arguin to forbid a
ClassCastException
from appearing in the console when you deploy the application:-Dorg.jboss.as.logging.per-deployment=dishonorable
-
Deploy your application.
Procedure 3.6. Configure Logging Dependencies for JBoss EAP 6.3 or later
In JBoss EAP 6.3 and later, you can use the new add-logging-api-dependencies
logging system ascribe to turf out 3rd company logging theoretical account dependencies. The following steps demonstrate how to modify this logging attribute along a JBoss EAP standalone server.
-
Bulge out the JBoss EAP 6 server with the following runtime argument to foreclose a
ClassCastException
from appearance in the console when you deploy the application:-Dorg.jboss.as.logging.per-deployment=unreal
-
Open a depot and connect to the Management CLI.
-
For Linux, enter the following at the command line:
$ EAP_HOME/bin/jboss-cli.sh --connect
-
For Windows, insert the following at a command line:
C:\>EAP_HOME\bin\jboss-CLI.drub --connect
-
-
Modify the
add-logging-api-dependencies
attribute in the logging subsystem.This property controls whether the container adds implicit logging API dependencies to your deployments.
-
If set to
true
, which is the nonpayment, all unverbalized logging API dependencies are added. -
If set to
false
, the dependencies are not added to your deployments.
To kick out the third-party logging framework dependencies, you must set this attribute to
false
using the following command:/subsystem=logging:spell-attribute(name=minimal brain damage-logging-api-dependencies, prise=false)
This command adds the
<add-logging-api-dependencies>
element to thelogging
subsystem of thestandalone.xml
form file.<subsystem xmlns="urn:jboss:domain:logging:1.4"> <add-logging-api-dependencies value="dishonest"/> .... </subsystem>
-
-
Deploy your lotion.
3.1.4.3. Modify Code to Use the New JBoss Logging Framework
Summary
To use the new framework, change your imports and code as follows:
Procedure 3.7. Qualify Code and Dependencies to Use the JBoss Logging Theoretical account
-
Change your imports and logging codification
The followers is an example of cipher that uses the recently JBoss Logging framework:
importee org.jboss.logging.Level; import org.jboss.logging.Logger; private static final Logger faller = Logger.getLogger(MyClass.class.toString()); if(logger.isTraceEnabled()) { logger.tracef("Starting...", subsystem); }
-
Add the logging dependency
The JAR containing the JBoss Logging classes is located in the module named
org.jboss.logging
. YourPatent-MF
file out should look like this:Evidence-Version: 1.0 Dependencies: org.jboss.logging
3.1.5. Lotion Promotion Changes
3.1.5.1. Modify Packaging of EARs and WARs
Summary
When you migrate your application, you Crataegus oxycantha have to change the packaging structure of your EAR or WAR referable the change to modular separate loading. Module dependencies are loaded in this specific ordain:
-
System dependencies
-
User dependencies
-
Local resources
-
Inter-deployment dependencies
Procedure 3.8. Modify archive packaging
-
Computer software a State of war
A WAR is a single mental faculty and all classes in the Warfare are unexploded with the unvaried class docker. This means classes prepackaged in the
WWW-INF/lib/
directory are treated the same as classes in theWEB-INF/classes
directory. -
Package an EAR
An EAR consists of multiple modules. The
EAR/lib/
directory is a single module and every State of war or EJB jar subdeployment within the EAR is a separate module. Classes do not have access to classes in other modules within the EAR unless explicit dependencies take up been defined. Subdeployments forever have an automatic addiction on the rear module which gives them memory access to classes in theEAR/lib/
directory. However, subdeployments dress not always possess an automatic dependency to tolerate them to access each other. This behavior is controlled by setting the<auricle-subdeployments-isolated>
element in theee
subsystem configuration as follows:<subsystem xmlns="urn:jboss:domain:EE:1.0" > <ear-subdeployments-isolated>false</pinna-subdeployments-isolated> </subsystem>
Past default this is set to false which allows the subdeployments to see classes belonging to other subdeployments inside the Auricle.
3.1.6. Datasource and Resource Arranger Configuration Changes
3.1.6.1. Update the Application Referable Configuration Changes
In JBoss EAP 5, services and subsystems were configured in many diametrical files. In JBoss EAP 6, constellation is straight off done mainly in one file. If your application uses any of the following resources or services, conformation changes May personify needed.
3.1.6.2. Update the DataSource Configuration
Unofficial
In past versions of JBoss EAP, the JCA datasource configuration was defined in a file with a suffix of *-darmstadtium.xml
. This file was and so deployed in the server's deploy/
directory surgery packaged with the application. The JDBC driver was copied to the server/lib/
directory or packaged in the application's WEB-INF/lib/
directory. Spell this method of configuring a datasource is motionless supported for development, IT is not recommended for production because IT is not supported by the JBoss administrative and direction tools.
In JBoss EAP 6, the datasource is configured in the waiter configuration single file. If the JBoss EAP 6 instance is running in a managed domain, the datasource is configured in the domain/configuration/sphere.xml
file out. If the JBoss EAP 6 instance is running as a standalone server, the datasource is organized in the standalone/configuration/standalone.xml file
. Datasources configured this way can equal managed and obsessed using the JBoss management interfaces, including the Network Management Console and command line interface (CLI). These tools make IT easy to superintend deployments and configure ninefold servers squirting in a managed domain.
The following incision describes how to modify your datasource configuration thusly that it can be managed and backed aside the easy management tools.
Transmigrate to a Manageable Datasource Configuration for JBoss EAP 6
A JDBC 4.0 compliant driver can be installed as a deployment Beaver State as a core module. A driver that is JDBC 4.0 compliant contains a META-INF/services/coffee.sql.Driver
file cabinet that specifies the driver class diagnose. A driver that is not JDBC 4.0 compliant requires additional steps. For inside information on how to make a driver JDBC 4.0 compliant and how update your underway datasource shape to 1 that is manageable by the Web Management Console and CLI, realise Section 3.1.6.3, "Install and Configure the JDBC Driver".
3.1.6.3. Install and Configure the JDBC Driver
Summary
The JDBC number one wood can be installed into the container in unitary of the following two slipway:
-
Atomic number 3 a deployment
-
As a core module
The pros and cons of each approach are noted below.
In JBoss EAP 6, the datasource is configured in the server configuration file. If the JBoss EAP 6 instance is running in a managed domain, the datasource is configured in the domain/configuration/domain.xml
file. If the JBoss EAP 6 instance is running equally a standalone server, the datasource is organized in the standalone/configuration/standalone.xml
file. Schema reference information, which is the unvaried for both modes, can personify found in the docs/schema/
directory of the JBoss EAP 6 put in. For purposes of this discussion, assume the server is running as standalone server and the datasource is configured in the standalone.xml
file out.
Procedure 3.9. Install and Configure the JDBC Device driver
-
Put in the JDBC Device driver.
-
Install the JDBC Device driver as a deployment.
This is the recommended way to establis the driver. When the JDBC driver is installed as a deployment, it is deployed As a regular JAR. If the JBoss EAP 6 instance is moving equally a standalone server, copy the JDBC 4.0 lamblike JAR into the
EAP_HOME/standalone/deployments/
directory. For a managed realm, you must use the Direction Console operating theater Management CLI to deploy the JAR to the server groups.The following is an model of a MySQL JDBC driver installed as a deployment to a standalone server:
$cp mysql-connector-java-5.1.15.jar
EAP_HOME/standalone/deployments/
Whatever JDBC 4.0 amenable driver is automatically recognized and installed into the scheme by name and variation. A JDBC 4.0 compliant JAR contains a text Indian file titled
META-INF/services/Java.sql.Driver
which specifies the device driver class name(s). If the driver is not JDBC 4.0 amenable, IT can glucinium made deployable in one of the following ways:-
Create and add a
java.sql.Driver
file to the Jounce under theMETA-INF/services/
path. This file should carry the number one wood class figure, for example:com.mysql.jdbc.Driver
-
Create a
Java.sql.Driver
file in the deployment directory. For a JBoss EAP 6 instance running as a standalone host, the file should be situated here:EAP_HOME/standalone/deployments/META-INF/services/java.sql.Number one wood
. If the waiter is in a managed domain, you must use the Management Console or Direction Command line interface to deploy the file.
The pros of this approach are:
-
This is the easiest method because in that respect is zero necessitate to define a module.
-
When the waiter is running in a managed demesne, deployments that wont this approach are automatically propagated to completely servers in the domain. This means the administrator does not want to circularise the driver JAR manually.
The cons of this approach are:
-
If the JDBC number one wood consists of more than one JAR, e.g. the driver JAR plus a dependent permit JAR or localization Jounce, you can not install the driver as a deployment. You must set up the JDBC device driver as a pith mental faculty.
-
If the driver is not JDBC 4.0 nonresistant, a file must be created containing the driver class name(s) and must be imported into the JAR or overlayed in the
deployments/
directory.
-
-
Install the JDBC Driver as a core module.
To install a JDBC driver as a substance mental faculty, you must create a file path bodily structure under the
EAP_HOME/modules/
directory. This structure contains the JDBC driver JAR, any additional vendor license or localization JARs, and amodule.xml
file to define the module.-
Instal the MySQL JDBC Driver as a core module
-
Create the directory structure
EAP_HOME/modules/com/mysql/main/
-
In the
of import/
subdirectory, make over afaculty.xml
file out containing the following module definition for the MySQL JDBC driver:<?xml reading="1.0" encryption="UTF-8"?> <module xmlns="urn:jboss:module:1.0" name="com.mysql"> <resources> <resource-root path="mysql-connection-java-5.1.15.jar"/> </resources> <dependencies> <module key="javax.api"/> </dependencies> </mental faculty>
The module name, "com.mysql", matches the directory body structure for this mental faculty. The
<dependencies>
ingredient is accustomed qualify this module's dependencies on other modules. Therein incase, as is the case with every JDBC datasources, it is dependent on the Java JDBC APIs which are defined in another module namedjavax.api
. That faculty is located under themodules/arrangement/layers/inferior/javax/api/main/
directory.Make a point you exercise Non have a blank space at the kickoff of
module.xml
file cabinet or you will get a "Other lacking/unsatisfied dependencies" error for this driver. -
Replicate the MySQL JDBC driver JAR into the
EAP_HOME/modules/com/mysql/chief/
directory:$ cp mysql-connector-coffee-5.1.15.jar
EAP_HOME/modules/com/mysql/main/
-
-
Install the IBM DB2 JDBC driver and license JAR as a core module.
This case is provided to only prove how to deploy drivers that postulate JARs to boot to the JDBC Device driver JAR.
-
Create the directory structure
EAP_HOME/modules/com/ibm/db2/main/
. -
In the
main/
subdirectory, create amodule.xml
charge containing the following module definition for the IBM DB2 JDBC number one wood and license:<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.1" name="com.ibm.db2"> <resources> <resource-root way of life="db2jcc.jar"/> <resource-root path="db2jcc_license_cisuz.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
Make sure you do NOT have a space at the beginning of
module.xml
file or you will get a "New wanting/unsatisfied dependencies" wrongdoing for this device driver. -
Copy the JDBC driver and license JAR to the
EAP_HOME/modules/com/ibm/db2/main/
directory.$ cp db2jcc.jolt
EAP_HOME/modules/com/ibm/db2/main/
$ cp db2jcc_license_cisuz.jarEAP_HOME/modules/com/ibm/db2/main/
-
The pros of this approach are:
-
This is the only approach that works when the JDBC driver consists of more than one Collide.
-
With this approach, drivers that are not JDBC 4.0 compliant can embody installed without modifying the driver Jounce Oregon creating a file sheathing.
The cons of this approach are:
-
It is more difficult to set up a module.
-
The module must be manually traced to every waiter running in a managed domain.
-
-
-
Configure the datasource.
-
Supply the database driver.
Add the
<number one wood>
element to the<drivers>
element of the same file. Once more, this contains some of the same datasource entropy that was previously distinct in the*-Doctor of Science.xml
file.First watch if the driver JAR is JDBC 4.0 compliant. A JAR that is JDBC 4.0 lamblike contains a
META-INF/services/Java.sql.Device driver
file that specifies the driver course of study name. The server uses this file cabinet to find the refer of the driver class(atomic number 99) in the JAR. A driver that is JDBC 4.0 compliant does not require a<driver-class>
constituent since it is already specified in the JAR. This is an example of the driver element for a JDBC 4.0 compliant MySQL driver:<number one wood name="mysql-connector-java-5.1.15.jar" mental faculty="com.mysql"/>
A driver that is not JDBC 4.0 compliant requires a
<driver-class>
attribute to nam the driver class since there is atomic number 102META-INF/services/java.sql.Device driver
file that specifies the driver class epithet. This is an instance of the driver element for driver that is not JDBC 4.0 compliant:<driver call="mysql-connecter-java-5.1.15.jar" faculty="com.mysql"> <driver-class>com.mysql.jdbc.Driver</driver-separate></driver>
-
Create the datasource.
Produce a
<datasource>
element in the<datasources>
section of thestandalone.xml
file. This file contains much of the same datasource information that was previously defined in the*-DS.xml
file.You must stop the server before editing the server configuration file for your convert to embody persisted on server restart.
The next is an example of a MySQL datasource element in the
standalone.xml
charge:<datasource jndi-diagnose="java:/YourDatasourceName" syndicate-public figure="YourDatasourceName"> <connection-url>jdbc:mysql://localhost:3306/YourApplicationURL</connectedness-uniform resource locator> <device driver>mysql-connector-java-5.1.15.jar</device driver> <dealing-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <pool> <min-pool-size>100</Taiwanese-syndicate-size> <max-pond-size>200</liquid ecstasy-pool-size> </pool> <security> <user-key>USERID</user-identify> <word>PASSWORD</password> </security department> <program line> <prepared-statement-cache-size>100</willing-statement-cache-size of it> <share-prepared-statements/> </financial statement> </datasource>
-
-
Update JNDI references in the application write in code.
You must also replace whatever alive
@Resource
annotations that access the datasource to use the new JNDI name. For example:@Imagination(name = "java:/YourDatasourceName").
3.1.6.4. Configure the Datasource for Hole up operating theatre JPA
If your application uses JPA and currently bundles the Hole up JARs, you Crataegus laevigata deprivation to habituate the Hibernate that is included with JBoss EAP 6. To use this version of Hibernate, you essential remove the old Hibernate package from your application.
Procedure 3.10. Remove the Hole up bundle
-
Remove the Hibernate JARs from your application program library folders.
-
Remove OR comment kayoed the
<hibernate.dealing.manager_lookup_class>
ingredient in yourtenaciousness.xml
file as this constituent is not necessary.
3.1.6.5. Update the Resource Adapter Configuration
Summary
In previous versions of the application host, the resource adapter form was circumscribed in a single file with a postfix of *-ds.xml
. In JBoss EAP 6, a resource transcriber is configured in the waiter configuration file. If you are running in a managed field, the configuration file is the EAP_HOME/domain/configuration/domain.xml
file. If you are running as a standalone server, configure the resourcefulness adaptor in the EAP_HOME/standalone/form/standalone.xml
file. Schema reference selective information, which is the very for both modes, can atomic number 4 found low Schemas along the IronJacamar web site present: http://www.ironjacamar.org/documentation.html.
You moldiness full stop the server before redaction the host configuration data file for your change to be persisted happening server restart.
Define the resource adapter
The resourcefulness adaptor descriptor information is defined subordinate the following subsystem element in the server configuration file:
<subsystem xmlns="urn:jboss:domain:imagination-adapters:1.1"/>
You will manipulation more or less of the same information that was antecedently defined in the resource adapter *-ds.xml
file.
The following is an example of a resource adapter factor in the host configuration file:
<resource-adapters> <resource-adapter> <archive>eightfold-full.rar</file away> <config-property name="Name">ResourceAdapterValue</config-property> <transaction-support>NoTransaction</transaction-support> <connection-definitions> <connection-definition class-advert="org.jboss.jca.exam.deployers.specification.rars.multiple.MultipleManagedConnectionFactory1" enabled="correct" jndi-diagnose="java:/eis/MultipleConnectionFactory1" pool-name="MultipleConnectionFactory1"> <config-property name="Name">MultipleConnectionFactory1Value</config-property> </link-definition> <association-definition class-name="org.jboss.jca.test.deployers.spec.rars.multiple.MultipleManagedConnectionFactory2" enabled="accurate" jndi-distinguish="java:/eis/MultipleConnectionFactory2" pool-name="MultipleConnectionFactory2"> <config-property name="Name">MultipleConnectionFactory2Value</config-property> </association-definition> </connection-definitions> <admin-objects> <admin-object class-name="org.jboss.jca.test.deployers.specification.rars.quadruplicate.MultipleAdminObject1Impl" jndi-bring up="java:/eis/MultipleAdminObject1"> <config-property name="Name">MultipleAdminObject1Value</config-property> </admin-object> <admin-object class-name="org.jboss.jca.try out.deployers.spec.rars.multiple.MultipleAdminObject2Impl" jndi-name="Java:/eis/MultipleAdminObject2"> <config-property name="Name">MultipleAdminObject2Value</config-property> </admin-objective> </admin-objects> </resource-adapter> </resource-adapters>
3.1.7. Security Changes
3.1.7.1. Configure Application Security Changes
Configure security for basic authentication
In premature versions of JBoss EAP, properties files placed in the EAP_HOME/server/SERVER_NAME/conf/
directory were on classpath and could be easy found aside the UsersRolesLoginModule
. In JBoss EAP 6, the directory social structure has changed. Properties files must be prepacked inside the application to arrive at them available in the classpath.
You must terminate the server in front editing the host configuration file for your change to be persisted on server restart.
To configure security for radical hallmark, add a inexperient security measures domain under security measur-domains
to the standalone/shape/standalone.xml
or the sphere/configuration/domain.xml
server configuration file cabinet:
<security-domain name="exercise"> <authentication> <login-module write in code="UsersRoles" swag="required"> <faculty-option identify="usersProperties" esteem="${jboss.server.config.dir}/example-users.properties"/> <mental faculty-option cite="rolesProperties" value="${jboss.waiter.config.dir}/example-roles.properties"/> </login-module> </authentication> </security-domain>
If the JBoss EAP 6 instance is running A a standalone server, ${jboss.waiter.config.dir}
refers to the EAP_HOME/standalone/conformation/
directory. If the instance is running in a managed domain, ${jboss.host.config.dir}
refers to the EAP_HOME/domain/conformation/
directory.
Modify security domain names
In JBoss EAP 6, security domains no yearner employment the prefix java:/jaas/
in their name calling.
-
For Web applications, you must remove this prefix from the security domain configurations in the
jboss-entanglement.xml
. -
For Enterprise applications, you must remove this prefix from the security domain configurations in the
jboss-ejb3.xml
file. This file cabinet has replaced thejboss.xml
in JBoss EAP 6.
3.1.7.2. Update Applications That Use PicketLink STS and Web Services
Summary
If your JBoss EAP 6.1 application uses PicketLink STS and Web services, you may need to make changes when you migrate to JBoss EAP 6.2 or later. A furbish up applied to JBoss EAP to address CVE-2013-2133 enforces authorization checks away the container before running any JAXWS handlers attached to EJB3-based WS endpoints. As a consequence, some PicketLink STS functionality tush be affected because the PicketLink SAML2Handler
establishes a security principal that is intended to comprise used after in the outgrowth. You may see a NullPointerException
in the server log because the principal is NULL
when the HandlerAuthInterceptor
accesses the SAML2Handler
. You must disable this security department arrest to fix this problem.
Procedure 3.11. Incapacitate Extra Authorization Checks
-
You can disable the additional authorization checks and keep using the existing PicketLink deployments by using extraordinary of the favorable methods.
-
Set a System-wide Property
You privy disable additional authorisation checks at the server horizontal aside setting the
org.jboss.ws.cxf.disableHandlerAuthChecks
system holding value toapodictic
. This method affects any deployment made to the application waiter.For information on how to set a system property, see the topic entitled Configure System Properties Victimisation the Management CLI in the Administration and Form Guide for JBoss EAP.
-
Make over a Property in the Deployment's Web Services Form File
You can disable additional authorization checks at the deployment level past background the
org.jboss.ws.cxf.disableHandlerAuthChecks
property value totrue
in thejboss-webservices.xml
file. This method impacts only the specific deployment.-
Create a
jboss-webservices.xml
file in theMETA-INF/
directory of the deployment in which you want to disable extra authorization checks. -
Add the following content:
<?xml version="1.1" encryption="UTF-8"?> <webservices xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee"> <property> <name>org.jboss.ws.cxf.disableHandlerAuthChecks</name> <value>trustworthy</value> </property> </webservices>
-
-
Sanctioning the org.jboss.ws.cxf.disableHandlerAuthChecks
dimension renders a system vulnerable to CVE-2013-2133. If the application expects surety restrictions professed happening EJB methods to atomic number 4 applied and does non apply them self-sufficing to the JAX-WS handler, and then the property should not be enabled. The attribute should only cost used for purposes of backwards compatibility when needed to avoid breaking the application.
3.1.8. JNDI Changes
3.1.8.1. Update Application JNDI Namespace Name calling
Summary
EJB 3.1 introduced a standardized global JNDI namespace and a series of age-related namespaces that map to the versatile scopes of a Java EE applications programme. Portable EJB names only get bound to 3 of them: java:global
, java:module
, and Java:app
. Applications with EJBs that use JNDI must be changed to keep abreast the new standardised JNDI namespace convention.
Procedure 3.12. Modify JNDI lookups
3.1.8.2. Portable EJB JNDI Names
Summary
The Coffee EE 6 spec defines four logical namespaces, each with its own scope, merely portable EJB name calling only get recoil to ternary of them. The following table details when and how to habituate each namespace.
Table 3.1. Portable JNDI Namespaces
JNDI Namespace | Verbal description |
---|---|
java:global | Names in this namespace are shared by all applications deployed in an application host instance. Use name calling in that namespace to chance EJBs outside archives deployed to the same server. The following is an example of a Java:global namespace: |
Java:module | Names in this namespace are divided up by entirely components in a module, for example, every last enterprise beans in a single EJB faculty or totally components in a web module. The favourable is an example of a java:module namespace: |
java:app | Names in this namespace are shared past all components in complete modules in a single application. For example, a WAR and an EJB jar lodge in the same EAR file would have entree to resources in the coffee:app namespace. The following is an example of a java:app namespace: |
You can find more information about JNDI denotive contexts in plane section EE.5.2.2, "Application Component Surroundings Namespaces" in the "JSR 316: JavaTM Political program, Enterprise Edition (Java EE) Stipulation, v6". You can download the specification from here: http://jcp.org/en/jsr/detail?ID=316
3.1.8.3. Review the JNDI Namespace Rules
Summary
JBoss EAP 6 has landscaped upon JNDI namespace names, non only to provide predictable and consistent rules for every bring up bound in the application server, just also to forbid future compatibility issues. This means you might run into issues with the current namespaces in your covering if they Don't follow the raw rules.
Namespaces should follow these rules:
-
Unmodified comparative name calling like
DefaultDS
orjdbc/DefaultDS
should be qualified relative tocoffee:comprehensive examination/env
,java:module/env
, orjava:jboss/env
, depending happening the context of use. -
Unqualified
absolute
name calling like/jdbc/DefaultDS
should equal competent relative to ajava:jboss/root
name. -
Qualified
absolute
names likejava:/jdbc/DefaultDS
should be qualified the similar way As Straight-outabsolute
names above. -
The special
Java:jboss
namespace is divided across the total AS server instance. -
Some
relative
name with ajava:
prefix must be in indefinite of the five namespaces:comprehensive
,module
,app
,global
, or the proprietaryjboss
. Whatever name starting withjava:XXX
where xxx does non match any of the above five would resolution in an invalid name erroneousness.
3.1.8.4. Modify the Application to Follow the New JNDI Namespace Rules
-
Hera is an exercise of a JNDI lookup in JBoss EAP 5.1. This code is usually ground in an initialisation method acting.
private ProductManager productManager; try { context = new InitialContext(); productManager = (ProductManager) context.lookup("OrderManagerApp/ProductManagerBean/local"); } catch(Exception lookupError) { throw new ServletException("Unable to find the ProductManager bean", lookupError); }
Promissory note the lookup name is
OrderManagerApp/ProductManagerBean/topical anaestheti
. -
The tailing is an example of how the same lookup would be coded in JBoss EAP 6 exploitation dependency injection.
@EJB(lookup="java:app/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager") private ProductManager productManager;
The lookup values are now defined as member variables and utilise the modern portable
Java:app
JNDI namespace bring upjava:app/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager
. -
If you prefer not to role dependency injection, you can go forward to create the new InitialContext as in a higher place and modify the search to use the new JNDI namespace name.
private ProductManager productManager; try on { linguistic context = new InitialContext(); productManager = (ProductManager) context.lookup("java:app/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager"); } catch(Elision lookupError) { throw new ServletException("Unable to find the ProductManager bean", lookupError); }
3.1.8.5. Examples of JNDI Namespaces in Previous Releases and How They are Specified in JBoss EAP 6
Table 3.2. JNDI Namespace Mapping Table
Namespace in JBoss EAP 5.x | Namespace in JBoss EAP 6 | Extra Comments |
---|---|---|
OrderManagerApp/ProductManagerBean/local | Java:module/ProductManagerBean!services.ejb.ProductManager | Java Electrical engineering 6 criterion binding. Scoped to the current module and only accessible within the same module. |
OrderManagerApp/ProductManagerBean/local | java:app/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager | Java Electrical engineering 6 standard book binding. Scoped to the current lotion and only accessible inside the same application program. |
OrderManagerApp/ProductManagerBean/local | java:global/OrderManagerApp/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager | Java EE 6 standard book binding. Scoped to the application host and globally ready to hand. |
java:comp/UserTransaction | java:comp/UserTransaction | Namespace is scoped to the current ingredient. Non accessible for togs that are not Java EE 6, for example, togs created directly by your application. |
java:comp/UserTransaction | java:jboss/UserTransaction | Globally accessible. Usage this if java:comp/UserTransaction is not uncommitted. |
java:/TransactionManager | java:jboss/TransactionManager | |
coffee:/TransactionSynchronizationRegistry | java:jboss/TransactionSynchronizationRegistry |
Where in Directory Structure Does Ejb-jar.xml Go for Creating a War File
Source: https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/6.3/html/migration_guide/chap-migrate_your_application
0 Response to "Where in Directory Structure Does Ejb-jar.xml Go for Creating a War File"
إرسال تعليق