This case worked under RSA 7.0 and WAS 6.1.
In the application, it defined two roles, tliu:passw0rd:101:101:Thomas Liu and authenticated_user. Only users with administrator role can access administrator pages and carry out administrator functions. Any users authenticated with a pair of user id and password can access general pages and carry out general functions.
In the application.xml file of the EAR project, two security-roles were defined.
[security-role id="admin"]
[role-name]administrator[/role-name]
[/security-role]
[security-role id="user"]
[role-name]authenticated_user[/role-name]
[/security-role]
In the ibm-application-bnd.xml file of the EAR project, one authorization table with two authorizations was defined.
[authorizationTable xmi:id="AuthorizationTable_1126620398213"]
[authorizations xmi:id="RoleAssignment_1126807102767"]
[specialSubjects
xmi:type="applicationbnd:AllAuthenticatedUsers"
xmi:id="AllAuthenticatedUsers_1140011292114"
name="AllAuthenticatedUsers" /]
[role
href="META-INF/application.xml#user" /]
[/authorizations]
[authorizations xmi:id="RoleAssignment_1140011292114"]
[role
href="META-INF/application.xml#admin" /]
[groups xmi:id="Group_1140011292114" name="ceadmin" /]
[/authorizations]
[/authorizationTable]
In the web.xml file of the web project, two security-constraint, one login-config, and two security-role were defined.
[security-constraint]
[display-name]Administrators Constraint[/display-name]
[web-resource-collection]
[web-resource-name](Administrator Web Resource Collection)[/web-resource-name]
[description][/description]
[url-pattern]/admin/*[/url-pattern]
[http-method]GET[/http-method]
[http-method]PUT[/http-method]
[http-method]HEAD[/http-method]
[http-method]DELETE[/http-method]
[http-method]OPTIONS[/http-method]
[/web-resource-collection]
[auth-constraint]
[description][/description]
[role-name]administrator[/role-name]
[/auth-constraint]
[user-data-constraint]
[transport-guarantee]NONE[/transport-guarantee]
[/user-data-constraint]
[/security-constraint]
[security-constraint]
[web-resource-collection]
[web-resource-name](Users Web Resource Collection)[/web-resource-name]
[description][/description]
[url-pattern]/document/*[/url-pattern]
[http-method]GET[/http-method]
[http-method]PUT[/http-method]
[http-method]HEAD[/http-method]
[http-method]POST[/http-method]
[http-method]DELETE[/http-method]
[/web-resource-collection]
[auth-constraint]
[description][/description]
[role-name]authenticated_user[/role-name]
[/auth-constraint]
[user-data-constraint]
[transport-guarantee]NONE[/transport-guarantee]
[/user-data-constraint]
[/security-constraint]
[login-config]
[auth-method]FORM[/auth-method]
[form-login-config]
[form-login-page]/login.do[/form-login-page]
[form-error-page]/login_error.do[/form-error-page]
[/form-login-config]
[/login-config]
[security-role]
[description][/description]
[role-name]administrator[/role-name]
[/security-role]
[security-role]
[description][/description]
[role-name]authenticated_user[/role-name]
[/security-role]
The above login-config enabled the application to use a WebSphere extension called Form-based authentication. WAS Form-based authentication will be introduced in a later post.
In WAS administrative console, in Applications - Enterprise Applications - [Appl] - Security role to user/group mapping, there were two lines
Role | Everyone? | All authenticated? | Mapped users | Mapped groups
authenticated_users | unchecked | checked | null | null
administrator | unchecked | unchecked | null | ceadmin
WAS was defined to use File-based J2EE security. See a previous post about File-based J2EE security for details.
In the groups.props, add a line ceadmin:101:tester:CE Administrative Group, where the 101 was the group number.
In the users.props, add a line tester:password:101:101:CE Admin Tester, where the first 101 was the user number and the second group number.
With the above definitions, the application was able to make use of WAS security and can distinguish users by their authentication and role.
Monday, October 15, 2007
Friday, October 12, 2007
LDAP Browser in Eclipse
Actually I was installing LDAP browser plugin in my Rational Software Architect 7. I defined a remote update site using the URL http://directory.apache.org/studio/update/1.x and installed the LDAP Browser on my RSA.
That site was somehow a little bit weird. I tried the connection for several times before I was able to see the LDAP browser selection.
I used the "Connections" view to set up a new connection to LDAP server. After connected, I switched to the LDAP Browser view and saw three roots, DIT, Searches and Bookmarks.
The LDAP server which I connected was quite a big one. I easily got lost in the DIT tree. So I had to use the search. I learned something new here which was called the LDAP query.
For example, I needed to search any records that has a uid of ABC. What I needed to put in the "Filter" was (&(uid=ABC)). In my application, it had a query like (&(cn=my_group)(member=uid={0}, *)). It was very interesting, at least to me, since LDAP query was a new thing to me.
The searching speed was actually quite cool. Boom, the result was out. Since I would need to view that record from time to time. I saved it as a bookmark.
So far, the experience was good.
That site was somehow a little bit weird. I tried the connection for several times before I was able to see the LDAP browser selection.
I used the "Connections" view to set up a new connection to LDAP server. After connected, I switched to the LDAP Browser view and saw three roots, DIT, Searches and Bookmarks.
The LDAP server which I connected was quite a big one. I easily got lost in the DIT tree. So I had to use the search. I learned something new here which was called the LDAP query.
For example, I needed to search any records that has a uid of ABC. What I needed to put in the "Filter" was (&(uid=ABC)). In my application, it had a query like (&(cn=my_group)(member=uid={0}, *)). It was very interesting, at least to me, since LDAP query was a new thing to me.
The searching speed was actually quite cool. Boom, the result was out. Since I would need to view that record from time to time. I saved it as a bookmark.
So far, the experience was good.
Friday, October 05, 2007
WAS 6.1/RSA 7.0 File-based Authentication
To enable file-based authentication,
- start up WAS 6.1 in RSA 7.0
- run administrative console
- security > secure administration, applications, and infrastructure
- check on "Enable administrative security"
- check on "Enable application security" (might be checked on automatically when check on "Enable administrative security")
- check off "Use Java 2 security to restrict ..." (if on, be ready to define web resource and beans and roles)
- select "Standalone custom registry" from the "Available realm definitions"
- click on "Set as current"
- click on "Configuration", the "Standalone custom registry" page will be shown
- click on "Custom properties"
- add two properties, usersFile ${USER_INSTALL_ROOT}/File-based_JACC/users.props, groupsFile $USER_INSTALL_ROOT}/File-based_JACC/groups.props
- in Windows explorer, go to folder
\runtimes\base_v61\profiles\AppSrv01, e.g. C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01, and create a new folder "File-based_JACC" - under the newly created folder, create two files, users.props and groups.props,
- in users.props, add entry "wsadmin:password:100:100:Administrator"
- in groups.props, add entry "admins:100:wsadmin:Administrative group"
- go back to "Standalone custom registry" page in the administrative console
- enter "wsadmin" into "Primary administrative user name"
- select "Automatically generated server identity"
- make sure the "Custom registry class name" is "com.ibm.websphere.security.FileRegistrySample" (shall be by default)
- click on "OK" and click on "Save" if asked
- click on "Apply" and click on "Save" if asked
- right click on the "WebSphere Application Server v6.1" in "Servers" view and select "Open"
- expand "Security" and check on "Security is enabled on this server"
- enter "wsadmin" in "User ID" and "password" in "Password"
- save changes made to the server
- restart the server, the server should be ready to use file-based authentication.
Wednesday, October 03, 2007
Ant with JUnit in WID 6.0.2
Since I had a junit task in my ant script, I added the junit.jar into ant::Runtime::Classpath::Global Entries. The interesting part was, WID warned me no tools.jar in the classpath and asked me if I wanted to ignore it.
I searched tools.jar under WID installation. None of them was exactly fit to me. So I decided to ignore it.
Run the ant script, it completed successfully. Question is, what does tools.jar do in ant classpath?
I searched tools.jar under WID installation. None of them was exactly fit to me. So I decided to ignore it.
Run the ant script, it completed successfully. Question is, what does tools.jar do in ant classpath?
IBM WebSphere Integration Developer
Current version is 6.0.2. Updates will be made available through the Rational Product Updater. As I installed it on 10/2/2007, necessary updates were available and required to be installed.
If IBM WebSphere Process Server Test Environment is also installed, its updates are not provided through the Rational Product Updater, but may be obtained by visiting http://www.ibm.com/software/integration/wps/support/. Current updates are Fixpack 2 to 6.0.2, released on 7/31/2007.
Started using WID without updates. Since we use Harvest, I started with installing Harvest plugin. WID 6.0.2 uses Eclipse 3.0.2. Harvest plugin site is the same for Eclipse 3.2, 3.1, and 3.0. The site is http://supportconnectw.ca.com/public/harvesteclipse.
Carefully selected Eclipse 3.0, then plugin version 6.20.2. Check out a project from Harvest, no problem. Synchronize the workspace with Harvest, it suggested removing local files.
Harvest plugin was actually installed under rwd. Locate it and uninstall it. Do the plugin installation again, select 6.20.1 and then carefully select the destination to eclipse not rwd. This time the synchronization worked fine.
WID 6.0.2 uses Sun JDK 1.4.2 as default JRE. It has WAS 5.1 and 6.0, but not 6.1. It has the default perspective Business Integration, the only one cannot be found in Rational Software Architect 7.0.0.3.
- WebSphere Integration Developer Fix Pack 6.0.2.2
- WebSphere Integration Developer 6.0.2.2 Interim Fix 002
- WebSphere Integration Developer 6.0.2.2 National Language Support Interim Fix
- J2EE Connector Tools 6.0.1.5
If IBM WebSphere Process Server Test Environment is also installed, its updates are not provided through the Rational Product Updater, but may be obtained by visiting http://www.ibm.com/software/integration/wps/support/. Current updates are Fixpack 2 to 6.0.2, released on 7/31/2007.
Started using WID without updates. Since we use Harvest, I started with installing Harvest plugin. WID 6.0.2 uses Eclipse 3.0.2. Harvest plugin site is the same for Eclipse 3.2, 3.1, and 3.0. The site is http://supportconnectw.ca.com/public/harvesteclipse.
Carefully selected Eclipse 3.0, then plugin version 6.20.2. Check out a project from Harvest, no problem. Synchronize the workspace with Harvest, it suggested removing local files.
Harvest plugin was actually installed under rwd. Locate it and uninstall it. Do the plugin installation again, select 6.20.1 and then carefully select the destination to eclipse not rwd. This time the synchronization worked fine.
WID 6.0.2 uses Sun JDK 1.4.2 as default JRE. It has WAS 5.1 and 6.0, but not 6.1. It has the default perspective Business Integration, the only one cannot be found in Rational Software Architect 7.0.0.3.
Tuesday, October 02, 2007
JACC - Java Authorization Container Contract
The Java Authorization Container Contract (JACC) is a specification that was introduced in Java 2 Platform, Enterprise Edition (J2EE) 1.4 through the Java Specification Request (JSR) 115 process. This specification defines a contract between J2EE containers and authorization providers. This enables any third-party authorization providers to plug into any J2EE 1.4 Application Servers such as WebSphere to make authorization decisions when a J2EE resource is being accessed. The access decisions is made through the standard java.security.Policy object.
When an authenticated user makes a request to a web or a EJB resource, the security runtime makes the decision of whether to allow the access. This is called an access decision. Based on JACC, the appropriate permission object is created, the appropriate policy context handlers are registered, and the appropriate policy context identifier (contextID) is set. A call is made to the java.security.Policy object that is implemented by the provider to make the access decision.
In IBM WebSphere Application Server (WAS), when security is enabled, the default authorization is used unless a JACC provider is specified. The default authorization does not require special setup, and the default authorization engine makes all of the authorization decisions. However, if a JACC provider is configured and set up for WAS, all of the enterprise bean and web resource access decision will be delegated to the JACC provider.
When an authenticated user makes a request to a web or a EJB resource, the security runtime makes the decision of whether to allow the access. This is called an access decision. Based on JACC, the appropriate permission object is created, the appropriate policy context handlers are registered, and the appropriate policy context identifier (contextID) is set. A call is made to the java.security.Policy object that is implemented by the provider to make the access decision.
In IBM WebSphere Application Server (WAS), when security is enabled, the default authorization is used unless a JACC provider is specified. The default authorization does not require special setup, and the default authorization engine makes all of the authorization decisions. However, if a JACC provider is configured and set up for WAS, all of the enterprise bean and web resource access decision will be delegated to the JACC provider.
Monday, October 01, 2007
WAS 6.1 Startup Error on SystemOut.log
My WAS 6.1 on RSA 7.0.0.3 has this error when starts up.
[10/1/07 9:48:28:785 EDT] 0000000a WrappingFileO E archiveCurrentFile TRAS0016E: An unexpected exception while trying to archive log file C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\logs\server1\SystemOut.log Exception is java.io.IOException: Unable to rename file C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\logs\server1\SystemOut.log to C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\logs\server1\SystemOut_07.10.01_09.48.28.log. Logging continues.It was said on IBM WID Forum that the fix for this issue will be available in 6.0.2.25 fixpack.
Friday, September 28, 2007
Log4JCategoryLog
Apache common logging 1.0 used Log4JCategoryLog. In version 1.1, replace it with Log4JLogger. The commons-logging.properties file will look like this,
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
Monday, September 17, 2007
Tuesday, September 11, 2007
Hibernate and Struts - Identifier Altered
In our application, we used Hibernate 3.1.2, Spring 1.2.6 and Struts 1.2.4. One of the page flows was to gather input from a form and insert a record into database then go back to the list page.
We saw messages like that,
Then we read Spring document and found HibernateTemplate recommended over Session. So we replaced Session with Template. But it didn't solve the problem.
Because because it had no problem going back to list after update, we tried to use saveOrUpdate and replace save. But it was the same.
Finally we noticed the Hibernate flush was scheduled after the page was forwarded, no matter what the setting of transaction.flush_before_completion was true or false. We also noticed the struts always recovered the form after forward. We tried to reset the data bean in the form right after insert. And this time, it solved the problem.
We saw messages like that,
org.hibernate.HibernateException: identifier of an instance of ... was altered ...In the beginning of investigation, we found the Hibernate related code did not flush after insert. We added the flush, but it didn't solve the problem.
...
org.hibernate.event.def.DefaultFlushEventListener.onFlush...
...
Then we read Spring document and found HibernateTemplate recommended over Session. So we replaced Session with Template. But it didn't solve the problem.
Because because it had no problem going back to list after update, we tried to use saveOrUpdate and replace save. But it was the same.
Finally we noticed the Hibernate flush was scheduled after the page was forwarded, no matter what the setting of transaction.flush_before_completion was true or false. We also noticed the struts always recovered the form after forward. We tried to reset the data bean in the form right after insert. And this time, it solved the problem.
Thursday, September 06, 2007
Hibernate and MS SQL - Nullability Problem
The nullability problem happens when Hibernate 3 deletes an instance with any null value property defined not nullable.
However, it is necessary to define some properties not nullable. In this case, modify the application and let the property has non-null value or get the instance from database by primary key, then delete it.
This problem was reported to Hibernate on August, 2007. No known release fixes it.
org.springframework.orm.hibernate3.HibernateSystemException: not-null property references a null or transient value: com.ag.applications.forms.entity.qstnaire.QstnaireBean.qstnaireNam; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.ag.applications.forms.entity.qstnaire.QstnaireBean.qstnaireNamTo get rid of the error, edit the hbm.xml file and change the not-null="true" to "false".
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.ag.applications.forms.entity.qstnaire.QstnaireBean.qstnaireNam
However, it is necessary to define some properties not nullable. In this case, modify the application and let the property has non-null value or get the instance from database by primary key, then delete it.
This problem was reported to Hibernate on August, 2007. No known release fixes it.
Wednesday, September 05, 2007
Hibernate and MS SQL - Delete Operation
When does delete operation, application prompts message,
Here is the solution, in applicationContext.xml, set the property "checkWriteOperations" of "org.springframework.orm.hibernate3.HibernateTemplate" to false.
Data Access Error: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition.This is because Spring 1.2 is incompatible with Hibernate 3. I heard Spring 2.0 solved this problem, but I found a workaround solution with Spring 1.2.
Here is the solution, in applicationContext.xml, set the property "checkWriteOperations" of "org.springframework.orm.hibernate3.HibernateTemplate" to false.
Tuesday, September 04, 2007
Hibernate and MS SQL - Unsupported prepareStatement
Insert operation generated by Hibernate didn't work with MS SQL. I was using Hibernate 3.1.2, WAS 6.1, JVM 1.5. And I was testing two JDBC drivers.
For IBM ConnectJDBC for MS SQL,
Here is the definition of the property.
For IBM ConnectJDBC for MS SQL,
java.sql.SQLException: [IBM][SQLServer JDBC Driver]Unsupported method: Connection.prepareStatementFor DirectData ConnectJDBC for MS SQL,
at com.ibm.websphere.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.ibm.websphere.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.ibm.websphere.jdbc.base.BaseConnection.prepareStatement(Unknown Source)
at com.ibm.websphere.jdbcx.base.BasePooledConnection.prepareStatement(Unknown Source)
at com.ibm.websphere.jdbcx.base.BaseConnectionWrapper.prepareStatement(Unknown Source)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.pmiPrepareStatement(WSJdbcConnection.java:3980)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:3854)
java.sql.SQLException: [DataDirect][SQLServer JDBC Driver]Unsupported method: Connection.prepareStatement(String, String[])There is a saying that the Connection.prepareStatement(String sql, String[] columnNames) is not supported. Workaround solution is to set the "hibernate.jdbc.use_get_generated_keys" to false in the hibernate settings, either in the properties or in the cfg.xml.
at com.ddtek.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.ddtek.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.ddtek.jdbc.base.BaseConnection.prepareStatement(Unknown Source)
at com.ddtek.jdbcx.base.BasePooledConnection.prepareStatement(Unknown Source)
at com.ddtek.jdbcx.base.BaseConnectionWrapper.prepareStatement(Unknown Source)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.pmiPrepareStatement(WSJdbcConnection.java:3980)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:3854)
Here is the definition of the property.
Enable use of JDBC3 PreparedStatement.getGeneratedKeys() to retrieve natively generated keys after insert. Requires JDBC3+ driver and JRE1.4+, set to false if your driver has problems with the Hibernate identifier generators. By default, tries to determine the driver capabilites using connection metadata.eg. true|false
Here is the quote from mdiamonte in DataDirect forum.
Against SQL Server 2000, the driver can not implement this method correctly in the general case because SQL Server 2000 does not allow you to return the value of an arbitrary column from an insert, update or delete statement. At least not with out making an extra round trip to the server, which negates the purpose of this method.
I have seen implementations of this method by other drivers where the value returned will be the value of the identity column regardless of which column was actually asked for. I believe that implementation is bad. I feel it is much worse for a driver to return incorrect information than it is to not be able to return the information. Assuming the id column in the statement is an identity column, then Hibernate may have just gotten lucky that it worked in the testing that they did.
Tuesday, August 28, 2007
Migrate WASD 5.1 Application to RSA 7.0/WAS 6.1
Get the application source from Harvest repository. Disconnect Harvest connection.
Create a new web project and ear project in RSA on a new folder. Import source code from the old folder. Compile passed.
Deploy to the embedded WAS 6.1. Run.
Find the tld path problem. Old web.xml sets tlds under WEB_INF/, now application looks tlds under WEB_INF/tlds. Edit web.xml and fix it. WAS 6.1 automatically republishes the app and restart the app.
Get this exception.
Encounter the same exception.
Several combinations tried. Finally this one worked.
Download spring-framework-1.2.9-with-dependencies.zip and extract the cglib-nodep-2.1_3.jar and replace the original cglib-2.1_3.jar. Redeploy the application in workspace to WAS 6.1 and restart server.
It is possibly both spring framework and hibernate depend on cglib, and further on asm, but they require different asm. cglib-nodep actually packages a revised asm, spring will have no need of a separate asm and let hiberate uses the asm exclusively. Hibernate may actually not need any cglib, but no time for this research yet.
Create a new web project and ear project in RSA on a new folder. Import source code from the old folder. Compile passed.
Deploy to the embedded WAS 6.1. Run.
Find the tld path problem. Old web.xml sets tlds under WEB_INF/, now application looks tlds under WEB_INF/tlds. Edit web.xml and fix it. WAS 6.1 automatically republishes the app and restart the app.
Get this exception.
[8/28/07 10:49:14:485 EDT] 00000036 WebApp E Exception caught while initializing contextSearch Google. Find talks on incompatibility of asm, cglib, spring and hibernate. We are using
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator' defined in ServletContext resource [/WEB-INF/declarativeServices.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.FatalBeanException: Could not instantiate class [org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator]; constructor threw exception; nested exception is java.lang.NoSuchMethodError: org/objectweb/asm/ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
org.springframework.beans.FatalBeanException: Could not instantiate class [org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator]; constructor threw exception; nested exception is java.lang.NoSuchMethodError: org/objectweb/asm/ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
java.lang.NoSuchMethodError: org/objectweb/asm/ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
- spring-1.2.6
- hibernate-3.1.2
- asm-1.5.3
- cglib-2.1_3
Encounter the same exception.
Several combinations tried. Finally this one worked.
Download spring-framework-1.2.9-with-dependencies.zip and extract the cglib-nodep-2.1_3.jar and replace the original cglib-2.1_3.jar. Redeploy the application in workspace to WAS 6.1 and restart server.
It is possibly both spring framework and hibernate depend on cglib, and further on asm, but they require different asm. cglib-nodep actually packages a revised asm, spring will have no need of a separate asm and let hiberate uses the asm exclusively. Hibernate may actually not need any cglib, but no time for this research yet.
Saturday, August 18, 2007
终于能在Red Hat中键入中文
关键是需要将默认的语言设置成简体中文,然后用Ctrl+Space在中英文之间切换。
默认的输入法是二笔,我不会,改成了智能拼音就好了。和用惯了的全拼有些区别,用用也就习惯了。
简体中文中好多系统菜单翻译得莫名其妙,试了试,不知道怎么切回英文。
默认的输入法是二笔,我不会,改成了智能拼音就好了。和用惯了的全拼有些区别,用用也就习惯了。
简体中文中好多系统菜单翻译得莫名其妙,试了试,不知道怎么切回英文。
Thursday, August 09, 2007
Compare Fuse Message Broker 4.1 to Apache Active MQ 4.1.1
- conf\activemq.xml: Fuse has one more block of comments.
- installsession_log.xml: only Fuse has.
- docs: Fuse has welcome.htm and more images.
- etc: only Fuse has etc folder, including license_agreement.txt and notices.txt. Apache puts these two files at the root directory.
- example is not compared.
- lib: Most differences are on the release number. Fuse is 4.1.2.4, Apache is 4.1.1. One noticable difference is Fuse has xbean-spring-fuse-2.7.0.0.jar, but Apache has xbean-spring-2.8.jar.
Monday, August 06, 2007
Unit Test - Piece of Logic Covered or Not?
Emma coverage report will show uncovered pieces of logic red. For example,
if (validField(fk.getName(), valueFK)) {
criteria.add(buildRestriction(propertyTypes[i], value, relationName));
criteriaCount.add(buildRestriction(propertyTypes[i], value, relationName));
}
In the unit test, you will need to make the validField returns true. And then the report will show them covered and mark them green.
JMS Implementation with RSA 7.0 and WAS 6.1
Environment:
IBM Rational Software Architect 7.0 with embedded WebSphere Application Server 6.1.
Purpose:
Export minzyClient to C:\development\applications\minzyClient.ear.
Export minzyEnt to C:\development\applications\minzyEnt.ear.
Deployment:
In a command line window, change directory to C:\Program Files\IBM\SDP70\runtimes\base_v61\bin. Run,
setupCmdLine.bat
launchClient \development\applications\minzyClient.ear -CCBootstrapPort=2810
In the command line window, you shall see,
WSCL0014I: Invoking the Application Client class tliu.minzy.client.MessProducer
Minzy mess produced.
In the server console, you shall see,
[8/6/07 13:33:32:455 EDT] 0000002f SystemOut O Message Received: Hello, minzy.
The End.
IBM Rational Software Architect 7.0 with embedded WebSphere Application Server 6.1.
Purpose:
- Create a JMS client application to send a simple message to a queue defined by WAS 6.1 default messaging provider.
- Create a MDB to consume the message received by the queue.
- Open RSA, use the New wizard to create an Enterprise Application Project under J2EE group, if you cannot see this selection, check if you are using the J2EE perspective. I called the project minzy.
- Click "Show Runtimes" to make sure the v6.1 is selected.
- Click "New Modules" to create default modules, check off Web module and Connector module, which we don't need, and change the name of the EJB module to minzyEnt. It's only my preference, you can call it any name.
- Rename source folders to "src" in both minzyClient and minzyEnt.
- In minzyClient, create a package "tliu.minzy.client" and create a class "MessProducer" with main method.
- Delete default package.
- Edit MANIFEST.MF under META-INF and change Main-Class to tliu.minzy.client.MessProducer.
- From menu Project, select clean and select minzyClient, minzyEnt and minzy, error in minzy and minzyClient will be gone.
- In minzyEnt, create package tliu.minzy.ent, use New wizard to create a Enterprise Bean.
- Check "Message-driven bean", give name MessConsumer, select package tliu.minzy.ent and check on "Generate an annotated bean class".
- Make sure JMS type is javax.jms.MessageListener.
- Check off "Add bean to Class Diagram", diagrams are out of the scope.
- Now you see all error gone, we are ready to put real codes in.
public static void main(String[] args) throws Exception {
InitialContext initCtx = new InitialContext();
javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) initCtx.lookup("jms/minzyConnectionFactory");
Destination q = (Destination) initCtx.lookup("jms/minzyQueue");
Connection connection = qcf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer queueSender = session.createProducer(q);
TextMessage outMessage = session.createTextMessage();
outMessage.setText("Hello, minzy.");
outMessage.setJMSType("minzy");
outMessage.setJMSDestination(q);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
queueSender.send(outMessage);
connection.close();
System.out.println("Minzy mess produced.");
}
Code in MessConsumerBean: public void onMessage(javax.jms.Message mess) {
TextMessage text = (TextMessage) mess;
try {
System.out.println("Message Received: " + text.getText());
} catch (JMSException e) {
System.out.println("Oops, exception.");
}
}
Packaging:Export minzyClient to C:\development\applications\minzyClient.ear.
Export minzyEnt to C:\development\applications\minzyEnt.ear.
Deployment:
- In Servers view in RSA, select WebSphere Application Server v6.1 and start the server.
- After started, right click the server and select "Run administrative console".
- Navigate Service integration > Buses > New and create a bus "minzyBus".
- Navigate minzyBus > Bus members > Add and add server "cledt-123691Node02:server1".
- Open a command window, and change directory to "C:\Program Files\IBM\SDP70\runtimes\base_v61\bin", run "setupCmdLine.bat".
- Run "wsadmin -f installSdoRepository.jacl -createDb cledt-123691Node02 server1".
- Verify SDO Repository successfully started under Enterprise Applications. Note, install once per server.
- Run "wsadmin -f ../util/sibwsInstall.jacl INSTALL_RA -installRoot "C:/Program Files/IBM/SDP70/runtimes/base_v61" -nodeName cledt-123691Node02". Note, install once per node.
- Run "wsadmin -f ../util/sibwsInstall.jacl INSTALL -installRoot "C:/Program Files/IBM/SDP70/runtimes/base_v61" -serverName server1 -nodeName cledt-123691Node02".
- Run "wsadmin -f ../util/sibwsInstall.jacl INSTALL_HTTP -installRoot "C:/Program Files/IBM/SDP70/runtimes/base_v61" -serverName server1 -nodeName cledt-123691Node02".
- In the admin console, navigate to Servers > Application Servers > server1 > Endpoint Listeners and select New. Specify SOAPHTTPChannel1 as name, http://cledt-123691.agna.amgreetings.com:9081/SOAPHTTPChannel1 as URL root, http://cledt-123691.agna.amgreetings.com:9081/sibws as WSDL root.
- Select the "Connection Properties" of SOAPHTTPChannel1, client New and select minzyBus.
- Go to minzyBus > Destinations, there should be a new destination called cledt-123691Node02.server1.SOAPHTTPChannel1Reply.
- Navigate minzyBus > Destinations > New and create a Queue type destination "minzyDestination".
- Navigate Resources > JMS Providers > Default messaging. Select Node as the scope.
- Select Connection factories and click New. Enter minzyConnectionFactory as name, jms/minzyConnectionFactory as JNDI name, select minzyBus, enter localhost:7277 in the "Provider endpoints" box, leave other default and click OK.
- Go back to Default messaging provider and select Queues. Click New.
- Enter minzyQueue as name, jms/minzyQueue as JNDI name, select minzyBus and minzyDestination. Click OK.
- Go back to Default messaging provider and select Activation specifications. Click New.
- Enter minzyActivation as name, eis/minzyActivation as JNDI name, jms/minzyQueue as Destination JNDI name and select minzyBus. Click OK and save all your changes.
- Install minzyEnt.ear in admin console. Make sure Deploy enterprise beans are checked. Enter eis/minzyActivation as Activation Specification Target and jms/minzyQueue as Destination.
- Restart server.
In a command line window, change directory to C:\Program Files\IBM\SDP70\runtimes\base_v61\bin. Run,
setupCmdLine.bat
launchClient \development\applications\minzyClient.ear -CCBootstrapPort=2810
In the command line window, you shall see,
WSCL0014I: Invoking the Application Client class tliu.minzy.client.MessProducer
Minzy mess produced.
In the server console, you shall see,
[8/6/07 13:33:32:455 EDT] 0000002f SystemOut O Message Received: Hello, minzy.
The End.
Thursday, August 02, 2007
WAS 6.1 - JMS Default Provider Administrative Aspect
In WAS 6.1, there is a default messaging JMS provider. It comes with WAS 6.1.
To list messages in a queue, go through this path,
Service integration > Buses > [TheBus] > Messaging engines > [cledt-123691Node01.server1-TheBus] > Queue points > [MyQueueDestination@cledt-123691Node01.server1-TheBus] > Runtime
you see the "Current message depth".
Select "Messages", you see messages and their position, identifier, state and transaction id. You can select any of them and click "Delete" or just click "Delete all" to delete them from the queue.
The message's identifier is actually a link. Click it to get the detail of the message. It shows
identifier, state, transaction id, message type, approximate length, time stamp, message wait time, current messaging engine arrival time, redelivered count, security user id, producer type, message id, correlation id, user id, format, JMS delivery mode, JMS expiration, JMS destination, JMS reply to destination, JMS redelivered, JMS type, JMSX delivery count, JMSX application id, discriminator, priority, reliability, time to live, reply discriminator, reply priority, reply reliability, reply time to live and system message id. All attributes are read only.
Click "Message body", you will get "Approximate total message size" in bytes, message body. The message body is also read only.
You can define Performance Monitoring Infrastructure(PMI) to collect JMS runtime statistics. You will need a PMI client to view these statistics. So far, Tivoli Performance Viewer(TPV) is the only known PMI client to us. TPV has not been tested so far. According to IBM, TPV comes with WAS 6.1 and is free.
To list messages in a queue, go through this path,
Service integration > Buses > [TheBus] > Messaging engines > [cledt-123691Node01.server1-TheBus] > Queue points > [MyQueueDestination@cledt-123691Node01.server1-TheBus] > Runtime
you see the "Current message depth".
Select "Messages", you see messages and their position, identifier, state and transaction id. You can select any of them and click "Delete" or just click "Delete all" to delete them from the queue.
The message's identifier is actually a link. Click it to get the detail of the message. It shows
identifier, state, transaction id, message type, approximate length, time stamp, message wait time, current messaging engine arrival time, redelivered count, security user id, producer type, message id, correlation id, user id, format, JMS delivery mode, JMS expiration, JMS destination, JMS reply to destination, JMS redelivered, JMS type, JMSX delivery count, JMSX application id, discriminator, priority, reliability, time to live, reply discriminator, reply priority, reply reliability, reply time to live and system message id. All attributes are read only.
Click "Message body", you will get "Approximate total message size" in bytes, message body. The message body is also read only.
You can define Performance Monitoring Infrastructure(PMI) to collect JMS runtime statistics. You will need a PMI client to view these statistics. So far, Tivoli Performance Viewer(TPV) is the only known PMI client to us. TPV has not been tested so far. According to IBM, TPV comes with WAS 6.1 and is free.
Subscribe to:
Posts (Atom)