JBoss AS Upgrade


Published on

Upgrading to JBoss AS7? Read this first.

Published in: Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

JBoss AS Upgrade

  1. 1. Upgrading to JBoss AS7 Amit Sharma AXS USA LLC amit@axsusa.com 9th Jan 2013
  2. 2. IndexO Cover Jboss AS7 O Jboss AS 6.x/5.x comparisonO FeaturesO The ArchitectureO New ComponentsO Lessons learnedO References
  3. 3. JBoss AS7O 7.0.0.Final – First stable release 12th July 2011O 7.1.1.Final – released 9th March 2012O First major shift – common codebaseO Major re-write of the underlying architectureO Extensible framework – Immutant (clojure), torquebox (Jruby)
  4. 4. Client HistoryO A complete JBoss Shop O JBoss EAP 6.x O Hibernate 3.3 O Seam 2.x O JBoss Messaging O JMX Console O RestEasy O Jdk 1.6.0_31
  5. 5. FeaturesJBoss AS7 Website:O Blazingly fast (<3s startup)O LightweightO Modular coreO Elegant administrationO Domain managementO First class components
  6. 6. AS7 ArchitectureO Core: O Jboss Modules (class loading of resources) O Module Service Container (install/uninstall or manage services)O Standalone.xml at the heart of Jboss O Snapshot folder strategyO JSR-299 compliant server (Java EE6) O CDI / Weld supported fully.O Modules are open source projects
  7. 7. AS7 Architecture (standard) O Hibernate Core (4.0.1.Final) – Default JPA Provider. O RestEasy (2.3.1.GA) O Apache CXF (4.0.1.GA) O Mojarra (JSF 2.0) O JBoss Logging (Java Util Logging) * Jboss/docs/licenses/licenses.xml
  8. 8. Folder Structure
  9. 9. ModulesAS Bootstrap libs Server libs4.x JBOSS_HOME/server JBOSS_HOME/server/<server>/lib5.x – JBOSS_HOME/server JBOSS_HOME/common/lib and6.x JBOSS_HOME/server/<server>/lib7.x JBOSS_HOME/jboss- JBOSS_HOME/modules subfolders. modules.jar
  10. 10. Standalone.xmlO Variants of standalone.xml pre-exist.O <extensions> - shared by all applications O These are stored in ‘modules’O <profile> - collection of subsystems. O One for standalone, multiple for domain.O <interfaces> - bind addresses.O <socket-binding-group> - define ports.O <system-properties> O Define in xml O standalone.bat -P=mypropertiesfile.properties
  11. 11. Standalone.xml (contd.)O Adding SMTP support O Bring the subsystem <subsystem xmlns="urn:jboss:domain:mail:1.0"> <mail-session jndi-name="java:/Mail" debug="true"> <smtp-server outbound-socket-binding-ref="mail-smtp"/> </mail-session> </subsystem> O Add the socket bindings <outbound-socket-binding name="mail-smtp"> <remote-destination host=“mail.google.com" port="25"/> </outbound-socket-binding>
  12. 12. Standalone.xml (contd.)O Overiding default scanner path<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1"> <deployment-scanner path="C:/myapp/deployments"scan-interval="5000" auto-deploy-zipped="true" auto-deploy-exploded="true" deployment-timeout="180"/> </subsystem>O Port Offsetstandalone.bat -Djboss.socket.binding.port-offset=10 [All ports are offset by 10]http://localhost:8090
  13. 13. Standalone.xml (contd.)O Registering a database driver (another subsystem) O No common/lib or *ds.xml files<datasources> <datasource jndi-name="java:jboss/datasources/testDS" pool-name="testDS" use-java-context="false"> <connection-url>jdbc:oracle:thin:@myserverip/myschema</connection-url> <driver>oracle</driver> <security> <user-name>amit</user-name> <password>sharma</password> </security> </datasource> <drivers> <driver name="oracle" module="com.oracle.ojdbc6"> <xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class> </driver> </drivers> </datasources>JBOSS_HOMEmodulescomoracleojdbc6mainmodule.xml and jar
  14. 14. JBoss CLIO Example:<system-properties><property name="hibernate.default_schema“ value="AMIT"/></system-properties>O Read System properties[standalone@localhost:9999 /] /system-property=hibernate.default_schema:read-resource{ "outcome" => "success", "result" => {"value" => "AMIT"}}
  15. 15. JBoss CLI (contd.)O Command Line Interface. GUI available as well. O /subsystem=datasources/data-source=ExampleDS/ c:jboss-as-7.1.1.Finalbin>jboss-cli.bat –guiO Command line[standalone@localhost:9999 /]/subsystem=datasources/data-source=ExampleDS:read-attribute(name=connection-url){ "outcome" => "success", "result" => "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"}
  16. 16. DeploymentO Mechanisms: O Deployments Directory (/standalone/deployments) O CLI (undeploy and then .dodeploy) O Marker files O .deployed or .undeployed markers O .failed O .isdeploying O .isundeploying O Management Console O Eclipse Plugin
  17. 17. What’s newO HornetQ – default JMS Provider (2.2.11)O Jgroups API Implementation for communication between nodes - UDP and multicast. (3.1.0.GA)O IronJacamar - Java Connector Architecture 1.6 Implementation. (1.0.7.Final)O Infinispan – JSR-107 compatible cache O Handles cluster consistencyO Jolokia - JMX-HTTP bridge (JMX with JSON over http)O Arquillian support.O Mod_cluster support. (mod_jk and mod_proxy still works)
  18. 18. HornetQO HornetQ is an open source project to build a multi-protocol, embeddable, very high performance, clustered, asynchronous messaging system.O High performance journal mechanism for message persistence (No database persistence)O Provides fully functional JMS capabilities. O Supports JMS 1.1 API. (No code changes) O Provides its own Messaging API. O STOMP and REST support
  19. 19. HornetQ (contd.)O MDB example O No Java Impact to MDBs @MessageDriven(name = "MDBExample", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue") }) public class MDBExample implements MessageListener { public void onMessage(Message message)... }
  20. 20. HornetQ (contd.)O Wildcards on Addresses rather than specific queue. O filter for the destination - jms.queue.#O Standalone-full-ha.xml <jms-destinations> <jms-queue name="testQueue"> <entry name="queue/test"/> <entry name="java:jboss/exported/jms/queue/test"/> </jms-queue> <jms-topic name="testTopic"> <entry name="topic/test"/> <entry name="java:jboss/exported/jms/topic/test"/> </jms-topic> </jms-destinations>
  21. 21. HornetQ (contd.)O Integration with any JEE App Server must happen via JCA (Java Connector Architecture) Adaptor O A JCA Adapter basically controls the inflow of messages to Message-Driven Beans (MDBs) and the outflow of messages sent from other JEE components, e.g. EJBs and Servlets. O Anti-pattern defined. (See Image)
  22. 22. HornetQ (contd.)O Anti-Pattern
  23. 23. JBoss CLI - HornetQO See a Queue O /subsystem=messaging/hornetq- server=default/:read-children- resources(child-type=jms-queue)O Read a broadcast-group O /subsystem=messaging/hornetq- server=default/:read-children-names(child- type=broadcast-group)O Test a connectiondata-source test-connection-in-pool --name=testDS
  24. 24. JolokiaO WAR-Agent (access to your JMX beans)O Query:http://localhost:8080/jolokia-war-1.0.6/read/jboss.as:subsystem=datasources,data-source=ExampleDS/connectionUrl?ignoreErrors=trueO Result:{"timestamp":1357502024,"status":200,"request":{"mbean":"jboss.as:data-source=ExampleDS,subsystem=datasources","attribute":"connectionUrl","type":"read"},"value":"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"}
  25. 25. ArquillianO No more mocks and No more container lifecycle and deployment@RunWith(Arquillian.class)public class GreeterTest { @Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClass(Greeter.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); }@InjectGreeter greeter;@Testpublic void should_create_greeting() { assertEquals("Hello, Earthling!", greeter.greet("Earthling")); }}
  26. 26. Arquillian (contd.)O src/test/resources/arquillian.xml<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> <container qualifier="jbossas-managed" default="true"> <configuration> <property name="jbossHome">target/jboss-as-7.1.1.Final</property> </configuration> </container></arquillian>
  27. 27. What’s missing?O JMX ConsoleO JBoss Messaging 1.0O JBoss Logging (old implementation)O VFS – Virtual File SystemO Farm deployment (vs Domain settings)O Same folder structureO Extensive configuration O Clear Documentation 
  28. 28. Lessons LearnedO Seam 2.x (hibernate dependency)O Hibernate Validators (JPA-2 compliance)O Apache CXF collisionO Seam Tests failure (Arquillian upgrade)O JMX console obsolete (jolokia war)O JSF 1.2 supportO HornetQ learning curve and dns issues.O MDB and Seam race condition issues. [@DependsOn does not work]O Jboss Logging
  29. 29. Lessons Learned (contd.)O Hibernate 3.x (JPA 2) support O META-INF/persistence.xml <property name="jboss.as.jpa.providerModule"value="hibernate3-bundled" />O Enable AJP Connector binding O <connector name="AJP" protocol="AJP/1.3" socket-binding="ajp" /> O <socket-binding name="ajp" port="8009"/>O HornetQ clustering (disabled by default) O <clustered>true</clustered>
  30. 30. Lessons Learned (contd.)O Declare dependenciesMETA-INF/MANIFEST.MF Dependencies: org.apache.log4jORWEB-INF/jboss-deployment-structure.xml<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <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" export="true"/> <module name="com.sun.jsf-impl" slot="1.2" export="true"/> </dependencies> </deployment></jboss-deployment-structure>
  31. 31. Lessons Learned (contd.)O Jboss-web.xml (still defines the context) <jboss-web> <context-root>myapp</context-root> </jboss-web>O HornetQ - DNS entries must exist for IP addresses defined for messaging (multicast or otherwise)O HornetQ – multicast configuration is enabled by default.O HornetQ - Round Robin Load Balancing configuration.<connection-load-balancing-policy-class-name>org.hornetq.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy</connection-load-balancing-policy-class-name>
  32. 32. Lessons Learned (contd.)O JBoss - You can load your own xml by : standalone.bat --server-config standalone- full-ha.xmlO JBOSS_HOME/docs/schema has dtds/xsds defined for validationsO Arquillian – TestSuite still in works.
  33. 33. ReferencesO JBoss AS 7 Configuration, Deployment and Administration. Marchioni, FrancescoO Credits: Isaac Christoffersen (Vizuri), Aslak Knutsen (Red Hat) and Catherine Robson (Red Hat)O Links: http://www.jboss.org/as7 https://docs.jboss.org/author/display/AS71/Documentation http://Jolokia.org http://www.jboss.org/ironjacamar http://java.net/projects/mojarra/ http://jboss.org/hornetq http://www.jgroups.org/ http://arqullian.org http://www.jboss.org/resteasy http://www.jboss.org/infinispan