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.

https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/5/html/Messaging_User_Guide/ch05s13.html#table-MDB_JCA_Spec_Properties

Annotations, MDB Properties Provided by the JCA Specification

Name

Type

Default value

Remarks

destination

java.lang.String

none

This property is Mandatory The JNDI name of the Queue or Topic.

destinationType

java.lang.String

none

The type of destination valid values are javax.jms.Queue or javax.jms.Topic

messageSelector

java.lang.String

none

The message selector of the subscription

acknowledgeMode

int

AUTO_ACKNOWLEDGE

The type of acknowledgement when not using transacted jms - valid values AUTO_ ACKNOWLEDGE or DUPS_OK_ ACKNOWLEDGE

clientID

java.lang.String

The client id of the connection

subscriptionDurability

String

NonDurable

Whether topic subscriptions are durable. Valid values are Durable orNonDurable

subscriptionName

String

none

The subscription name of the topic subscription

MDB Properties Provided as JBoss Extensions

Name

Type

Default value

Remarks

isTopic

boolean

false

Sets the destinationType

providerAdapterJNDI

java.lang.String

DefaultJMSProvider

The JNDI name of the JMS provider.

user

java.lang.String

none

The user ID used to connect to the JMS server

pass

java.lang.String

none

The password of the user

maxMessages

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

minSession

int

1

The minimum number of JMS sessions that are available to concurrently deliver messages to this mdb

maxSession

int

15

The maximum number of JMS sessions that are available to concurrently deliver messages to this mdb

reconnectInterval

long

10 seconds

The length of time in seconds between attempts to (re-)connect to the JMS provider

keepAlive

long

60 seconds

The length of time in milliseconds that sessions over the minimum are kept alive

sessionTransacted

boolean

true

Whether the sessions are transacted

useDLQ

boolean

true

Whether to use a Dead Letter Queue (DLQ) handler.

dLQJNDIName

java.lang.String

queue/DLQ

The JNDI name of the DLQ

dLQHandler

java.lang.String

org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler

The org.jboss.resource. adapter.jms.inflow. DLQHandler implementation class name.

dLQUser

java.lang.String

none

The user id used to make the dlq connection to the JMS server

dLQPassword

java.lang.String

none

The password of the dLQUser

dLQClientID

java.lang.String

none

The client id of the DLQ connection

dLQMaxResent

int

5

The maximum number of times a message is redelivered before it is sent to the DLQ.

redeliverUnspecified

boolean

true

Whether to attempt to redeliver a message in an unspecified transaction context

transactionTimeout

int

Default is the timeout set for the resource manager

Time in seconds for the transaction timeout

DeliveryActive

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:

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:

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

   1 <?xml version="1.0" encoding="UTF-8"?>
   2 <jboss-web>
   3   <context-root>/AppContextRoot</context-root>
   4   <security-domain>java:/jaas/other</security-domain> <!-- security application realm -->
   5 </jboss-web>

Forms login

The following input fields are posted when a login is attempted:

In web.xml:

   1     <login-config>
   2         <auth-method>FORM</auth-method>
   3         <realm-name>AppRealm</realm-name>
   4         <form-login-config>
   5             <form-login-page>/login.html</form-login-page>
   6             <form-error-page>/error.html</form-error-page>
   7         </form-login-config>
   8     </login-config>        

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:

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:

   1 <jboss-web>
   2 <!-- ... -->
   3     <security-domain>java:/jaas/jdbcRealm</security-domain>
   4 </jboss-web>

Compression JBossAS7

http://docs.jboss.org/jbossweb/7.0.x/sysprops.html

Clear transactions

   1 service jboss stop
   2 cd /opt/jboss/standalone/data/tx-object-store
   3 rm * -rf
   4 service jboss start

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

http://docs.jboss.org/jbossclustering/cluster_guide/5.1/html/clustering-intro.chapt.html

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:

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

   1 cd lib/
   2 ls *.jar | xargs -i sh -c 'echo {}; jar -tvf {}'
   3 find . -name *.jar | xargs -i sh -c 'echo {}; jar -tvf {}' > /tmp/out.txt

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:

Or download the jdk6 distribution (jboss-5.0.0.GA-jdk6.zip)

http://docs.jboss.org/jbossas/docs/Installation_And_Getting_Started_Guide/5/html/source_installation.html

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

   1 # Sample JPDA settings for remote socket debugging
   2 JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

Windows run.conf.bat

   1 rem # Sample JPDA settings for remote socket debugging
   2 set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

To connect in Eclipse:

JBoss EAP 6.4

Listen public IP address 0.0.0.0

   1 cd  /jboss-eap-6.4/standalone/configuration
   2 sed -i 's/127.0.0.1/0.0.0.0/g' standalone.xml # change listen IP address
   3 cd /jboss-eap-6.4
   4 bin/standalone.sh # Start jboss
   5 netstat -at -n | grep 8080 | grep -i LISTEN
   6 #  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       InHost
   7 

Java/JBoss (last edited 2023-05-29 08:54:43 by 127)