profiles=java5, java6, ee6
You are looking ad old version of migration document for JBoss AS 7.1 see https://docs.jboss.org/author/display/AS71/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7
The purpose of this guide is to document only those changes that are needed to successfully run and deploy AS 5 applications on AS 7. It provides information on how to resolve deployment and runtime problems and how to prevent changes in application behaviour. This is the first step in moving to the new platform. Once the application is successfully deployed and running on the new platform, plans can be made to upgrade individual components to use the new functions and features of AS7.
JBoss AS7 is structured differently from previous versions of JBoss AS, so you may want do a little research before you attempt to migrate your application. Getting Started with JBoss Application Server 7 in the Getting Started Guide has a lot of useful information, including a table that lists the features that are supported in AS 7.0. If your application uses features that go beyond the Java Enterprise Edition 6 Web Profile specification, you may want to postpone migration until release of AS 7.1 You should also read Getting started with JBoss AS for helpful information about how to install and run the application server.
The rest of this document describes some of the changes you might need to make to your application to successfully deploy and run it on AS7.
Class loading in AS7 is considerably different than in previous versions of JBoss AS. Class loading is now based on the JBoss Modules project. Instead of the more familiar hierarchical class loading environment, AS7's class loading is based on modules that have to define explicit dependencies on other modules. Deployments in AS7 are also modules, and do not have access to classes that are defined in jars in the application server unless an explicit dependency on those classes is defined.
Even though in AS7 modules are isolated by default, as part of the deployment process some dependencies on modules defined by the application server are set up for you automatically. For instance, if you are deploying a Java EE application, a dependency on the Java EE API's will be added to your module automatically. Similarly if your module contains a beans.xml file, a dependency on Weld will be added automatically, along with any supporting modules that Weld needs to operate. For a complete list of the automatic dependencies that are added see Implicit module dependencies for deployments.
The deployers within the server "implicitly" add some commonly used module dependencies, like the javax.api and sun.jdk, to the deployment so that the classes are visible to the deployment at runtime. This way the application developer doesn't have to worry about adding them explicitly. How and when these implicit dependencies are added is explained in Implicit module dependencies for deployments.
For some classes, the modules must be specified explicitly in the MANIFEST.MF as Dependencies: or “Class-Path:” entries. Otherwise you may see ClassNotFoundExceptions, NoClassDefFoundErrors, or ClassCastExceptions. You may also see runtime errors and page redirects to the JBoss Seam Debug Page. Manifest entries are explained in more detail here: Class Loading in AS7.
When you migrate your application, you may have to change the packaging structure of your EAR or WAR due to the class loading changes.
A WAR is a single module and all classes in the WAR are loaded with the same class loader. This means classes packaged in the WEB-INF/lib are treated the same as classes in WEB-INF/classes.
An EAR is different in that it consists of multiple modules. The EAR/lib directory is a single module, and every WAR or EJB jar deployment is also a separate module. Classes will not necessarily have access to other classes in the EAR unless explicit dependencies have been defined.
For more information on EAR and WAR packaging, see "WAR Class Loading" and "EAR Class Loading" in Class Loading in AS7.
Due to the modular class loading changes, when you migrate your application you might run into ClassNotFoundExceptions or ClassCastExceptions. To resolve these dependencies, you will need to find the JARs that contain the classes specified by the exceptions. Tattletale is an excellent tool that recursively scans your application and provides detailed reports about its contents. Here we use Tattletale's "Class Location" report to find the class dependency information.
This will only find dependencies on the application classes. It will not find dependencies that may be required by classes your application calls or by classes in other JARs included under your application's WEB-INF/lib directory.
Download Tattletale here.
Unzip the file into the directory of your choice.
Modify the TATTLETALE_HOME/jboss-tattletale.properties file by adding ee6 to the "profiles"
profiles=java5, java6, ee6
Uncomment scan and reports in the properties file
Extract or unzip your application WAR file into a folder.
Open a terminal and navigate the extracted WAR's WEB-INF/classes/ directory.
Create a JAR containing all of the files in the WEB-INF/classes/ directory and place it in the WEB-INF/lib/ directory as shown in the next steps.
Open a terminal and navigate to the application's WEB-INF/classes/ directory.
Create a JAR in the WEB-INF/lib/ directory that contains all the files in the WEB-INF/classes/ directory by typing:
jar cvf ../lib/foo.jar *
Following the Tattletale documentation, create the TattleTale report by issuing the command:
java -jar TATTLETALE_HOME/tattletale.jar <application-directory>/WEB-INF/lib <output-directory>
In a browser, open the <output-directory>/index.html file and click on "Depends on" under Dependencies.
Fully qualified class names can be found in italics under the “Depends On” column.
The JAR containing that class will be located to its left under the “Archive” column.
If you have defined a class-loading element, you need to remove it. The behaviour that this provokes in EAP 5 is now the default class-loading behaviour in AS 7, so it is no longer necessary. If you do not remove this element, you will see a ParseError and XMLStreamException in your server log:
javax.xml.stream.XMLStreamException: ParseError at [row,col]:[5,5] Message: Unexpected element 'class-loading' encountered at org.jboss.metadata.parser.util.MetaDataElementParser.unexpectedElement(MetaDataElementParser.java:109) at org.jboss.metadata.parser.jbossweb.JBossWebMetaDataParser.parse(JBossWebMetaDataParser.java:182) at org.jboss.as.web.deployment.JBossWebParsingDeploymentProcessor.deploy(JBossWebParsingDeploymentProcessor.java:64) ... 5 more
Depending on which components your application uses, you may need to add one or more dependencies to this file. There is more information about these dependencies in the following paragraphs.
If you modify the MANIFEST.MF file, make sure to include a newline character at the end of the file.
This file is a JBoss specific deployment descriptor that can be used to control class loading in a fine grained manner. Like the MANIFEST.MF, this file can be used to add dependencies. If can also prevent automatic dependencies from being added, define additional modules, change an EAR deployment's isolated class loading behaviour, and add additional resource roots to a module.
For additional information, see JBoss Deployment Structure File.
In previous versions of AS, the JBOSS_HOME/server/<servername>/conf/ was available in the classpath. Hence the properties files in that location were available in the classpath of the application.
In AS7, to get those properties available in the classpath, package them within your application. For example, if you are deploying a .war then package those properties in WAR WEB-INF/classes/ folder. If you want those properties accessible to all components in a .ear, then package them at the root of some .jar and place that jar in EAR lib/ folder.
ClassNotFoundExceptions can occur due to application packaging issues, unresolved dependencies, or missing archives. If the class specified is a class you have created in your application, the problem is mostly likely a packaging issue. If the class is is external to your project, you may need to explicitly define the dependencies on other modules or possibly copy an archive from a previous framework.
If the class specified in the exception is a class written specifically for the application, for example, a business class, you may need to change the packaging of the application. Due to modular class loading changes, your application may no longer be able to find classes within the EAR or WAR. In his case, you may need to move JARs to a different location within the application archive or modify class-path information so classes can be found. For more information on EAR and WAR packaging, see "WAR Class Loading" and "EAR Class Loading" in Class Loading in AS7.
For other classes, to resolve the dependency you will find the JAR that contains the class specified by the ClassNotFoundException by looking in the JBoss AS7 modules directory. If you find a module for the class, you must add a dependency to the manifest entry.
For example, if you see this ClassNotFoundException trace in the log:
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log from [Module "deployment.TopicIndex.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:188)
Find the JBoss module containing this class by doing the following:
First determine if there is an obvious module for the class
Navigate to the AS7_HOME/modules directory and look for the module path.
in this case, under modules, there is org/apache/commons/logging
Open the AS7_HOME/modules/org/apache/commons/logging/main/module.xml file and find the module name.
Add the module name to the Dependencies in the MANIFEST.MF file:
Dependencies: org.apache.commons.logging
If there is no obvious module path for the class
Find the archive that contains the class in the Tattletale report.
Find the module containing the JAR in the AS7_HOME/modules directory and determine the module name.
The module name to the Dependencies in the MANIFEST.MF file
Dependencies: org.dom4j,org.slf4j.jcl-over-slf4j
If the class is not found in a JAR packaged in a module defined by the AS7 server, find the JAR in your EAP 5.x install or your prior server's lib directory and copy it to your application's lib/ directory.
For example, when you migrate the Seam Booking appliation from EAP 5.1, you see this ClassNotFoundException in the log:
Caused by: java.lang.NoClassDefFoundError: org/hibernate/validator/ClassValidator
at java.lang.Class.getDeclaredMethods0(Native Method) [:1.6.0_25]
Open a terminal and navigate to the EAP5_HOME/ directory.
Issue the command:
grep 'org.hibernate.validator.ClassValidator' `find . \-name '*.jar'`
You should see this (one of many) for the result: Binary file ./jboss-eap-5.1/seam/lib/hibernate-validator.jar matches
Copy this JAR to the application's lib/ directory.
Rebuild and redeploy the application
This usually happens because the class is being loaded by a different class loader than the class it extends. It can also be a result of the same class existing in multiple JARs.
First find the JAR that contains the class and determine how it is being loaded. Often you need to find and remove the JAR from the application's WAR or EAR. Then you must find the dependent JBoss module containing the class, and explicitly define the dependency in the MANIFEST.MF file.
There are cases where you will need to copy in older JARs for your applcation. If the newer JARs are loaded as automatic dependencies in AS7, you may see ClassCastExceptions and need to exclude the conflicting module dependencies. This will prevent the server from adding the dependencies. This is an example of the exclusions element in the jboss-deployment-structure.xml file:
<exclusions> <module name="org.javassist" /> </exclusions>
If you are not able to figure out how the classes are loaded, you can often resolve the problem by printing class loader information to the log. For example, if you see the following ClassCastException in the log:
java.lang.ClassCastException: com.example1.Foo1 cannot be cast to com.example2.Foo2
In your code, print the class loader information by logging
logger.info("Class loader for foo1: " + com.example1.Foo1.getClass().getClassLoader().toString()); logger.info("Class loader for foo2: " + com.example2.Foo2.getClass().getClassLoader().toString());
The ModuleClassLoader information in the log will show which modules are loading the classes and, based on your application, you will need to determine the best approach to resolve the issue. You might have to remove or move a conflicting JARs, add dependencies through the MANIFEST.MF or jboss-deployment-structure.xml file or excluding dependencies in the jboss-deployment-structure.xml file.
A NoSuchMethodException indicates a class version mismatch between JAR files. It indicates your application's calling class was compiled using a different version of the JAR than the one used by the application server runtime. This can occur when you package different versions of common libraries your application, for example Hibernate. This can also happen if you migrate between versions of JBoss EAP and do not recompile your application against the updated EAP jars. To resolve this problem, remove any common JARs from your application archive, add any dependencies as described above, recompile and deploy your application.
If you get a DuplicateServiceException for a subdeployment of a JAR or a message that the WAR application has already been installed when you deploy your EAR in AS7, it may be due to the way JBoss WS handles the deployment.
If you have a WAR and a JAR with the same name within an EAR, it may create a web context with the same name as the JAR which will conflict with the WAR context. To resolve this issue, either rename the JAR or modify the context for the WAR in the application.xml file.
Usually the root cause of the exception can be found in one of the links on this page, for example, under the Component org.jboss.seam.caughtException. Use the same technique above under “How to Resolve ClassNotFoundExceptions or NoCLassDefFoundErrors” to resolve the dependencies.
For more information about the class loading changes in AS7, see Class Loading in AS7.
For more information about modular class loading, see the Module Compatible Classloading Guide.
For information about deployment module dependencies, see Deployment Module Dependencies.
In previous versions of the application server, the JCA data source configuration was defined in a file with a suffix of *-ds.xml. This file was then deployed in the server's deploy directory. The JDBC driver was copied to the server lib/ directory or packaged in the application's WEB-INF/lib/ directory.
In AS7, this has all changed. You will no longer package the JDBC driver with the application or in the server/lib directory. The *-ds.xml file is now obsolete and the datasource configuration information is now defined in the standalone/configuration/standalone.xml or in the domain/configuration/domain.xml file.
A JDBC 4-compliant driver can be installed as a deployment or as a core module. A driver that is JDBC 4-compliant contains a META-INF/services/java.sql.Driver file that specifies the driver class name. A driver that is not JDBC 4-compliant requires additional steps, as noted below.
In AS7, a datasource is configured in the server configuration file. If you are running in domain mode, the configuration file is the domain/configuration/domain.xml file. If you are running in standalone mode, you will configure the datasource in the standalone/configuration/standalone.xml file. Schema reference information, which is the same for both modes, can be found here: Datasource Descriptors.
First, you will need to create a datasource element and a driver element for your JDBC driver and datasource information in the standalone.xml or domain.xml file. You will use some of the same information that was previously defined in the *-ds.xml file.
The following is an example of a MySQL datasource element:
<datasource jndi-name="java:/YourDatasourceName" pool-name="YourDatasourceName" enabled="true" use-java-context="true"> <connection-url>jdbc:mysql://localhost:3306/YourApplicationURL</connection-url> <driver-class> com.mysql.jdbc.Driver </driver-class> <driver> mysql-connector-java-5.1.15.jar </driver> <transaction-isolation> TRANSACTION_READ_COMMITTED </transaction-isolation> <pool> <min-pool-size> 200 </min-pool-size> <max-pool-size> 300</max-pool-size> <prefill> true </prefill> <use-strict-min> false </use-strict-min> </pool> <security> <user-name> USERID </user-name> <password> PASSWORD</password> </security> <validation> <validate-on-match> false </validate-on-match> <background-validation> false </background-validation> <useFastFail> false </useFastFail> </validation> <statement> <prepared-statement-cache-size> 100 </prepared-statement-cache-size> <share-prepared-statements/> </statement> </datasource>
A JAR that is JDBC 4-compliant contains a META-INF/services/java.sql.Driver file that specifies the driver class name. This is used by the server to find name of the class(es) of the Drivers which exist in that JAR.
This is an example of the driver element for a JDBC 4-compliant MySQL driver.
<driver name="mysql-connector-java-5.1.15.jar" module="com.mysql"/>
This is an example of the driver element for driver that is not JDBC 4-compliant. The driver-class must be specified since it there is no META-INF/services/java.sql.Driver file that specifies the driver class name.
<driver name="mysql-connector-java-5.1.15.jar" module="com.mysql"> <driver-class>com.mysql.jdbc.Driver</driver-class> </driver>
For more information on how to add a MySQL driver, see Adding a MySQL datasource to JBoss AS 7.
The JDBC driver can be installed into the container in one of two ways: either as a deployment or as a core module. There are pros and cons to each approach, which will be outlined below. For a detailed explanation how to deploy JDBC 4-compliant driver jar, please refer to the DataSources chapter of the Admin Guide.
When you install the JDBC driver as a deployment, it is deployed as a regular JAR. This is the recommended way to install the driver. When you run your application server in domain mode, deployments are automatically propagated to all servers to which the deployment applies; thus distribution of the driver JAR is one less thing for administrators to worry about.
Any JDBC 4-compliant driver will automatically be recognized and installed into the system by name and version. A JDBC 4-compliant JAR is identified using the Java service provider mechanism. It contains a text a file named "META-INF/services/java.sql.Driver", which contains the name of the class(es) of the Drivers which exist in that JAR. If your JDBC driver JAR is not JDBC 4-compliant, it can be made deployable by adding the java.sql.Driver file to the JAR or by deploying the JAR with an overlay. More information on that topic can be found here: Installing a JDBC Driver as a Deployment.
In AS7 standalone mode, you simply copy the JDBC 4-compliant JAR into the AS7_HOME/standalone/deployments directory. Here is an example of a MySQL JDBC driver installed as a deployment:
AS7_HOME/standalone/deployments/mysql-connector-java-5.1.15.jar
If the JDBC driver consists of more than one JAR, for example a JAR with the driver and a dependent license JAR, you can not install the driver as a deployment. You must install the JDBC driver as a core module.
To install the driver as a module, you will need to create a directory structure under the modules folder. This structure will contain the driver and a module.xml file to define the module.
For example, using the MySQL JDBC driver above, you would create a directory structure as follows:
AS7_HOME/modules/com/mysql/main
In the main directory, you then create the following module.xml file:
<?xml version="1.0" encoding="UTF-8"?> <!-- ~ JBoss, Home of Professional Open Source. ~ Copyright 2010, Red Hat, Inc., and individual contributors as indicated by the @author tags. See the copyright.txt file in the ~ distribution for a full listing of individual contributors. ~ ~ This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as ~ published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. ~ ~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. ~ ~ You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org. --> <module xmlns="urn:jboss:module:1.0" name="com.mysql"> <resources> <resource-root path="mysql-connector-java-5.1.15.jar"/> </resources> <dependencies> <module name="javax.api"/> </dependencies> </module>
The module name, “com.mysql”, matches the directory structure for this module. Under dependencies, you specify the module's dependencies on other modules. In this case, as the case with all JDBC data sources, it is dependent on the Java JDBC APIs which are defined in another module named javax.api that is located under modules/javax/api/main.
Make sure you do NOT have a space at the beginning of module.xml file or you will get a "New missing/unsatisfied dependencies" error for this driver.
If your application uses JPA and currently bundles the Hibernate JARs, you may want to use the Hibernate that is included with AS7. You should remove the Hibernate jars from your application. You should also remove the "hibernate.transaction.manager_lookup_class" property from your persistence.xml as this is not needed.
EJB 3.1 introduced a standardized global JNDI namespace and a series of related namespaces that map to the various scopes of a Java EE application. The three JNDI namespaces used for portable JNDI lookups are java:global, java:module, and java:app. If you use JNDI lookups in your application, you will need to change them to follow the new standardized JNDI namespace convention.
To conform to the new portable JNDI namespace rules, you will need to review the JNDI namespace rules and modify the application code to follow these rules.
In AS7 there is no possibility for custom JNDI names of EJB beans and it's not planned for 7.1.
Therefor the annotation @RemoteBindings and @LocalBindings are not available.
AS7 has tightened up on JNDI namespace names to provide predictable and consistent rules for every name bound in the application server and to prevent future compatibility issues. This means you might run into issues with the current namespaces in your application if they don't follow the new rules.
Namespaces should follow these rules:
Unqualified relative names like "DefaultDS" or "jdbc/DefaultDS"
should be qualified relative to "java:comp/env", "java:module/env", or
"java:jboss/env", depending on the context.
Unqualified "absolute" names like "/jdbc/DefaultDS" should be
qualified relative to a "java:jboss/root" name.
Qualified "absolute" names like "java:/jdbc/DefaultDS" should be
qualified the same way as #2.
The special "java:jboss" namespace is shared across the entire AS
server instance.
Any "relative" name with a "java:" lead-in must be in one of the five
namespaces: "comp", "module", "app", "global", or our proprietary
"jboss". Any name starting with "java:xxx" where "xxx" is a name which
is not equal to one of the above five would result in an invalid name error.
Here's an example of a JNDI lookup in EAP 5.1. This code is usually found in an initialization method. Note the lookup name is: “OrderManagerApp/ProductManagerBean/local”.
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); }
Here is an example of how the same lookup would be coded in AS7. This code is defined as member variables. The lookup name now uses the new portable java:app JNDI namespace: “java:app/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager”
@EJB(lookup=“java:app/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager") private ProductManager productManager;
(This needs input!)
Previous Namespace |
New Namespaces |
OrderManagerApp/ProductManagerBean/local |
java:module/ProductManagerBean!services.ejb.ProductManager (EE6 standard binding, only accessible within the same module) |
OrderManagerApp/ProductManagerBean/local |
java:app/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager (EE6 standard binding, only accessible within the same application) |
OrderManagerApp/ProductManagerBean/local |
java:global/OrderManagerApp/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager (EE6 standard binding, globally accessible) |
java:comp/UserTransaction |
java:comp/UserTransaction (This will not be accessible for non EE threads, e.g. Threads your application directly creates) |
java:comp/UserTransaction |
java:jboss/UserTransaction (Globally accessible, use this if java:comp/UserTransaction is not available) |
java:/TransactionManager |
java:jboss/TransactionManager |
java:/TransactionSynchronizationRegistry |
java:jboss/TransactionSynchronizationRegistry |
Java EE6 Tutorial - Portable JNDI Syntax
Application-specified Portable JNDI Names
TODO: complete this section
TODO: complete this section
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. Regardless of your decision, because of the modular class loading changes, you will probably need to modify your application to add the required dependencies.
If you are using the old Apache/Jakarta Commons Logging, your API code will look something like the following:
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; private static Log log = LogFactory.getLog(MyClass.class.toString()); if (log.isTraceEnabled()) { log.trace("Starting..."); }
To avoid a ClassNotFoundException, you will need to add a dependency for the module that contains those classes. The module name for Apache Commons Logging is "org.apache.commons.logging", so your MANIFEST.MF file will look like this:
Dependencies: org.apache.commons.logging
If you are creating a deployment which uses Apache Log4j, you must add a dependency on the appropriate module. The Log4j module is called "org.apache.log4j", so your MANIFEST.MF should look like this:
Dependencies: org.apache.log4j
If you are creating a deployment which uses SLF4J, you must add a dependency on the appropriate module. The Log4j module is called "org.slf4j", so your MANIFEST.MF should look like this:
Dependencies: org.slf4j
If your deployment uses JDK logging, no changes need to be made to your application.
If your deployment includes modules which use more than one logging framework, it is permissible to include multiple dependencies:
Dependencies: org.slf4j, org.apache.log4j, org.apache.commons.logging
To use the new framework, you will need the change your imports and code as follows to achieve the same results as above:
import org.jboss.logging.Level; import org.jboss.logging.Logger; private static final Logger logger = Logger.getLogger(MyClass.class.toString()); if(logger.isLoggable(Level.TRACE)) { logger.log(Level.TRACE, "Starting..."); }
The JAR containing the JBoss Logging classes is located in the module named "org.jboss.logging". Your MANIFEST-MF file will look like this:
Dependencies: org.jboss.logging
For more information on how to find the module dependency, please see “How to Resolve ClassNotFoundExceptions” under the “Modular Class Loading” above.
If your application contains a persistence.xml file or the code uses @PersistenceContext or @PersistenceUnit, AS7 will detect this during deployment and assume the application uses JPA. It will implicitly add Hibernate 4 and a few other dependencies to your application classpath.
If your application currently uses Hibernate 3 libraries, in most cases, this will not be a problem. You will be able to deploy and run successfully using Hibernate 4. However, if your application uses Hibernate 3 classes that are not available in Hibernate 4, for example, some of the validator or search classes, you may see ClassNotFoundExceptions when you deploy your application. If you encounter this problem, you can try one of two approaches:
You may be able to resolve the issue by copying the specific Hibernate 3 JARs containing those classes into the application "/lib" directory or by adding them to the classpath using some other method. In some cases this may result in ClassCastExceptions or other class loading issues due to the mixed use of the Hibernate versions, so you will need to use the second approach.
You need to tell the server to use only the Hibernate 3 libraries and you will need to add exclusions for the Hibernate 4 libraries. Details on how to do this are described here: JPA Reference Guide.
For more information on Hibernate and JPA, see JPA Reference Guide.
Hibernate "text" type now maps to JDBC LONGVARCHAR
In pre-3.5 versions of Hibernate, text type were mapped to JDBC CLOB. A new Hibernate type, "materialized_clob", was added to map Java String properties to JDBC CLOB. If an application has properties configured as type="text" that are intended to be mapped to JDBC CLOB, they should be changed to type="materialized_clob" in hbm mapping files, or, if using annotations, @Type(type = "text") should be replaced by @Lob.
Numeric aggregate Criteria projections now return the same value type as their HQL counterparts. As a result, the return type from the following projections in org.hibernate.criterion have changed:
"count" and "count distinct" projections now return a Long value (due to changes in CountProjection, Projections.rowCount(), Projections.count( propertyName ), and Projections.countDistinct( propertyName )).
"sum" projections return a value type that depends on the property type due to changes in Projections.sum( propertyName ). Failure to modify your application code may result in a java.lang.ClassCastException.
for properties mapped as Long, Short, Integer, or primitive integer types, a Long value is returned;
for properties mapped as Float, Double, or primitive floating point types, a Double value is returned.
AnnotationConfigration must be merged into Configuration
Aside from the fact that AnnotationConfiguration is now deprecated, this usually is not of concern. However, if you are still using an hbm.xml file, you should be aware that AS7 now uses the org.hibernate.cfg.EJB3NamingStrategy in AnnotationConfigration instead of the older org.hibernate.cfg.DefaultNamingStrategy that was previously used in Configuration. This can result in naming mismatches. If you rely on the naming strategy to default the name of a association (many-to-many and collections of elements) table, you may see this issue. To resolve it, you can tell Hibernate to use the the legacy org.hibernate.cfg.DefaultNamingStrategy by calling Configuration#setNamingStrategy and passing it org.hibernate.cfg.DefaultNamingStrategy#INSTANCE
The namespaces for the Hibernate DTD files have changed.
If you are using Oracle, the global environment variable "hibernate.jdbc.use_streams_for_binary" must be set to true if you are using "materialized_clob" or "materialized_blob" properties.
If you are using PostgreSQL, the global environment variable "hibernate.jdbc.use_streams_for_binary" must be set to false if you are using CLOB or BLOB properties.
JBoss Cache has been replaced by Infinispan for 2nd level cache (even for non-clustered use). This requires a change to the persistence.xml file. The syntax is slightly different, depending on if you're using JPA or Hibernate second level cache. These examples assume you are using JPA.
Here's an example of the persistence.xml file in EAP 5.1:
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory"/> <property name="hibernate.cache.region.jbc2.cachefactory" value="java:CacheManager"/> <property name="hibernate.cache.use_second_level_cache" value="true"/> <property name="hibernate.cache.use_minimal_puts" value="true"/> <property name="hibernate.cache.region.jbc2.cfg.entity" value="mvcc-entity"/> <property name="hibernate.cache.region_prefix" value="services"/>
Here is what is needed to configure the same thing for a JPA application using Infinispan with AS7:
<property name="hibernate.cache.use_second_level_cache" value="true"/> <property name="hibernate.cache.use_minimal_puts" value="true"/>
Here is what is needed to configure the same thing for a native Hibernate application using Infinispan with AS7:
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"/> <property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/hibernate"/> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/> <property name="hibernate.cache.use_second_level_cache" value="true"/> <property name="hibernate.cache.use_minimal_puts" value="true"/>
Since JPA applications use Infinispan by default, fewer properties are needed to be specified. For native Hibernate applications you need to:
Select the correct Hibernate transaction factory using the hibernate.transaction.factory_class property.
Select the correct Hibernate transaction manager lookup class using the hibernate.transaction.manager_lookup_class property.
Configure the Infinispan cache region factory using one of the two options below:
If the Infinispan CacheManager is bound to JNDI, select JndiInfinispanRegionFactory as the cache region factory and add the cache manager’s JNDI name
If running JPA/Hibernate and Infinispan standalone or within third party application server, select InfinispanRegionFactory as the cache region factory
Infinispan
Using Infinspan as JPA/Hibernate Second Level Cache Provider
HIBERNATE - RelationalPersistence for Idiomatic Java
The UsersRolesLoginModule has always looked for the properties files in the classpath. In previous versions of AS, files in the JBOSS_HOME/server/SERVER_NAME/conf directory were on classpath so you could put your properties files there. In AS7 the directory structure has changed, so you need to package the properties within the application to make them available in the classpath.
To configure security for basic authentication, add a new security domain under security-domains to your standalone.xml configuration file :
<security-domain name="example"> |
If you are running in standalone mode, ${jboss.server.config.dir} refers to JBOSS_HOME/standalone/configuration/
A list of available login modules can be found in the admin guide.
In AS7 security domains no longer use the prefix java:/jaas/ in their names. Remove this prefix from the security domain configurations in jboss-web.xml for web applications and jboss.xml for enterprise applications.
AS7 sets up Resteasy for you, so there is no need to set it up yourself.
You should remove all of the resteasy configuration from your web.xml and replace it with one of the following three options:
Subclass javax.ws.rs.core.Application and use @ApplicationPath
This is the easiest way and does not require any xml configuration. Simply include a subclass of javax.ws.rs.core.Application in your application, and annotate it with the path that you want your JAX-RS classes to be available. For example:
@ApplicationPath("/mypath") public class MyApplication extends Application { }
This will make your JAX-RS resources available under /mywebappcontext/mypath.
Note that that the path is /mypath not /mypath/*
Subclass javax.ws.rs.core.Application and use web.xml
If you do not wish to use @ApplicationPath but still need to subclass Application you can set up the JAX-RS mapping in web.xml:
public class MyApplication extends Application { }
<servlet-mapping> <servlet-name>com.acme.MyApplication</servlet-name> <url-pattern>/hello/*</url-pattern> </servlet-mapping>
This will make your JAX-RS resources available under /mywebappcontext/hello.
You can also use this approach to override an application path set with the @ApplicationPath annotation.
Modify web.xml
If you don't want to subclass Application you can set the JAX-RS mapping in web.xml as follows:
<servlet-mapping> <servlet-name>javax.ws.rs.core.Application</servlet-name> <url-pattern>/hello/*</url-pattern> </servlet-mapping>
This will make your JAX-RS resources available under /mywebappcontext/hello.
Note that you only have to add the mapping, not the corresponding servlet. The server is responsible for adding the corresponding servlet automatically.
For more information, see the JAX-RS Reference Guide.
JBoss Messaging will no longer be included in EAP 6. If your application uses JBoss Messaging as the messaging provider, you will need to make changes to your application to use HornetQ.
Shut down the client and server.
Make a backup of any JBoss Messaging data.
Transfer the existing JBoss Messaging configurations to the AS7 configuration. These configurations are located in deployment descriptors on the server running JBoss Messaging. This includes the following configurations:
Connection Factory service configuration files - these files contain JMS connection factories deployed with JBoss Messaging server. JBoss Messaging stores these files in a file called connection-factories-service.xml in the deployment directory of your application server.
Destination service configurations - these files contain JMS queues and topics deployed with JBoss Messaging server. By default, these are stored in a file called destinations-service.xml in the deployment directory of your application server.
Message bridge service configurations - these files contain bridge services deployed with JBoss Messaging server. No bridges are deployed by default, so the name of the deployment file will vary, depending on your JBoss Messaging installation.
Refer to Messaging configuration for details on HornetQ configurations.
If the application code uses standard JMS, no code changes are required.
If the application code uses features specific to JBoss Messaging, modify the code to use equivalent features available in HornetQ.
JBoss Messaging uses a Managed Bean service to configure bridges and JMS objects such as connection factories, queues, and topics. HornetQ uses a POJO (Plain Old Java Object) to configure these objects instead. Update any configuration parameters to use equivalent parameters in HornetQ.
Move any messages in the JBoss Messaging database to HornetQ bindings.
For more information on HornetQ, see HornetQ Project Documentation and the HornetQ homepage.
To enable clustering in AS5 and AS6, you needed to start your server instances using the "all" profile (or some derivation of it).
e.g.
$ ./bin/run.sh -c all
In AS7, the method of enabling clustering depends on whether your servers are started via the domain controller, or as standalone servers.
To enable clustering for servers started via the domain controller, update your domain.xml and designate a server group to use the "ha" profile and "ha-sockets" socket binding group:
e.g.
<server-groups> <server-group name="main-server-group" profile="ha"> <jvm name="default"> <heap size="64m" max-size="512m"/> </jvm> <socket-binding-group ref="ha-sockets"/> </server-group> </server-group>
To enable clustering for standalone servers, start the server using the appropriate configuration file:
$ ./bin/standalone.sh --server-config=standalone-ha.xml
In AS5 and AS6, you would typically indicate the bind address used for clustering via the "-b" command line argument.
e.g.
$ ./bin/run.sh -c all -b 192.168.0.2
In AS7, bind addresses are explicitly defined by the relevant socket bindings within the AS7 configuration files. For servers started via the domain controller, bind addresses are specified within domain/configuration/host.xml. For standalone servers, bind addresses are specified within the standalone-ha.xml:
e.g.
<interfaces> <interface name="management"> <inet-address value="192.168.0.2"/> </interface> <interface name="public"> <inet-address value="192.168.0.2"/> </interface> </interfaces>
<socket-binding-groups> <socket-binding-group name="ha-sockets" default-interface="public"> <!-- ... --> </socket-binding-group> </socket-binding-groups>
In the example above, the "public" interface is specified as the default interface for all sockets within the "ha-sockets" socket binding group.
In AS5 and AS6, you could specify the multicast address and port used for intra-cluster communication using the command line arguments "-u" and "-m", respectively.
e.g.
./bin/run.sh -c all -u 228.11.11.11 -m 45688
In AS7, the multicast address and port used for intra-cluster communication are defined by the socket-binding referenced by the relevant JGroups protocol stack.
e.g.
<subsystem xmlns="urn:jboss:domain:jgroups:1.0" default-stack="udp"> <stack name="udp"> <transport type="UDP" socket-binding="jgroups-udp"/> <!-- ... --> </stack> </subsystem>
<socket-binding-groups> <socket-binding-group name="ha-sockets" default-interface="public"> <!-- ... --> <socket-binding name="jgroups-udp" port="55200" multicast-address="228.11.11.11" multicast-port="45688"/> <!-- ... --> </socket-binding-group> </socket-binding-groups>
In AS5 & AS6, you could manipulate the default protocol stack used for all clustering services via the "jboss.default.jgroups.stack" system property.
e.g.
./bin/run.sh -c all -Djboss.default.jgroups.stack=tcp
In AS7, the default protocol stack is defined by the JGroups subsystem within domain.xml or standalone-ha.xml.
e.g.
<subsystem xmlns="urn:jboss:domain:jgroups:1.0" default-stack="udp"> <stack name="udp"> <!-- ... --> </stack> </subsystem>
The jboss-maven-plugin has not been updated and does not work In AS7. You must use org.jboss.as.plugins:jboss-as-maven-plugin to deploy to the correct directory.
TODO: complete this section
TODO: complete this section
EJB 2.x support is not available in AS 7.0 but should be implemented in AS 7.1.
ToDo: Conplete this section
When you migrate a Seam 2 application, you will follow the steps outlined in the migration guide. You will need to configure the datasource as noted above. You will need to specify any module dependencies. You will also need to determine if the application has any dependencies on archives that do not ship with AS7 and copy any dependent JARs into the application lib/ directory.
Some Seam 2 examples use a default JDBC datasource named java:/DefaultDS. The easiest way is to define this datasource is to add the following datasource definition to the <jbossas7_dir>/standalone/configuration/standalone.xml file the :
<datasource jndi-name="java:/DefaultDS" pool-name="DefaultDS_Pool" enabled="true" jta="true" use-java-context="true" use-ccm="true"> <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url> <driver>h2</driver> <security> <user-name>sa</user-name> <password>sa</password> </security> </datasource>
This definition is a copy of the default HSQL datasource defined in JBoss AS 7.
You can also add the datasource using the jboss-admin command line interface:
$ <jboss-as7>/bin/jbossadmin.sh --connect [standalone@localhost:9999 /] add-data-source --jndi-name=java:/DefaultDS --connection-url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 --username=sa --password=sa --pool-name=DefaultDS_pool --driver-name=h2
Since Seam 2 applications use JSF 1.2, you will need to add dependencies for the JSF 1.2 modules and exclude the JSF 2.0 modules. You will need to create a jboss-deployment-structure.xml file in the EAR META-INF/ directory that contains the following data:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <dependencies> <module name="javax.faces.api" slot="1.2" export="true"/> <module name="com.sun.jsf-impl" slot="1.2" export="true"/> </ dependencies> </deployment> <sub-deployment name="jboss-seam-booking.war"> <exclusions> <module name="javax.faces.api" slot="main"/> <module name="com.sun.jsf-impl" slot="main"/> </exclusions> <dependencies> <module name="javax.faces.api" slot="1.2"/> <module name="com.sun.jsf-impl" slot="1.2"/> </dependencies> </sub-deployment> </jboss-deployment-structure>
If your application uses any third-party logging frameworks you will need add dependencies as described in that section of the migration guide.
Even if your Seam 2 application uses Hibernate 3, you may still be able to run with the Hibernate 4 module packaged in AS7. Some hibernate classes are no longer available and you may need to copy one or more of the older hibernate JARs into the /lib directory. If you end up with ClassNotFoundExceptions or ClassCastExceptions involving hibernate classes, you may have to exclude the hibernate module in the deployments section of the META-INF/jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <exclusions> <module name="org.hibernate"/> </exclusions> <deployment> </jboss-deployment-structure>
Remove the jboss-web.xml file from the jboss-seam-jpa.war/WEB-INF/ directory - Defined class loading in jboss-web.xml is now default behaviour.
Comment or remove hibernate property in jboss-seam-jpa.war/WEB-INF/classes/META-INF/persistence.xml:
<!-- <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/> -->
Add the following dependencies from seam distribution (seam/lib directory) into
jboss-seam-jpa.war/WEB-INF/lib directory, which were in JBoss AS 5/6 and are upgraded in JBoss AS7 to higher major version:
slf4j-api.jar
slf4j-log4j12.jar
hibernate-entitymanager.jar
hibernate-core.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-validator.jar
Add jboss-deployment-structure.xml to jboss-seam-jpa.war/WEB-INF/ with the following content in it:
<jboss-deployment-structure> <deployment> <exclusions> <module name="javax.faces.api" slot="main"/> <module name="com.sun.jsf-impl" slot="main"/> </exclusions> <dependencies> <module name="org.apache.log4j" /> <module name="org.dom4j" /> <module name="org.apache.commons.logging" /> <module name="org.apache.commons.collections" /> <module name="javax.faces.api" slot="1.2"/> <module name="com.sun.jsf-impl" slot="1.2"/> </dependencies> </deployment> </jboss-deployment-structure>
Creator |
Comment |
|||
XML File jboss-deployment-structure.xml |
0.6 kB |
Jul 18, 2011 10:50 |
jboss-deployment-structure.xml for Seam 2 JPA example migration |
When you migrate a Seam 2 application, you may see javax.naming.NameNotFoundException errors in the log like the following:
javax.naming.NameNotFoundException: Name 'jboss-seam-booking' not found in context ''
If you don't want to modify JNDI lookups throughout the code, you can modify the application's components.xml file.
First, you will need to replace the existing core-init element as follows:
<!-- <core:init jndi-pattern="jboss-seam-booking/#{ejbName}/local" debug="true" distributable="false"/> --> <core:init debug="true" distributable="false"/>
Next, find the JNDI binding INFO messages that are printed in the server log when the application is deployed. The JNDI binding messages should look similar to this:
15:01:16,138 INFO org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor (MSC service thread 1-1) JNDI bindings for session bean
named AuthenticatorAction in deployment unit subdeployment "jboss-seam-booking.jar" of deployment "jboss-seam-booking.ear" are as follows:
java:global/jboss-seam-booking/jboss-seam-booking.jar/AuthenticatorAction!org.jboss.seam.example.booking.Authenticator
java:app/jboss-seam-booking.jar/AuthenticatorAction!org.jboss.seam.example.booking.Authenticator
java:module/AuthenticatorAction!org.jboss.seam.example.booking.Authenticator
java:global/jboss-seam-booking/jboss-seam-booking.jar/AuthenticatorAction
java:app/jboss-seam-booking.jar/AuthenticatorAction
java:module/AuthenticatorAction
For each JNDI binding INFO message in the log, add a matching component element to the components.xml file:
<component class="org.jboss.seam.example.booking.AuthenticatorAction" jndi-name="java:app/jboss-seam-booking.jar/AuthenticatorAction" />
ToDo: Complete this section
For information on how to migrate Spring applications, see details at the Spring applications development and migration guide.