Tag: JBoss AS 6

EJB Specific Deployment descriptors in WebLogic and JBoss

Hi,

An EJB container is the component that manages a particular class of EJB. In JBoss there is one instance of the org.jboss.ejb.Container created for each unique configuration of an EJB that is deployed. The actual object that is instantiated is a subclass of Container and the creation of the container instance is managed by the EJBDeployer MBean.

The JBoss EJB container architecture employs a modular plug-in approach. All key aspects of the EJB container may be replaced by custom versions of a plug-in and/or an interceptor by a developer. This approach allows for fine tuned customization of the EJB container behavior to optimally suite your needs. Most of the EJB container behavior is configurable through the EJB JAR META-INF/jboss.xml descriptor and the default server-wide equivalent standardjboss.xml descriptor.

In order to migrate the EJB based application from WebLogic to JBoss most of the peoplefaces challenges specially when it comes to the container specific deployment descriptors. So here in this example we will see what kind of entries goes inside the WebLogic specific EJB Deployment descriptor “weblogic-ejb-jar.xml” and how those parameter and configurations can be moved insside the JBoss specific EJB Deployment descriptors like “jboss.xml” (for JBoss AS4/5/6) and “jboss-ejb3.xml” (for JBoss AS7).

First of all we will see where to find the XSDs based on which we can write these JBoss specific deployment descriptors.

WebLogic XSDs

WebLogic Schemas are present inside : “${WLS_INSTALLATION}/modules/com.bea.core.descriptor.wl.binding_1.2.0.0.jar” file.

Location: “WLS1031/modules/com.bea.core.descriptor.wl.binding_1.2.0.0/META-INF/schemas/weblogic-ejb-jar.xsd”

JBoss XSDs

JBoss Schemas are present inside the ${JBOSS_HOME}/docs/schema/jboss_5_1.xsd (JBoss AS6 and earlier versions)

JBoss Schemas are present inside the ${JBOSS_HOME}/docs/schema/jboss-ejb3-2_0.xsd (JBoss AS7)

Here we will see with all the possible elements inside “weblogic-ejb-jar.xml” file how it looks :

Before Migration (weblogic-ejb-jar.xml)

<weblogic-ejb-jar id="{someID}" version="{someString}">
  <description>{someDescription}</description>
  <weblogic-enterprise-bean id="{someID}">
    <ejb-name>{someEjbName}</ejb-name>
    <transaction-descriptor id="{someID}">
      <trans-timeout-seconds>{someTxTimeout}</trans-timeout-seconds>
    </transaction-descriptor>
    <iiop-security-descriptor id="{someID}">
      <transport-requirements id="{someID}">
        <integrity id="{someID}">{someString}</integrity>
        <confidentiality id="{someID}">{someString}</confidentiality>
        <client-cert-authentication id="{someID}">{someString}</client-cert-authentication>
      </transport-requirements>
      <client-authentication id="{someID}">{someString}</client-authentication>
      <identity-assertion id="{someID}">{someString}</identity-assertion>
    </iiop-security-descriptor>
    <enable-call-by-reference>{some-true-false}</enable-call-by-reference>
    <network-access-point>{someString}</network-access-point>
    <clients-on-same-server>{some-true-false}</clients-on-same-server>
    <run-as-principal-name>{some-Role-Name}</run-as-principal-name>
    <create-as-principal-name id="{someID}">{someString}</create-as-principal-name>
    <remove-as-principal-name id="{someID}">{someString}</remove-as-principal-name>
    <passivate-as-principal-name id="{someID}">{someString}</passivate-as-principal-name>
    <jndi-name>{someJndiName}</jndi-name>
    <local-jndi-name>{someJndiName}</local-jndi-name>
    <dispatch-policy>{some-dispatch-policyType}</dispatch-policy>
    <remote-client-timeout>{someTxTimeout}</remote-client-timeout>
    <stick-to-first-server>{some-true-false}</stick-to-first-server>
  </weblogic-enterprise-bean>
  <security-role-assignment>{some-Role-Name}</security-role-assignment>
  <run-as-role-assignment>{some-Role-Name}</run-as-role-assignment>
  <security-permission>{some-security-permissionType}</security-permission>
  <transaction-isolation id="{someID}">
    <isolation-level id="{someID}">{someString}</isolation-level>
    <method id="{someID}">
      <description>{someDescription}</description>
      <ejb-name>{someEjbName}</ejb-name>
      <method-intf>{something}</method-intf>
      <method-name>{something}</method-name>
      <method-params>{something}</method-params>
    </method>
  </transaction-isolation>

  <message-destination-descriptor>{some-message-destination-descriptorType}</message-destination-descriptor>
  <idempotent-methods id="{someID}">
    <method id="{someID}">
      <description>{someDescription}</description>
      <ejb-name>{someEjbName}</ejb-name>
      <method-intf>{something}</method-intf>
      <method-name>{something}</method-name>
      <method-params>{something}</method-params>
    </method>
  </idempotent-methods>
  <retry-methods-on-rollback id="{someID}">
    <description>{someDescription}</description>
    <retry-count>{someTxTimeout}</retry-count>
    <method id="{someID}">
      <description>{someDescription}</description>
      <ejb-name>{someEjbName}</ejb-name>
      <method-intf>{something}</method-intf>
      <method-name>{something}</method-name>
      <method-params>{something}</method-params>
    </method>
  </retry-methods-on-rollback>
  <enable-bean-class-redeploy>{some-true-false}</enable-bean-class-redeploy>
  <timer-implementation id="{someID}">{someString}</timer-implementation>
  <disable-warning id="{someID}">{someString}</disable-warning>
  <work-manager>{something}</work-manager>
  <component-factory-class-name>{someString}</component-factory-class-name>
  <weblogic-compatibility id="{someID}">
    <entity-always-uses-transaction>{some-true-false}</entity-always-uses-transaction>
  </weblogic-compatibility>
