Академический Документы
Профессиональный Документы
Культура Документы
What is J2EE
J2EE is a standard based platform to develop,deploy and manage multi-tier,web enabled,server centric and component based enterprise applications. As a super set of J2SE ,J2EE adds additional specifications,libraries,documentation and tools.
2
Multi-Tier Architecture
Client Tier
Web Tier
Messaging Tier
Business Tier
Data Tier
JSP/Servlet
Data Tier
Server Centric
J2EE apps run within a J2EE application server that provides all middle-tier services Clients are thin Support for rich clients through RMI, Web services,etc -The design of such clients is beyond the scope of J2EE
5
Web enabled
Thanks to Servlet/JSP technology,J2EE applications are automatically webenabled
JBoss Organization
The professional Open Source Company Focuses on middleware software and services-JBoss Enterprise Middleware Suite(JEMS)
Software is open source and free.
Server Configurations
Fundamentally, the JBoss architecture consists of the JMX MBean server, the microkernel, and a set of pluggable component services, the MBeans. This makes it easy to assemble different configurations and gives you the flexibility to tailor them to meet your requirements You dont have to run a large, monolithic server all the time; you can remove the components you dont need
you can also integrate additional services into JBoss by writing your own MBeans. You certainly dont need to do this to be able to run standard J2EE applications.
Microkernel Layer
Based on JMX architecture Defines lifecycle configuration and management of services --Standard mechanism for assembling service components for consistent access management and integration
10
11
What is MBean
An MBean is a Java object that implements one of the standard MBean interfaces and follows the associated design patterns. The MBean for a resource exposes all necessary information and operations that a management application needs to control the resource.
12
JMX Architecture
Management Applications Distributed Services Layer Connectors and Protocol Adapters
MBean Server
Agent Layer Agent Service MBeans
JMX on Jboss AS
JTA MBean
Servlet Container MBean
JMS MBean
DB Bean
Security MBean
JNDI MBean
14
Url: http://localhost:8080/jmx-console/
15
JMX Console
16
17
Service Layer
Each service is defined as a JMX Managed Bean Services are hot Pluggable Makes it possible to tune the system for just the required service to lower the footprint Easy to define new services and package them as SARs(service archive)
Examples: Servlet/JSP container,EJB Container,transaction management,messaging,connection pooling,Security
18
Application Layer
This is where the enterprise(J2EE) applications reside This layer deals with the business logic while leaving the container services up to Jboss AS Portable-Independent of Jboss AS
19
Avoid installing java into a directory that contains spaces or other special characters (e.g C:\Program Files)
21
Configuring Java
Set JAVA_HOME to point to the directory where you installed java Add $JAVA_HOME/bin to your PATH
Test that java version prints the expected java version
22
Installing Jboss AS
Download pacakeged community distribution from: http://labs.jboss.com/jbossas/download Unpack the compressed archive
23
Directory Structure
bin: contains startup and shutdown and other system-specific scripts. The scripts which starts JBoss. client: stores configuration and JAR files which may be needed by a client which runs outside the Jboss AS container such as: Webservice client EJB Client JMX Console This is used by external applications that need to access JNDI resources To get the client classpath run: $JBOSS_HOME/bin/classpath.sh c docs: contains the XML DTDs used in JBoss for reference (these are also a useful source of documentation on JBoss configuration specifics). There are also example JCA (Java Connector Architecture) configuration files for setting up datasources for different databases (such as MySQL, Oracle, Postgres). lib: JAR files which are needed to run the JBoss microkernel. You should never add any of your own JAR files here. Applications running on Jboss do not have access to the libraries placed in this directory.
24
25
Server Configurationscontd
Within the server directory, there are three example server configurations: minimal: The minimal configuration contains the bare minimum services required to start JBoss. It starts the logging service, a JNDI server and a URL deployment scanner to find new deployments. This is what you would use if you want to use JMX/JBoss to start your own services without any other J2EE technologies. This is just the bare server. There is no web container, no EJB or JMS support. default: The default configuration consists of the standard services needed by most J2EE applications. It does not include the JAXR service, the IIOP service, or any of the clustering services. all: The all configuration starts all the available services. This includes the RMI/IIOP and clustering services, which arent loaded in the default configuration.
26
27
28
29
If you have java libraries that you need to be made available to all your applications/services, these can be placed in this directory.
Similarly, you would also use this directory for java libraries that need to be used by both your applications/services and Jboss AS services. For Example JDBC Driver that is need by JBoss AS to manage a pool of database connections as well as your code which implicitly uses it to interact with the database server.
30
32
Starting Jboss AS
Execute $JBOSS_HOME/bin/run.sh(run.bat) The script figures out JBOSS_HOME by itself To start JBOSS as a service on unix use the script jboss_init_redhat.sh To bind Jboss to a specific address execute: run.sh Djboss.bind.address=10.1.2.3 or run.sh b 10.1.2.3
34
35
36
Stopping Jboss AS
If started in foreground using the run script, simply hit CTRL+C If running in the background as an OS service stop it just like any other OS service -kill TERM <jboss-pid> -NET STOP Jboss(on Windows)
Use the shutdown script(remote shutdown): $JBOSS_HOME/bin/shutdown.sh S To shutdown a remote Jboss AS instance use: ./shutdown.sh s jnp://remoteHostOrIP:1099 S
Remote instances IP address and port are specified by its Naming Service configured in ${jboss.server.config.url}/jboss-service.xml
37
38
Running AS as a Service
On Linux, Of course you can start the Jboss in background by using & .i.e. running it as a background service On Windows, Utility called Javaservice can be used to do that.
39
The directory server configuration youre using, is effectively the server root while JBoss is running. It contains all the code and configuration information for the services provided by the particular configuration. Its where the log output goes, and its where you deploy your applications.
40
Deployment on JBoss AS
Deploy by copying components to /deploy directory Undeploy be removing the components that are not needed The main deployment process is managed by /conf/jboss-service.xml. By default this scans the deploy directory every 5000ms for added, removed or modified components.
41
JMX-Console
You can get a live view of the server by going to the JMX console application at http://localhost:8080/jmx-console It allows you to modify its configuration, start and stop components and so on. For example, find the service=JNDIView link and click on it. This particular MBean provides a service to allow you to view the structure of the JNDI namespaces within the server. Now find the operation called list. click the invoke. The operation returns a view of the current names bound into the JNDI tree, which is very useful when you start deploying your own applications and want to know why you cant resolve a particular EJB name.
43
Configuration Issues
core services specified in the conf/jboss-service.xml.This is the bootstarp descriptor that defines core services that are fixed for the lifetime of the server. Several MBeans are being configured like logging, security, JNDI Naming and View, Thread Pool etc. Comment the JNDIView Service in jboss-service.xml & Restart the Appln server. <! <mbean code="org.jboss.naming.JNDIView" name="jboss:service=JNDIView" xmbean-dd="resource:xmdesc/JNDIView-xmbean.xml"> </mbean> --> Now if you see in JMX console you will not be able to find JNDIView service 44 being deployed.
45
46
Tomcats server.xml
Tomcats own configuration file: jboss-web.deployer/server.xml Configures -Connectors(HTTP,HTTPS,AJP) -Security realms(Inherits from Jboss) -logging (Tomcat Service) -Valves(Request/Response interceptor) -Virtual Hosts(Name Based)
Tomcats web.xml
Default web descriptor for all web apps jboss-web.deployer/conf/web.xml Configures -common filters -servlets for handling static content,JSP,CGI Scripts -Default session timeout -MIME type mappings -Welcome File List:index.html,index.jsp -Error documents
48
Session Configuration
Configure <session-config> <session-timeout>30</session-timeout> </session-config> The value (in minutes) indicated how long the servlet container will maintain an idle session(in memory or in disk) before timimg out Value<=0 indicates that session never expires-unless destroyed explicitly through users logout Significant impact on server memory usage and end users dissatisfaction with time outs.
49
Error Documents
Configured through <error-page> Defines mapping between an <error-code> or <exception-type> and a <location> of the error document to be served on those errors
50
<! ELEMENT error-page ((error-code | exception-type) , location)> <error-page> <error-code>404</error-code> <location>/FileNotFoundError.jsp</location> </error-page>
Note that <location> is relative to the root of the application and it must start with a /
51
<! ELEMENT error-page ((error-code | exception-type) , location)> <error-page> <error-code>404</error-code> <location>/FileNotFoundError.jsp</location> </error-page>
Note that <location> is relative to the root of the application and it must start with a /
52
JNDI on JBoss
Configured in Jboss_Home\server\default\conf\ jboss-service.xml
<mbean code="org.jboss.naming.NamingService
name="jboss:service=Naming"
xmbean-dd="resource:xmdesc/NamingService-xmbean.xml"> <attribute name="CallByValue">false</attribute> <!-- The listening port for the bootstrap JNP service. Set this to -1 to run the NamingService without the JNP invoker listening port. --> <attribute name="Port">1099</attribute>
<!-- The bootstrap JNP server bind address. This also sets the default
RMI service bind address. Empty == all addresses--> <attribute name="BindAddress">${jboss.bind.address}</attribute> <!-- The port of the RMI naming service, 0 == anonymous --> <attribute name="RmiPort">1098</attribute> <!-- The RMI service bind address. Empty == all addresses --> <attribute name="RmiBindAddress">${jboss.bind.address}</attribute> <!-- The thread pool service used to control the bootstrap lookups --> <depends optional-attribute-name="LookupPool" proxy-type="attribute">jboss.system:service=ThreadPool</depends> <!-- An example of using the unifed invoker as the transport. <depends optional-attribute-name="InvokerProxyFactory" proxy-type="attribute">jboss:service=proxyFactory,type=unified,target=Naming</depends> --> <depends optional-attribute-name="Naming" proxy-type="attribute">jboss:service=NamingBeanImpl</depends> </mbean>
56
57
<?xml version="1.0" encoding="UTF-8"?> <!-- $Id: mail-service.xml 62349 2007-04-15 16:48:15Z dimitris@jboss.org $ --> <server> <!-- ==================================================================== --> <!-- Mail Connection Factory --> <!-- ==================================================================== --> <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail"> <attribute name="JNDIName">java:/Mail</attribute> <attribute name="User">nobody</attribute> <attribute name="Password">password</attribute> <attribute name="Configuration"> <!-- A test configuration --> <configuration> <!-- Change to your mail server prototocol --> <property name="mail.store.protocol" value="pop3"/> <property name="mail.transport.protocol" value="smtp"/> <!-- Change to the user who will receive mail --> <property name="mail.user" value="nobody"/> <!-- Change to the mail server --> <property name="mail.pop3.host" value="pop3.nosuchhost.nosuchdomain.com"/> <!-- Change to the SMTP gateway server --> <property name="mail.smtp.host" value="smtp.nosuchhost.nosuchdomain.com"/> <!-- The mail server port --> <property name="mail.smtp.port" value="25"/> <!-- Change to the address mail will be from --> <property name="mail.from" value="nobody@nosuchhost.nosuchdomain.com"/>
<!-- Enable debugging output from the javamail classes --> <property name="mail.debug" value="false"/> </configuration> </attribute> <depends>jboss:service=Naming</depends> </mbean>
58
In the applications WEB-INF/web.xml <resource-ref> <description>Default Mail Session</description> <res-ref-name>mail/Session</res-ref-name> <res-type>javax.mail.Session</res-type> <res-auth>Container</res-auth> </resource-ref> In the applications WEB_INF/jboss-web.xml <jboss-web> <resource-ref> <res-ref-name>mail/Session</res-ref-name> <res-type>javax.mail.Session</res-type> <jndi-name>java:/Mail</jndi-name> </resource-ref>
59
In J2EE,JMS
Allows loosely coupled,reliable,asynchronous interactions among J2EE components and legacy systems capable of messaging Application clients, EJBs, and web components can send and receive JMS messages
Message driven beans enable the async consumption of messages, making it easy to plug in new business event handlers into an existing deployment
Message send and receive operation can participate in distributed transactions, which allow JMS operations and database accesses to take place within a single transaction.
Inventory
Factory
Parts
Accounting
Inventory
JMS Architecture
JMS Clients are the programs or components wrtitten in java programming language that produce and comnsume messages.
A JMS provider is the messaging system that implements the JMS interfaces and provides administrative an control features. Messages are the objects that communicate information between JMS clients.
Administrative Tool
lookup
JNDI
bind
JMS Client
Logical connection
JMS Provider
Point To Point
A sender sends message addressed to a specific queue. A receiver consumes the message from the queue established to hold its messages Queues retain all messages sent to them until the messages are consumed or the messages expire Each message has only one consumer
A sender and receiver of a message has no time dependency.A receiver can fetch the message whether or n it was running when the client sent the message. The receiver acknowledges the successful processing of a message
Send message
JMS Queue
acknowledges
Subscriber clients subscribe to one or more message message topics and receive messages when they are sent to them. The topics hold the messages as long as it takes to deliver them to all currently subscribed clients Each message can have multiple consumers
Publisher and subscribers have a timing dependency. A client that subscribes to a topic can consume only messages published after the client has created a subscription and the subscriber must continue to be activ order for it to consume messages
publish message
JMS Topic
Subscribe
Asynchornous: A client can register a message listener with a consumer. Whenever a message arrives at the destination, the JMS provider delivers the message by calling the listener's on Message method, which acts on the contents of the message.
JMS on Jboss
JMS Services Invocation Layer-Bidirectional communication
Logging Service
Logging is controlled from a central conf/log4j.xmlfile. This file defines a set of appenders, specifying the log files, what categories of messages should go there, the message format and the level of filtering. By default, JBoss produces output to both the console and a log file (server.log in the log directory) There are 4 basic log levels used: DEBUG, INFO, WARN and ERROR.
The logging threshold on the console is INFO, which means that you will see informational messages, warning messages and error messages on the console but not general debug messages.
67
Logging Service
In contrast, there is no threshold set for the server.log file, so all generated logging messages will be logged there. Also that just because the logging threshold allows debug messages to be displayed, that doesn't mean that all of JBoss will produce detailed debug information for the log file. You will also have to boost the logging limits set for individual categories.
Eg:
<!-- Limit JBoss categories to INFO --> <category name="org.jboss"> <priority value="INFO"/> </category> This limits the level of logging to INFO for all JBoss classes, apart from those which have more specific overrides provided. If you were to change this to DEBUG, it would produce much more detailed logging output.
68
Logging Example
Another example if you want to set output from some component redirected to a particular file. <appender name="CMP" class="org.jboss.logging.appender.RollingFileAppender"> <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/> <param name="File" value="${jboss.server.home.dir}/log/cmp.log"/> <param name="Append" value="false"/> <param name="MaxFileSize" value="500KB"/> <param name="MaxBackupIndex" value="1"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/> </layout> </appender> <category name="org.jboss.ejb.plugins.cmp"> <priority value="DEBUG" /> <appender-ref ref="CMP"/> </category>
You will notice that the log directory also contains HTTP request logs which are produced by the web container.
69
Database Connectivity
(Connecting Jboss AS with RDBMS with connection pooling)
Steps Involved
Resource references in web appsrequiring connectivity to RDBMS Providing RDBMS resources(connection pools) in the server Installing JDC Driver Defining RDBMS Resources
Web Applications that need services of a relational database, can connect to it : By managing their own connections By having the server managed a shared database connection pool. Management of database connections in web applications: -Bloats the code -require more testing -require seperate configuration for each web app -is slow if connections are not pooled. -is inefficient and limiting if the connections are pooled because there would be a separate pool for each web app with potentially many idle connections.
Resource Requirement
In a web app's WEB-INF/web.xml file
<web-app ..>
<resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/NorthwindDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth> </resource-ref> </web-app>
<local-tx-datasource>
<jndi-name>NorthwindDS</jndi-name> <connectionurl>jdbc:mysql://localhost:3306/Northwind?autoReconnect=true </connectionurl>\ <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>northwind</user-name> <password>secret</password> </local-tx-datasource> </datasources>
idle-timeout-minutes: the maximum time(in minutes) before idle connections are closed.
Resource Mapping
In the WEB_INF/jboss-web.xml file
<jboss-web>
<resource-ref> <description>JDBC Connection</description> <res-ref-name>jdbc/NorthwindDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <jndi-name>java:/NorthwindDS</jndi-name> </resource-ref>
</jboss-web>
Maps the application's resources to real resource provided by Jboss AS
Security
Securing Applications
Filtering clients by source IP address Requiring authentication and authorization Data transport integrity and confidentiality(SSL)
-Different levels: <Engine> (global), <Host> (per virtual host) , <Context> (per web application)
To limit access as a desired <Valve> in <Engine> or <Host> within \default\deploy\jboss-web.deployer\server.xml file-
</Context>
Requiring A&A
Adding security-costraint in web.xml
<security-constraint> <web-resource-collection> <web-resource-name>Tell Fortune Servlet</web-resource-name>
<url-pattern>/tellFortune</url-pattern>
</web-resource-collection> <auth-constraint> <role-name>customer</role-name> </auth-constraint> </security-constraint>
.....
<security-constraint> .... </security-constraint>
<login-config>
<auth-method>BASIC</auth-method> <realm-name>Customers Only</realm-name> </login-config> ... </web-app> In this case we used HTTP BASIC authentication. But other options are:DIGEST,FORM etc.
.....
<security-constraint> .... <auth-constraint>
<role-name>customer</role-name>
</auth-constraint> </security-constraint> <login-config>...</login-config> <security-role> <role-name>customer</role-name> </security-role> </web-app>
WEB-INF/classes/roles.properties
mike=customer
john=manager The properties files are loaded during initialization of the context class loader. Placing these files in the deploy/<app>/WEBINF/classes directory makes them unique to that specific web application.
Security Service
The security domain information is stored in the file \server\default\conf\loginconfig.xml as a list of named security domains, each of which specifies a number of JAAS3 login modules which are used for authentication purposes in that domain. Eg: jmx-console (Since everything is being controlled by this, you may need to secure this). To protect this application we will be add a security domain cover to it. <application-policy name = "jmx-console"> <authentication> <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag = "required"> <module-option name="usersProperties">props/jmx-console-users.properties</ module-option> <module-option name="rolesProperties">props/jmx-console-roles.properties</ module-option> </login-module> </authentication> </application-policy>
87
3. To configure this, go to the web.xml file in the same directory and uncomment the security-constraint that is already there.
88
Adding Security
<!-A security constraint that restricts access to the HTML JMX console to users with the role JBossAdmin. Edit the roles to what you want and uncomment the WEB-INF/jboss-web.xml/security-domain element to enable secured access to the HTML JMX console. --> <security-constraint> <web-resource-collection> <web-resource-name>HtmlAdaptor</web-resource-name> <description> An example security config that only allows users with the role JBossAdmin to access the HTML JMX console web application </description> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>JBossAdmin</role-name> </auth-constraint> </security-constraint> 89
Adding Security
Where are the username, passwords & roles stored. The configuration is stored in conf/login-config.xml.
<application-policy name="jmx-console"> <authentication> <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"flag="required"> <module-option name="usersProperties"> props/jmx-console-users.properties </module-option> <module-option name="rolesProperties"> props/jmx-console-roles.properties </module-option> </login-module> </authentication> </application-policy>
90
Adding Security
The location of these files is in the conf directory. i.e. <jboss-home>/server/default/conf/props/<filename> The usernames and passwords are stored in jmx-consoleusers.properties in the directory and take the form username=password". To assign a user to the JBossAdmin group add "username=JBossAdmin" to the jmx-console-roles.properties file.
91
Securing Passwords
Configure Hashed passwords in conf/login-config.xml
<login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule"flag = "required"> ..... <module-option name = "hashAlgorithm">MD5</module-option> <module-option name = "hashEncoding">hex</module-option> </login-module>
Enabling SSL
Use KeyTool Utility with JDK to generate keystore file keytool -genkey -alias tomcat -keyalg RSA Copy the .keystore file to <Jboss-Home>/derver/default/conf. Rename it to ssl.keystore Uncomment the following from \server\default\deploy\jboss-web.deployer\server.xml
<!-- SSL/TLS Connector configuration using the admin devl guide keystore <Connector port="8443" address="${jboss.bind.address}" maxThreads="100" strategy="ms" maxHttpHeaderSize="8192" emptySessionPath="true" scheme="https" secure="true" clientAuth="false" keystoreFile="${jboss.server.home.dir}/conf/ssl.keystore" keystorePass="rmi+ssl" sslProtocol = "TLS" /> -->
93
<user-data-constraint>
<desription>Require SSL</desription> <transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
The element <transport-guarantee> can be NONE,INTEGRAL,CONFIDENTIAL. The INTEGRAL,CONFIDENTIAL flag indicates that the use of SSL is required.
Securing Jboss AS
Running Jboss AS with low previleges File system security Securing console application-like JMX Securing other Jboss AS services Running with JAVA security Manager Running behind a firewall
starting
--Running without root privileges forces you to use ports >=1024 on a UNIX/LINUX system
--Front Jboss AS with a web server (Like Apache HTTPD) or setup firewall-based port forwarding for access over default HTTP(S) port:80,443.
Performance Tuning
Tomcat jbossweb-tomcat5.sar/server.xml <Connector port="8080" address="${jboss.bind.address}" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true"/>
You should have enough threads (maxThreads) to handle (rule of thumb) 25% more than your maximum expected load (concurrent hits coming in at once) You should have minSpareThreads equal just a little more than your normal load You should have maxSpareThreads equal just a little more than your peak load minSpareThreads means "on start up, always keep at least this many threads waiting idle" maxSpareThreads means "if we ever go above minSpareThreads then always keep maxSpareThreads waiting idle"
97
Performance-Log4J
Logging has a profound effect on performance. Changing the logging level to TRACE can bring the JBossAS to a crawl. Changing it to ERROR (or WARN) can speed things up dramatically. By default, JBoss logs both to the console and server.log and by default it uses level "INFO". To turn off console logging:
<appender-ref ref=CONSOLE"/>
<appender-ref ref="FILE"/>
</root> <root> <appender-ref ref="FILE"/> </root>
make it read
98
Finally the most important thing in log4j, make sure you limit the logging level on your own class hierarchy. <!-- Limit my.package category to INFO --> <category name="my.package"> <priority value="INFO"/> </category>
99
Slimming
JavaMail Remove the services which are not being used. When not using the mail-service (J2EE standard JavaMail client) remove server/deploy/mail-service.xml remove server/lib/mail* (mail-plugin.jar, mail.jar - JavaMail stuff) remove server/lib/activation.jar (Java Activation Framework is used by JavaMail)
J2EE Client deployer service When not using the J2EE client deployer service remove server/deploy/client-deployer-service.xml
100
Slimming
HAR Deployer When not using the integrated HAR deployer and Hibernate session management services remove server/deploy/hibernate-deployer-service.xml (HAR support) remove server/lib/jboss-hibernate.jar (HAR support) remove server/lib/hibernate2.jar (Hibernate itself) remove server/lib/cglib-full-2.0.1.jar (used by Hibernate to create proxies of POJOs) remove server/lib/odmg-3.0.jar HSQL When not using Hypersonic (which you should not in production) remove server/deploy/hsqldb-ds.xml remove server/lib/hsqldb-plugin.jar remove server/lib/hsqldb.jar Remember Jboss MQ by default uses HSQL. So sometimes you may need to configure it with some other database.
101
Slimming
JBossMQ remove the entire server/deploy/jms directory remove server/lib/jbossmq.jar
HTTPInvoker (which lets you tunnel RMI over HTTP) remove the entire server/deploy/http-invoker.sar directory
102
If you do not need to make JMX calls over RMI (warning the shutdown.sh DOES do this) remove server/deploy/jmx-invoker-adaptor-server.sar remove server/deploy/jmx-adaptor-plugin.jar or you may want to just secure the JMX invoker-adaptor instead
EAR Deployer If you do not need to be able to deploy EAR files open server/conf/jboss-service.xml in the vi editor remove/comment the following XML fragments from the from under the <mbean code="org.jboss.management.j2ee.LocalJBossServerDomain" MBean <attribute name="EARDeployer">jboss.j2ee:service=EARDeployer</attribute> and <!-- EAR deployer, remove if you are not using Web layers --> <mbean code="org.jboss.deployment.EARDeployer" name="jboss.j2ee:service=EARDeployer"> </mbean>
103
Requirements
Fault Tolerance --Reliability
--Uptime Guarantee
Stable Throughput Scalability --Provide consistent response times in light of increased system load Manageability of Servers -- Server upgrade with no service interruptions
Jboss AS
Data Base
Client
This architecture is not scalable.Additional users can only be handled by improving the performance of the server(e.g. Additional CPUs, more memory) No fault tolerance. If the JBoss AS goes down , the entire service becomes unavailable.
Jboss AS
Data Base
Jboss AS Jboss AS
Data Base
Client
Add one or many web servers to balance the load to multiple Jboss AS nodes typically running on seperate physical servers. Additional user load can be handled by adding another Jboss AS If anyone of the Jboss AS nodes fail, the service is still available through other Jboss AS.
Client
HTTP/S 80/443
AJP1.3 8009
Jboss AS
Legacy System
Install and setup Apache HTTPD Install and configure mod_jk on apache AJP connector on Jboss AS already enabled in jboss.web.deployer/server.xml
Installing mod_jk
Download latest mod_jk(binary or source) from: http://tomcat.apache.org/connectors-doc/ Save it as <apache-dir>/modules/mod_jk.so Include its configuration file in <apache-dir>/conf/httpd.conf: Include conf/jk.conf
configuring mod_jk
Define a Jboss AS instance in: <apache-dir>/conf/workers.properties: worker.jboss1.type=ajp13 worker.jboss1.host=127.0.0.1 worker.jboss1.port=8009 worker.list=jboss1 Special directive worker.list exports all declared workers for use in the Apache HTTPD
Include conf/jk.conf
Workers jboss1 come from workers.properties file because they were exported by worker.list directive
Define it in workers.properties:
worker.jboss2.type=ajp13 worker.jboss2.host=192.168.1.149 worker.jboss2.port=8009
worker.jboss.balance_workers=jboss1,jboss2
Export the load balancing worker: worker.list=jboss
<apache-dir>/conf/workers.properties file
worker.jboss1.type=ajp13 worker.jboss1.host=127.0.0.1 worker.jboss1.port=8009 worker.list=jboss1 worker.jboss2.type=ajp13 worker.jboss2.host=192.168.1.149 worker.jboss2.port=8009 worker.jboss.type=lb worker.jboss.balance_workers=jboss1,jboss2
worker.list=jboss
Change conf/jk.conf
jkMount /jmx-console/* jboss jkMount /fortune/* The update jk.conf looks like:
LoadModule jkWorkersFile jk_logLevel jkMount jk_module INFO jboss modules/mod_jk.so Conf/workers.properties
jboss
/jmx-console/*
jkMount
/fortune/*
jboss
Note that we are no longer jkMount- ing jboss1 ( or jboss2). We can only use the new load balancer worker called jboss because that is the one exported by worker.list in conf/workers.properties file.