|
Size: 17210
Comment:
|
Size: 17246
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 244: | Line 244: |
| http://docs.jboss.org/jbossclustering/cluster_guide/5.1/html/clustering-intro.chapt.html | * [[ http://docs.jboss.org/jbossclustering/cluster_guide/5.1/html/clustering-intro.chapt.html | clustering intro chapter ]] |
Contents
-
JBoss
- JBoss AS7
- Message driven bean (JBoss)
- Timers annotations
- JAAS security JBoss AS7
- Forms login
- JDBC authentication
- Compression JBossAS7
- Clear transactions
- Replace default page in JBossAS7
- System properties in JBossAS7
- System properties in JBoss5
- Show web services in JBoss5
- JBoss5 clustering
- JBoss5 run profile ALL and listen on 0.0.0.0
- JBoss5 EJB client required libs
- List deployed web services on JBoss5
- List packages per JAR file
- JBoss5 JAX-WS support
- Enable debugging
- JBoss EAP 6.4
JBoss
Application server that implements the Java Platform, Enterprise Edition (Java EE) http://en.wikipedia.org/wiki/Jboss.
Old versions: https://jbossas.jboss.org/downloads
JBoss AS7
Is a Java application server Java EE 6 Full Profile http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip
Message driven bean (JBoss)
A message-driven bean is an enterprise bean that allows J2EE applications to process messages asynchronously.
Annotations, MDB Properties Provided by the JCA Specification
Name |
Type |
Default value |
Remarks |
destination |
String |
none |
This property is Mandatory The JNDI name of the Queue or Topic. |
destination Type |
String |
none |
The type of destination valid values are javax.jms.Queue or javax.jms.Topic |
message Selector |
String |
none |
The message selector of the subscription |
acknowledge Mode |
int |
AUTO_ |
The type of acknowledgement when not using transacted jms - valid values AUTO_ ACKNOWLEDGE or DUPS_OK_ ACKNOWLEDGE |
clientID |
String |
|
The client id of the connection |
subscription Durability |
String |
Whether topic subscriptions are durable. Valid values are Durable orNonDurable |
|
subscription Name |
String |
none |
The subscription name of the topic subscription |
MDB Properties Provided as JBoss Extensions
Name |
Type |
Default value |
Remarks |
is Topic |
boolean |
false |
Sets the destinationType |
provider Adapter JNDI |
String |
Default JMS Provider |
The JNDI name of the JMS provider. |
user |
String |
none |
The user ID used to connect to the JMS server |
pass |
String |
none |
The password of the user |
max Messages |
int |
1 |
Read this number of messages before delivering messages to the MDB. Each message is delivered individually on the same thread in an attempt to avoid context excessive context switching |
min Session |
int |
1 |
The minimum number of JMS sessions that are available to concurrently deliver messages to this mdb |
max Session |
int |
15 |
The maximum number of JMS sessions that are available to concurrently deliver messages to this mdb |
reconnect Interval |
long |
10 seconds |
The length of time in seconds between attempts to (re-)connect to the JMS provider |
keep Alive |
long |
60 seconds |
The length of time in milliseconds that sessions over the minimum are kept alive |
session Transacted |
boolean |
true |
Whether the sessions are transacted |
use DLQ |
boolean |
true |
Whether to use a Dead Letter Queue (DLQ) handler. |
dLQ JNDIName |
String |
queue/DLQ |
The JNDI name of the DLQ |
dLQ Handler |
String |
org. jboss. resource. adapter. jms. inflow. dlq. Generic DLQ Handler |
The org.jboss. resource. adapter.jms.inflow. DLQHandler implementation class name. |
dLQ User |
String |
none |
The user id used to make the dlq connection to the JMS server |
dLQ Password |
String |
none |
The password of the dLQUser |
dLQ ClientID |
String |
none |
The client id of the DLQ connection |
dLQ MaxResent |
int |
5 |
The maximum number of times a message is redelivered before it is sent to the DLQ. |
redeliver Unspecified |
boolean |
true |
Whether to attempt to redeliver a message in an unspecified transaction context |
transaction Timeout |
int |
Default is the timeout set for the resource manager |
Time in seconds for the transaction timeout |
Delivery Active |
boolean |
true |
Whether the MDB should make the subscription at initial deployment or wait for start() or stopDelivery() on the corresponding MBean. You can set this to false if you want to prevent messages from being delivered to the MDB (which is still starting) during server start up. |
Timers annotations
Creating Calendar-Based Timer Expressions http://docs.oracle.com/cd/E19226-01/820-7627/giqlk/index.html
Examples:
Every five minutes, @Schedule(minute = "*/5" , hour="*")
Every twenty minutes from 5 to 21, @Schedule(minute="*/20" , hour = "5-21")
At one AM, @Schedule(hour = "1")
At two AM and five PM, @Schedule(hour = "2,17")
JAAS security JBoss AS7
JAAS (Java Authentication and Authorization Service).
Read http://amatya.net/blog/implementing-security-with-jaas-in-jboss-as-7/
Basic authentication Web application
Add user and roles:
- /opt/jboss-as-7.1.1.Final/bin/add-user.sh -a userx passx # add user userx
- Files /opt/jboss-as-7.1.1.Final/standalone/application-users.properties and /opt/jboss-as-7.1.1.Final/domain/application-users.properties changed
- vi /opt/jboss-as-7.1.1.Final/standalone/application-roles.properties # add primary role
- userx=AppXYZUser # in application-roles.properties
Edit web.xml file for the web application:
1 <web-app>
2 <!-- other stuff .....-->
3 <!-- security application realm -->
4 <security-constraint>
5 <web-resource-collection>
6 <web-resource-name>HtmlAuth</web-resource-name>
7 <description>application security constraints</description>
8 <url-pattern>/*</url-pattern>
9 <http-method>GET</http-method>
10 <http-method>POST</http-method>
11 </web-resource-collection>
12 <auth-constraint>
13 <role-name>AppXYZUser</role-name>
14 </auth-constraint>
15 </security-constraint>
16 <login-config>
17 <auth-method>BASIC</auth-method>
18 <realm-name>ApplicationRealm</realm-name>
19 </login-config>
20 <security-role>
21 <role-name>AppXYZUser</role-name>
22 </security-role>
23 <!-- security application realm -->
24 </web-app>
Edit jboss-web.xml
Forms login
The following input fields are posted when a login is attempted:
- j_security_check
- j_username
- j_password
In web.xml:
JDBC authentication
For this setup the password is in plain text ! It must be improved in order to use hash like MD5 or SHA1.
Create tables on a PostgreSQL server:
- psql -U userx -W -d databasex -h 192.168.1.1
- \c databasex
- create table users (username varchar(128) NOT NULL,password varchar(128) NOT NULL );
- create table roles (username varchar(128) NOT NULL,role varchar(128) NOT NULL );
- insert into users (username,password) values('userx1','12345678');
- insert into roles (username,role) values('userx1','User');
insert into roles (username,role) values('userx1','UserManager');
- grant all privileges on database dldserver to dldserver;
- alter table users owner to userx;
- alter table roles owner to userx;
Add security domain to standalone-full.xml:
1 <security-domain name="jdbcRealm" cache-type="default">
2 <authentication>
3 <login-module code="Database" flag="required">
4 <module-option name="dsJndiName" value="java:jboss/datasources/ServerDS"/>
5 <module-option name="principalsQuery" value="SELECT password FROM users WHERE username=?"/>
6 <module-option name="rolesQuery" value="SELECT role, 'Roles' FROM roles WHERE username=?"/>
7 <module-option name="unauthenticatedIdentity" value="guest"/>
8 </login-module>
9 </authentication>
10 </security-domain>
Alter jboss-web.xml:
Compression JBossAS7
http://docs.jboss.org/jbossweb/7.0.x/sysprops.html
org.apache.coyote.http11.Http11Protocol.COMPRESSION: force org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES: text/javascript,text/xml,text/html,text/plain,text/css
Clear transactions
Replace default page in JBossAS7
To replace this page set "enable-welcome-root" to false in your server configuration and deploy your own war with / as its context path.
Files standalone.xml or standalone-full.xml:
1 <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
2 <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" max-connections="5000"/>
3 <virtual-server name="default-host" enable-welcome-root="false">
4 <alias name="localhost"/>
5 <alias name="example.com"/>
6 </virtual-server>
7 </subsystem>
System properties in JBossAS7
https://community.jboss.org/wiki/JBossAS7SystemProperties
Files standalone.xml and domain.xml, and other with full and ha, add it after the extensions node:
1 <server name="xyz.home" xmlns="urn:jboss:domain:1.0">
2 <extensions>
3 <extension module="org.jboss.as.clustering.infinispan"/>
4 <extension module="org.jboss.as.clustering.jgroups"/>
5 <extension module="org.jboss.as.connector"/>
6 ....
7 <extension module="org.torquebox.web"/>
8 </extensions>
9 <system-properties>
10 <property name="org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR" value="false"/>
11 </system-properties>
12 ...
13 </server>
System properties in JBoss5
http://www.mastertheboss.com/jboss-configuration/how-to-inject-system-properties-into-jboss
Files properties-service.xml:
1 <server>
2 <mbean code="org.jboss.varia.property.SystemPropertiesService"
3 name="jboss:type=Service,name=SystemProperties">
4
5 <attribute name="URLList">
6 http://somehost/some-location.properties,
7 ./conf/somelocal.properties
8 </attribute>
9
10 <attribute name="Properties">
11 property1=This is the value of my property
12 property2=This is the value of my other property
13 </attribute>
14
15 </server>
Show web services in JBoss5
http://127.0.0.1:8080/jbossws/services
JBoss5 clustering
Clustering allows you to run an application on several parallel servers (a.k.a cluster nodes) while providing a single view to application clients. Load is distributed across different servers, and even if one or more of the servers fails, the application is still accessible via the surviving cluster nodes. Clustering is crucial for scalable enterprise applications, as you can improve performance by adding more nodes to the cluster. Clustering is crucial for highly available enterprise applications, as it is the clustering infrastructure that supports the redundancy needed for high availability.
JBoss5 run profile ALL and listen on 0.0.0.0
Windows: run.bat -c ALL -b 0.0.0.0 Linux: run.sh -c ALL -b 0.0.0.0
JBoss5 EJB client required libs
Libs in <JBOSS_HOME>/client:
- commons-logging.jar
- concurrent.jar
- ejb3-persistence.jar hibernate-annotations.jar
- jboss-aop-client.jar
- jboss-appclient.jar
- jboss-aspect-jdk50-client.jar
- jboss-client.jar
- jboss-common-core.jar
- jboss-deployers-client-spi.jar
- jboss-deployers-client.jar
- jboss-deployers-core-spi.jar
- jboss-deployers-core.jar
- jboss-deployment.jar
- jboss-ejb3-common-client.jar
- jboss-ejb3-core-client.jar
- jboss-ejb3-ext-api.jar
- jboss-ejb3-proxy-clustered-client.jar
- jboss-ejb3-proxy-impl-client.jar
- jboss-ejb3-proxy-spi-client.jar
- jboss-ejb3-security-client.jar
- jboss-ha-client.jar
- jboss-ha-legacy-client.jar
- jboss-iiop-client.jar
- jboss-integration.jar
- jboss-j2se.jar
- jboss-javaee.jar
- jboss-jsr77-client.jar
- jboss-logging-jdk.jar
- jboss-logging-log4j.jar
- jboss-logging-spi.jar
- jboss-main-client.jar
- jboss-mdr.jar
- jboss-messaging-client.jar
- jboss-remoting.jar
- jboss-security-spi.jar
- jboss-serialization.jar
- jboss-srp-client.jar
- jboss-system-client.jar
- jboss-system-jmx-client.jar
- jbosscx-client.jar
- jbossjts-integration.jar
- jbossjts.jar
- jbosssx-as-client.jar
- jbosssx-client.jar
- jmx-client.jar
- jmx-invoker-adaptor-client.jar
- jnp-client.jar
- slf4j-api.jar
- slf4j-jboss-logging.jar
- xmlsec.jar
Python script to help install locally the JARs
1 #!/usr/bin/python
2 # generate mvn install lines to register local jars JbossAS5 client EJB
3
4 artifacts=[
5 'commons-logging.jar',
6 'concurrent.jar',
7 'ejb3-persistence.jar hibernate-annotations.jar',
8 'jboss-aop-client.jar',
9 'jboss-appclient.jar',
10 'jboss-aspect-jdk50-client.jar',
11 'jboss-client.jar',
12 'jboss-common-core.jar',
13 'jboss-deployers-client-spi.jar',
14 'jboss-deployers-client.jar',
15 'jboss-deployers-core-spi.jar',
16 'jboss-deployers-core.jar',
17 'jboss-deployment.jar',
18 'jboss-ejb3-common-client.jar',
19 'jboss-ejb3-core-client.jar',
20 'jboss-ejb3-ext-api.jar',
21 'jboss-ejb3-proxy-clustered-client.jar',
22 'jboss-ejb3-proxy-impl-client.jar',
23 'jboss-ejb3-proxy-spi-client.jar',
24 'jboss-ejb3-security-client.jar',
25 'jboss-ha-client.jar',
26 'jboss-ha-legacy-client.jar',
27 'jboss-iiop-client.jar',
28 'jboss-integration.jar',
29 'jboss-j2se.jar',
30 'jboss-javaee.jar',
31 'jboss-jsr77-client.jar',
32 'jboss-logging-jdk.jar',
33 'jboss-logging-log4j.jar',
34 'jboss-logging-spi.jar',
35 'jboss-main-client.jar',
36 'jboss-mdr.jar',
37 'jboss-messaging-client.jar',
38 'jboss-remoting.jar',
39 'jboss-security-spi.jar',
40 'jboss-serialization.jar',
41 'jboss-srp-client.jar',
42 'jboss-system-client.jar',
43 'jboss-system-jmx-client.jar',
44 'jbosscx-client.jar',
45 'jbossjts-integration.jar',
46 'jbossjts.jar',
47 'jbosssx-as-client.jar',
48 'jbosssx-client.jar',
49 'jmx-client.jar',
50 'jmx-invoker-adaptor-client.jar',
51 'jnp-client.jar',
52 'slf4j-api.jar',
53 'slf4j-jboss-logging.jar',
54 'xmlsec.jar',]
55
56 base='call mvn install:install-file -Dfile=%s -DgroupId=jbossas5ejbclient -DartifactId=%s -Dversion=1.0 -Dpackaging=jar'
57 baseDepMvn='<dependency><groupId>jbossas5ejbclient</groupId><artifactId>%s</artifactId><version>1.0</version></dependency>'
58
59 for art in artifacts:
60 print base%(art,art.replace('.jar',''))
61
62 print ''
63
64 for art in artifacts:
65 print baseDepMvn%(art.replace('.jar',''))
List deployed web services on JBoss5
http://localhost:8080/jbossws/
http://localhost:8080/jbossws/services
List packages per JAR file
JBoss5 JAX-WS support
In JBoss 5.1.0 copy the following libraries from the JBOSS_HOME/client directory to the JBOSS_HOME/lib/endorsed directory, so that the JAX-WS 2.0 apis supported by JBossWS are used:
- jbossws-native-saaj.jar
- jbossws-native-jaxrpc.jar
- jbossws-native-jaxws.jar
- jbossws-native-jaxws-ext.jar
Or download the jdk6 distribution (jboss-5.0.0.GA-jdk6.zip)
http://sourceforge.net/projects/jboss/files/JBoss/JBoss-5.1.0.GA/
http://sourceforge.net/projects/jboss/files/JBoss/JBoss-5.1.0.GA/jboss-5.1.0.GA-jdk6.zip
http://sourceforge.net/projects/jboss/files/JBoss/JBoss-5.1.0.GA/jboss-5.1.0.GA.zip
Enable debugging
http://stackoverflow.com/questions/516196/jboss-debugging-in-eclipse
Linux run.conf
Windows run.conf.bat
To connect in Eclipse:
- Run
- Debug configurations
- Remote Java Application
Connect project: RemProj
- Connect type: Socket Attach
- Host: 127.0.0.1
- Port: 8787
JBoss EAP 6.4
