Book Image

WildFly: New Features

By : Filippe C Spolti
Book Image

WildFly: New Features

By: Filippe C Spolti

Overview of this book

Table of Contents (13 chapters)
WildFly: New Features
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Deploying the same application on two servers


Let's use the app2-v01-logging.war application.

The deployment occurred as expected and the logs were printed. If you remember, this app has been developed for testing with WildFly; thus, the same deployment would occur with this application if it were developed for JBoss 7, and there would be no problems. Refer to the following logs. Let's see the results when you deploy in JBoss7:

13:43:13,901 INFO  [br.com.caelum.vraptor.core.DefaultConverters] (MSC service thread 1-3) Registering bundled converters
13:43:13,958 INFO  [br.com.caelum.vraptor.http.route.
DefaultRouteBuilder] (MSC service thread 1-3) /home                                             [ALL] -> HomeController.home(String)
13:43:13,960 INFO  [br.com.caelum.vraptor.VRaptor] (MSC service thread 1-3) VRaptor 3.3.1 successfuly initialized
13:43:13,989 INFO  [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /log
13:43:13,997 INFO  [org.jboss.as] (MSC service thread 1-6) JBAS015951: Admin console listening on http://127.0.0.1:9990
13:43:13,997 INFO  [org.jboss.as] (MSC service thread 1-6) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 4654ms - Started 184 of 264 services (78 services are passive or on-demand)
13:43:14,126 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "app2-v01-logging-2.0.1-SNAPSHOT.war"
13:44:14,434 INFO  [org.hibernate.validator.util.Version] (http--127.0.0.1-8080-1) Hibernate Validator 4.2.0.Final
13:44:14,583 FATAL [com.wflybook.HomeController] (http--127.0.0.1-8080-1) This is a fatal message, a high level message error.
13:44:14,583 ERROR [com.wflybook.HomeController] (http--127.0.0.1-8080-1) This is a error message.
13:44:14,583 WARN  [com.wflybook.HomeController] (http--127.0.0.1-8080-1) This is a warning message.
13:44:14,584 INFO  [com.wflybook.HomeController] (http--127.0.0.1-8080-1) This is a information message.

Now, note the WildFly logs:

13:49:04,837 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017534: Register web context: /log
13:49:04,888 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "app2-v01-logging-2.0.1-SNAPSHOT.war" (runtime-name : "app2-v01-logging-2.0.1-SNAPSHOT.war")
13:49:04,963 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
13:49:04,963 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
13:49:04,963 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.CR1 "WildFly" started in 9095ms - Started 259 of 316 services (90 services are lazy, passive or on-demand)
^[13:49:13,079 INFO  [br.com.caelum.vraptor.config.BasicConfiguration] (default task-1) Using class br.com.caelum.vraptor.ioc.spring.SpringProvider as Container Provider
...
13:49:13,394 INFO  [br.com.caelum.vraptor.core.DefaultConverters] (default task-1) Registering bundled converters
13:49:13,461 INFO  [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (default task-1) /home                                             [ALL] -> HomeController.home(String)
13:49:13,464 INFO  [br.com.caelum.vraptor.VRaptor] (default task-1) VRaptor 3.3.1 successfuly initialized
13:49:13,668 INFO  [org.hibernate.validator.internal.util.Version] (default task-1) HV000001: Hibernate Validator 5.0.2.Final
13:49:13,887 FATAL [com.wflybook.HomeController] (default task-1) This is a fatal message, a high level message error.
13:49:13,888 ERROR [com.wflybook.HomeController] (default task-1) This is a error message.
13:49:13,888 WARN  [com.wflybook.HomeController] (default task-1) This is a warning message.
13:49:13,888 INFO  [com.wflybook.HomeController] (default task-1) This is a information message.

The only difference is that the WildFly does not load dependencies of the application until it is called; this improves the startup time of the server.

Another point that needs some attention while performing migration is the configuration files of the application, such as:

  • hibernate.properties: This is responsible for configuring the database connection file, where the data is the URL, username, and password

  • log4j.properties: This provides the logging configuration

In WildFly, these files must be deleted and all settings that were in it should be implemented in the standalone/domain.xml file. Some unexpected actions can occur, such as logs not being generated or the database connection not being configured properly if the configuration is not set and these files are not deleted. Let's take a look at an example:

I will use an example in which these files are bundled within the application mentioned previously. Recollect that, at the time of deployment, there was a warning about the datasource. This happens because of the hibernate.properties file:

09:37:34,263 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017534: Register web context: /hs
09:37:34,338 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "hrstatus-3.2.3.war" (runtime-name : "hrstatus-3.2.3.war")
09:37:34,502 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
09:37:34,503 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
09:37:34,503 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.CR1 "WildFly" started in 12438ms - Started 689 of 746 services (90 services are lazy, passive or on-demand)
09:39:08,694 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (default task-2) IJ000612: Destroying connection that could not be successfully matched: org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@35ae5f80[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@158e651d connection handles=0 lastUse=1396442253367 trackByTx=false pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@42f03929 mcp=SemaphoreArrayListManagedConnectionPool@2938d514[pool=hrStatusDS] xaResource=LocalXAResourceImpl@37905df9[connectionListener=35ae5f80 connectionManager=70833b52 warned=false currentXid=null productName=MySQL productVersion=5.5.36-MariaDB jndiName=java:/hrStatusDS] txSync=null]

After the removal of the hibernate.properties file from the application, the previous message is no longer present in the logs:

09:37:34,263 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017534: Register web context: /hs
09:37:34,338 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "hrstatus-3.2.3.war" (runtime-name : "hrstatus-3.2.3.war")
09:37:34,502 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
09:37:34,503 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
09:37:34,503 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.CR1 "WildFly" started in 12438ms - Started 689 of 746 services (90 services are lazy, passive or on-demand)
09:39:08,694 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (default task-2) IJ000612: Destroying connection that could not be successfully matched: org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@35ae5f80[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@158e651d connection handles=0 lastUse=1396442253367 trackByTx=false pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@42f03929 mcp=SemaphoreArrayListManagedConnectionPool@2938d514[pool=hrStatusDS] xaResource=LocalXAResourceImpl@37905df9[connectionListener=35ae5f80 connectionManager=70833b52 warned=false currentXid=null productName=MySQL productVersion=5.5.36-MariaDB jndiName=java:/hrStatusDS] txSync=null]

However, we still have a problem. No application log is being generated yet. This is because there's a log4f.properties file within the application. We will remove this and see what happens. Check the logs now:

09:50:32,872 INFO  [br.com.caelum.vraptor.ioc.spring.DefaultSpringLocator] (default task-1) Using a web application context: Root WebApplicationContext: startup date [Wed Apr 02 09:50:18 BRT 2014]; root of context hierarchy
09:50:32,876 INFO  [br.com.caelum.vraptor.scan.WebAppBootstrapFactory] (default task-1) No static WebAppBootstrap found.
09:50:32,877 INFO  [br.com.caelum.vraptor.config.BasicConfiguration] (default task-1) br.com.caelum.vraptor.scanning = null
09:50:33,005 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (default task-1) Refreshing Root WebApplicationContext: startup date [Wed Apr 02 09:50:33 BRT 2014]; root of context hierarchy
...
...
09:50:34,823 INFO  [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (default task-1) 
09:50:35,450 INFO  [br.com.hrstatus.controller.LoginController] (default task-1) [ Not Logged ] URI Called: /login

As you can see now, all the logs of the application are printed as expected. The information on this topic is very brief and only provides the basics to guide the user during a migration. It does not talk objectively about everything because each application has its own peculiarities, and this information applies to virtually all migrations.