</weblogic-ejb-jar>

After Migration (jboss.xml) to JBoss AS5/6

Now if we will try to migrate a weblogic based EJB Application to JBoss AS 5/6 then it will look something like following:

<jboss version="{someString}" metadata-complete="{true-false}" id="{someID}">
  <loader-repository>{someClassLoaderRepositoryName}</loader-repository>
  <jmx-name>{someJMXName}</jmx-name>
  <security-domain>{someSecurityDomainName}</security-domain>
  <missing-method-permissions-excluded-mode></missing-method-permissions-excluded-mode>
  <unauthenticated-principal></unauthenticated-principal>
  <jndi-binding-policy>{someStringJndiPolicy}</jndi-binding-policy>
  <jacc-context-id></jacc-context-id>
  <webservices id="{someID}">
    <context-root>{someStringValue}</context-root>
    <webservice-description>{some-webservice-descriptionType}</webservice-description>
  </webservices>
  <enterprise-beans>
  <service id="{someID}">
    <ejb-name>{someEJBName}</ejb-name>
    <mapped-name>{someMBeanObjectName}</mapped-name>
    <business-local>{someRemoteInterfaceEJBClass}</business-local>
    <business-remote>{someRemoteInterfaceEJBClass}</business-remote>
    <ejb-class>{someEJBClass}</ejb-class>
    <security-identity id="{someID}">
      <description>{someStringDescription}</description>
      <run-as-principal>{someRoleName}</run-as-principal>
    </security-identity>
    <object-name>{someJMXName}</object-name>
    <management></management>
    <xmbean></xmbean>
    <local-binding>
      <description>{someStringDescription}</description>
      <jndi-name>{someStringJndiPType}</jndi-name>
    </local-binding>
    <remote-binding id="{someID}">
      <description>{someStringDescription}</description>
      <jndi-name>{someStringJndiPType}</jndi-name>
      <client-bind-url></client-bind-url>
      <interceptor-stack></interceptor-stack>
      <proxy-factory></proxy-factory>
      <invoker-name></invoker-name>
    </remote-binding>
    <jndi-name>{someStringJndiPType}</jndi-name>
    <home-jndi-name>{someStringJndiPType}</home-jndi-name>
    <local-jndi-name>{someStringJndiPType}</local-jndi-name>
    <jndi-binding-policy>{someStringJndiPolicy}</jndi-binding-policy>
    <clustered></clustered>
    <cluster-config id="{someID}">
      <description>{someStringDescription}</description>
      <partition-name></partition-name>
      <home-load-balance-policy></home-load-balance-policy>
      <session-state-manager-jndi-name>{someStringValue}</session-state-manager-jndi-name>
    </cluster-config>
    <security-domain>{someMBeanObjectName}</security-domain>
    <method-attributes id="{someID}">
      <method id="{someID}">
        <method-name>{some-method-nameType}</method-name>
        <read-only>{some-boolean}</read-only>
        <idempotent>{some-boolean}</idempotent>
        <transaction-timeout></transaction-timeout>
      </method>
    </method-attributes>
    <depends>{someMBeanObjectName}</depends>
    <annotation id="{someID}">
      <description>{someStringDescription}</description>
      <annotation-class></annotation-class>
      <annotation-implementation-class></annotation-implementation-class>
      <injection-target>{someInjectionTarget}</injection-target>
      <property id="{someID}">
        <description>{someStringDescription}</description>
        <property-name>{someStringValue}</property-name>
        <property-value>{someStringValue}</property-value>
      </property>
    </annotation>
    <ignore-dependency id="{someID}">
      <description>{someStringDescription}</description>
      <injection-target>{someInjectionTarget}</injection-target>
    </ignore-dependency>
    <aop-domain-name></aop-domain-name>
    <pool-config>
      <pool-value></pool-value>
      <pool-max-size></pool-max-size>
      <pool-timeout></pool-timeout>
    </pool-config>
    <concurrent></concurrent>
    <jndi-ref id="{someID}">
      <description>{someStringDescription}</description>
      <jndi-ref-name>{someStringJndiPType}</jndi-ref-name>
    </jndi-ref>
    <port-component id="{someID}">
      <port-component-name>{someStringValue}</port-component-name>
      <port-component-uri>{someStringValue}</port-component-uri>
      <auth-method>{someStringValue}</auth-method>
      <transport-guarantee>{someStringValue}</transport-guarantee>
      <secure-wsdl-access>{some-boolean}</secure-wsdl-access>
    </port-component>
    <ejb-timeout-identity id="{someID}">
      <description>{someStringDescription}</description>
      <run-as-principal>{someRoleName}</run-as-principal>
    </ejb-timeout-identity>
  </service>
  </enterprise-beans>
  <assembly-descriptor id="{someID}">
    <security-role>{some-security-roleType}</security-role>
    <message-destination>{some-message-destinationType}</message-destination>
  </assembly-descriptor>
  <resource-managers id="{someID}">
    <description>{someStringDescription}</description>
    <resource-manager id="{someID}" res-class="{someStringValue}">
      <description>{someStringDescription}</description>
      <res-name>{someMBeanObjectName}</res-name>
    </resource-manager>
  </resource-managers>
</jboss>

So now as we know the tags which we can use in an order while migrating from WebLogic to JBoss, it will be an easy task now. 🙂
To know more about these common JBoss specific deployment descriptors please refer to the following link:
http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/ENC_Usage_Conventions-EJB_References_with_jboss.xml_and_jboss_web.xml.html
.
.
Thanks 🙂
Middleware Magic Team


Useful list of sample twiddle command for AS 6

We have crated this article because JBoss AS 6 has a command line utility which is very useful to use when in production environments if your JMS console is been disabled then twiddle really comes handy. However there can be n-numbers of twiddle commands available but in this article we would be sharing few of the very useful commands which is been used in day to activity for an JBoss administrators.

If you feel like you have any twiddle commands which can be useful for other then feel free to share it with us and others so that other fellow JBoss administrators can get the benefits out of them. We would also like to share that most of the changes made using these twiddle commands are not permanent, meaning if you restart the JBoss server then the changes which were made by the twiddle commands would be overridden by the configuration which are given in the respective XML files.

To make is user friendly I have break down this commands in different sections so you can concentrate on your interests list of commands.

System utility twiddle commands

Shutdown JBoss

./twiddle.sh -s localhost:1099 -u admin -p admin invoke jboss.system:type=Server shutdown

Taking Theard Dump

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.system:type=ServerInfo" listThreadDump >> threadDump.html

List Memory Pools

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.system:type=ServerInfo" listMemoryPools true > memory.html

List Thread Cpu Utilization

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.system:type=ServerInfo" listThreadCpuUtilization > cpu.html

Application related twiddle commands

Deploy

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.system:service=MainDeployer" deploy "file:///home/rmody/JBoss_Data/Jboss/AS6/jboss-as/server/d-1/deploy/Test_WAR.war"

UnDeploy

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.system:service=MainDeployer" undeploy "file:///home/rmody/JBoss_Data/Jboss/AS6/jboss-as/server/d-1/deploy/Test_WAR.war"

ReDeploy

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.system:service=MainDeployer" redeploy "file:///home/rmody/JBoss_Data/Jboss/AS6/jboss-as/server/d-1/deploy/Test_WAR.war"

Maximum processing time of a request

./twiddle.sh -s localhost:1099 -u admin -p admin get "jboss.web:J2EEApplication=none,J2EEServer=none,WebModule=//localhost/Test_WAR,j2eeType=Servlet,name=jsp" maxTime

Number of requests processed by this wrapper

./twiddle.sh -s localhost:1099 -u admin -p admin get "jboss.web:J2EEApplication=none,J2EEServer=none,WebModule=//localhost/Test_WAR,j2eeType=Servlet,name=jsp" requestCount

JMS related twiddle commands

Creat a Queue

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.messaging:service=ServerPeer" deployQueue "testQueue" "testQueue-JNDIname"

Remove a Queue

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.messaging:service=ServerPeer" undeployQueue "TestQ"

Creat a Topic

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.messaging:service=ServerPeer" deployTopic "testTopic" "testTopic-JNDIname"

Remove a Topic

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.messaging:service=ServerPeer" undeployTopic "testTopic"

The number of messages in the queue

./twiddle.sh -s localhost:1099 -u admin -p admin get "jboss.messaging.destination:name=TestQ,service=Queue" MessageCount

Remove all messages in the queue

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.messaging.destination:name=TestQ,service=Queue" removeAllMessages

DataSource related twiddle commands

Connections currently in use

./twiddle.sh -s localhost:1099 -u admin -p admin get "jboss.jca:name=DefaultDS,service=ManagedConnectionPool" InUseConnectionCount

Logging Log4j related twiddle commands

Sets the log level for a given logger

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.system:service=Logging,type=Log4jService" setLoggerLevel "org.jboss" "TRACE"

Sets the levels of each logger specified by the given comma seperated list of logger names.

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.system:service=Logging,type=Log4jService" setLoggerLevels "org.jboss,org.jboss.system" "ERROR"

Displays the log level of a given logger.

./twiddle.sh -s localhost:1099 -u admin -p admin invoke "jboss.system:service=Logging,type=Log4jService" getLoggerLevel "org.jboss"

Creating Read Only Users for jmx-console and web-console

Hi,

JBoss AS6 provides admin-console, jmx-console and web-console for server monitoring and management purpose. By default the username and password for accessing these applications are “admin”, “admin”. But many times we want to create some more users who can login to these applications as a Read Only user so that these users will not have any privilege to make any configuration changes rather they can just do the monitoring part.

It is possible in JBoss AS6 to create read Only users fore jmx-console and web-console BUT Currently the admin-console application does not support read only users access so we CAN NOT create a read only user for “admin-console”. So in this demonstration we will see how we can create a Read Only (Monitor Role) in JBoss AS6 for web-console & jmx-console applications.

Step1). We need to edit the “$PROFILE/deploy/jmx-console.war/WEB-INF/web.xml” file by un-commenting the following section mentioned.

    <filter>
      <filter-name>JmxOpsAccessControlFilter</filter-name>
      <filter-class>org.jboss.jmx.adaptor.html.JMXOpsAccessControlFilter</filter-class>
      <init-param>
        <description>Comma-delimited Roles that define the JMX Operation denoting updation of Attributes</description>
        <param-name>updateAttributes</param-name>
        <param-value>UpdateAttributeRole</param-value>
      </init-param>
      <init-param>
        <description>Comma-delimited Roles that define the JMX Operation denoting Invocation of Operations</description>
        <param-name>invokeOp</param-name>
        <param-value>InvokeOpRole</param-value>
      </init-param>
   </filter>
   <filter-mapping>
      <filter-name>JmxOpsAccessControlFilter</filter-name>
      <servlet-name>HtmlAdaptor</servlet-name>
   </filter-mapping>

Step2). Now we need to edit the “$PROFILE/conf/props/jmx-console-roles.properties” like ollowing:
NOTE: to make read only role for “web-console” make the below mentioned changes inside “$PROFILE/deploy/management/console-mgr.sar/web-console.war/WEB-INF/classes/web-console-roles.properties” file.

# A sample roles.properties file for use with the UsersRolesLoginModule
admin=JBossAdmin,HttpInvoker,UpdateAttributeRole,InvokeOpRole
MyReadOnlyUserName=JBossAdmin

Here you can see that “MReadOnlyUserName” does not have the “UpdateAttributeRole,InvokeOpRole” roles means this user can not perform any update operation as well as this user can not perform any method Invocation operation from the console.

Step3). Similarly edit the “$PROFILE/conf/props/jmx-console-users.properties” like following :
NOTE: to make read only users for “web-console” make the below mentioned changes inside “$PROFILE/deploy/management/console-mgr.sar/web-console.war/WEB-INF/classes/web-console-users.properties” file.

# A sample users.properties file for use with the UsersRolesLoginModule
admin=admin
MyReadOnlyUserName=MyReadOnlyPassword

Step4). Setup is done so now you can restart your JBoss AS6 Profile and access in the jmx-console. Login as newly created user

username as MyReadOnlyUserName
password as MyReadOnlyPassword

You will receive a 403 error code “Access to the specified resource has been forbidden”, if you will try to make any configuration changes with this user credentials like changing the thread pool size…etc. But these changes you can easily make using the Non-Read only user credentials.

.
.
Thanks
Middleware Magic Team


Copyright © 2010-2012 Middleware Magic. All rights reserved. |