- run /usr/sbin/alternatives --config java, it gives no response.
- run uname -m and it gives i386. it means it is a linux not a linux64.
- download jdk rpm from java.sun.com, at the time, sun provides JDK 6 Update 12. select the Linux and the rpm.bin
- chmod of the bin file and make it executable, run it
- Get error -bash: ./jdk-6u12-linux-i586-rpm.bin: /bin/sh: bad interpreter: Permission denied
- after some research, i realized that the /tmp is shared managed. it won't allow me to run any scripts there. so i moved the bin file to my home directory and run it, it installed the java automatically
- run rpm -qa | grep java and got jdk-1.6.0_12-fcs, run rpm -qa | grep sun also returns a bunch of packages
- run /usr/sbin/alternatives --config java, it still gives no response but run java -version, it gives the 1.6.0_12 back.
- done.
Saturday, February 21, 2009
Install Java 6 on CentOS 5.2
Monday, February 09, 2009
Unicode in Web Application
In your web application, you allow users type 似水流年 and you get it from HTTP request and obtain a string.
When you compare the string obtained from request and the string stored in the database, they will not match.
What you need to do is to convert the non-unicode string to unicode. Here is one of the way, simple and elegant.
str = new String(str.getBytes("ISO-8859-1"), "UTF-8");
You would need to handle the UnsupportedEncodingException, but I doubt if there is any JVM not supporting ISO-8859-1 to UTF-8 conversion.
I am not sure if the ISO-8859-1 shall be different on different servers. I tried on my development workstation which is a Windows XP + Eclipse 3.3 + Tomcat 6 + Java 1.6 and my production server which is a Linux RH + Tomcat 6 + Java 1.6. They all work very well and so far I am OK with it hard coded.
Tuesday, February 03, 2009
For-Each Loop
... type ...
}
The For-Each loop makes Java code much more beautiful and clean than before. We shall use it any time we can.
Several exceptions,
- The program needs access to the iterator in order to remove the current element. The for-each loop hides the iterator, so you cannot call remove. Therefore, the for-each loop is not usable for filtering.
- Similarly it is not usable for loops where you need to replace elements in a list or array as you traverse it.
- Finally, it is not usable for loops that must iterate over multiple collections in parallel. These shortcomings were known by the designers, who made a conscious decision to go with a clean, simple construct that would cover the great majority of cases.
Wednesday, January 28, 2009
Java First Moment of a Day
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
Java First Moment of a Month
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
Java First Moment of a Year
cal.set(Calendar.DAY_OF_YEAR, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
Java First Moment of a Week
cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
Monday, January 12, 2009
Spring, Velocity and Dropdown List
First, the key word is springFormSingleSelect. In my velocity file, I wrote
#springFormSingleSelect("command.group", ${groups}, "style='width:270px;'")
Second, use referenceData to populate values in the "groups" in the Controller class.
referenceData(...) {
Map
... add (key, value) into a Map called groups
model.put("groups", groups);
return model;
}
Third, create a custom property editor, GroupEditor extends PropertyEditorSupport and override the setAsText method.
Note the Spring Framework will pass you the groupId and you need to create a Group object from the groupId, then call setValue(group).
Fourth, register the GroupEditor in the initBinder method.
binder.registerCustomerEditor(Group.class, new GroupEditor());
You may find the groups data will disappear after onSubmit. Don't worry, there is an easy fix. Instead of return a new ModelAndView, return showForm(request, response, errors, model). You can put whatever you need into the "model".
I spent a full weekend to sort everything out. Hope it can help you.
Tuesday, December 16, 2008
Monday, December 15, 2008
Method signature and method header
Example:
- toUpperCase()
- println(String s)
The header of a method consists of the signature plus the description of (the type of) the result.
Example:
- String toUpperCase()
- void println(String s)
Two methods of the same class can have the same name, provided they have different signatures. Methods with the same name (but with different signatures) are said to be overloaded. For example, the substring() method in the class String.
Thursday, November 20, 2008
2G Memory is not enough for RSA Profile
JVMDUMP013I Processed Dump Event "systhrow", detail "java/lang/OutOfMemoryError".
Friday, November 14, 2008
RSS - Really Simple Syndication
History 1997, now RSS 2.0 in 2003. 50% sites still use RSS 0.91, 25% RSS 1.0, 12.5% 0.9x and 12.5% 2.0.
With RSS,
- you create a RSS document and save it with a xml extension
- upload the file to your website
- register it with a RSS aggregator
Java RSS programming - ROME
Render RSS on web pages - RSS2HTML
Include rss2html output in a html page - Server Side Include (xyz.shtml)
Thursday, October 23, 2008
Start Tomcat in Eclipse
Solution: Window -> Preferences -> Server -> Server timeout delay
set it to Unlimited.
Monday, October 20, 2008
Enabling PostgreSQL on Linux System Startup
To enable PostgreSQL at startup
#chkconfig --all postgresql
#chkconfig postgresql on --level 2
#chkconfig postgresql on --level 3
#chkconfig postgresql on --level 5
Thursday, October 02, 2008
RUP Notes
RUP provides the software developer with a DISCIPLINED approach to the development process.
The aim of RUP is to ensure a high-quality result that satisfies user requirements within a predictable budget and schedule. It was designed to be fully compatible with object-oriented technology and the UML. It supports component-based software development.
RUP is a configurable process. It uses use cases to drive the development activities. Use cases facilitate the development from the beginning of the development process through to testing. And they give you a means to trace the process flow through the development of the system and the delivered product.
RUP is the opposite of sequential approaches. It is an iterative and incremental approach to the software life cycle. RUP encourages continuous integration. (Note, here it is "encourage", which means you still need to implemente your own continuous integration, or also called continuous build. Since RUP as a process to focus the final executible deliverables, continuous build servics as compliment to build the deliverables automatically. Sometime the build can also include regression tests which is even better.)
RUP deals errors and flaws in the system over successive iterations, thus makes the system more robust and stable.
Coming behind RUP are requirements management and change control. RM ensures the system better meets the customer's expectations, also limits the size of the project to acceptable levels(scope). Change control helps keep track of defects, misunderstandings, and project commitments and to associate them with specific artifacts.
RUP is architecture-centric, its early iterations has a main thrust to produce and validate a software architecture.
In RUP, quality control has been incorporated into the process. This quality assessment uses objective measurements and criteria for all activities and participants in the process.
RUP has four phases and each phase has iterations. At the end of each phase, comes a milestone, which is a predefined point in time by which certain goals must be achieved and certain decisions made. During the inception phase, the original vision of the product is transformed into a project(my understanding, a well defined plan, definition of deliveriables, iterations, etc.). Formulate the vision, establish business cases and specify the project scope, make decisions on what to invest time and money on. Business cases include success criteria, risk assessment, estimation of resources, phase plan indicating the dates of milestones, prototyping.
The goal of the elaboration phase is more thorough analysis of the problem domain, to establish and define the architecture, to address and eliminate high-rish elements of the project, to determine how the work should be divided into iterations(I think it is difficult but critical. It needs strategic thinking, knowledge and experience. But it is also where the value of a good architect lies.) At the end of the elaboration phase, the decision must be made to build or not the system.
The third phase is the construction. In its final iteration the construction delivers a constructed software system.
RUP defines a transition phase, where the product is supplied to its end-users. Plan the packaging, pricing, roll out, support, training, transition strategy, production details.
It's recommended to have a "postmortem" analysis of the project, addressing how well the original and revised success criteria have been met.
There are nine core workflows in the RUP, either engineering process workflows or supporting process workflows. Business modeling, requirements capture, application/system analysis and design, implementation, testing, deployment
Thursday, September 11, 2008
JDBC ResultSet Column Name with Multiple Tables
Incorrect - a.col1, b.col2.
Correct - col1, col2.
What if same column names in both tables, like a.col3 and b.col3?
Write SQL like "select a.col3 as acol3, b.col3 as bcol3 ...", then name the column in getXXX method as acol3 and bcol3.
Thursday, August 28, 2008
Customize 401 Error Page with HTTP Basic Authentication
After adding an error-page element in web.xml to customize 401 error page, HTTP auth will not work.
So far with Tomcat 6.0, I have found no way to make them work.
Monday, August 25, 2008
Tomcat DataSourceRealm
userTable="schema1.users" works and the schema name should be lower case too in the database.
Schema1 or SCHEMA1 won't work.
Wednesday, August 06, 2008
External JACC Provider in WebSphere 6.1
- Internal accepts "welcome.do" but external TAM provider doesn't, it accepts "/welcome.do"
- I switched from Default to External but failed to switch it back. Even from the admin console it looked fine, but the server kept using TAM as authorization provider. What I had to do was to reinstall RSA.
Friday, August 01, 2008
TAM Error AWXJC0050E
com.tivoli.pd.as.jacc.cfg.TAMConfigException: AWXJC0048E An error occurred during the configuration. The details are:
com.tivoli.pd.as.jacc.cfg.ConfigActionFailedException: AWXJC0050E The Tivoli Access Manager user, sec_master, failed to add the Tivoli Access Manager user, JACC_-264539269/cledt-123691.agna.amgreetings.com, to the Tivoli
Access Manager group, iv-admin. The details are: Wrappered Exception:java.net.BindException: Address already in use:
NET_Bind[HPDCO1050E Socket could not be created (8920).].. at
com.tivoli.pd.as.jacc.cfg.TAMConfigController.execute(TAMConfigController.java:156)
For this error, note the port 8920 in the message, then change the client listener port from default 8900:8999 to 8921:8999.
Have a $ in your password?
What you need to enter is "abc$$$$cba".
Wednesday, May 14, 2008
Struts InvalidCancelException
2.1. Bug 38374 - Validation always skipped with Globals.CANCEL_KEY
2.1.1. Issue: Cancel Processing
The Struts <html:cancel> tag sets a request parameter (org.apache.struts.taglib.html.Constants.CANCEL) which causes validation to be skipped.
Spoofing this request parameter however, could be used maliciously in order to circumvent an applications validation and proceed with the request processing with erroneous and potentially damaging data.
See
Bug 38374 for full details.
2.1.2. Resolution: Cancellable Property
A new cancellable property has been introduced which indicates whether an action is allowed to be cancelled or not. In Struts 1.2.9 this is set to true or false for an action in the struts-config.xml using the <set-property> notation. From Struts 1.3.x a new cancellable attribute has been added to the <action> element.
Now any action where the cancellable property is not set to true will throw an InvalidCancelException.
2.1.3. Upgrade Implications
Any existing applications that use the Cancel processing will need to modify their struts-config.xml to set the cancellable property for actions which require it.
In Struts 1.2.9 the <set-property> is used to set the cancellable property for an action....
<action path="/fooAction"
input="/foo.jsp"
validate="true">
<set-property property="cancellable" value="true"/>
<forward name="success" path="/bar.jsp"/>
</action>
From Struts 1.3.x a new cancellable attribute can be used....
<action path="/fooAction"
input="/foo.jsp"
validate="true"
cancellable="true">
<forward name="success" path="/bar.jsp"/>
</action>
In both Struts 1.2.9 and Struts 1.3.x an exception handler can be configured to handle the InvalidCancelException
<action path="/fooAction"
input="/foo.jsp"
validate="true"
cancellable="true">
<forward name="success" path="/bar.jsp"/>
<exception key="errors.cancel"
type="org.apache.struts.action.InvalidCancelException"
path="/foo.jsp"/>
</action>
2.1.4. Test Cases
This bug was tested using the struts-examples webapp (see struts-examples.war in the binary distribution). If you fire up the examples webapp, select the Taglib Test Pages link, then select the <html:cancel> link you will be presented with a page where you can try the Cancel button for four different configurations.
Tuesday, April 29, 2008
Cancel Button for CancellableFormController
where by default "_cancel" is the cancelParamKey. You can use setCancelParamKey() to override it.
Thursday, April 24, 2008
Form Validation Error Message
When the date input doesn't match the specified format, it will report an error message. The message is very much in Java developer's language, not user oriented.
To replace the message with your own, just put a line like that in your messages.properties,
typeMismatch=Invalid or incomplete input.
Spring Framework - Date Field in a SimpleFormController
- Override the initBinder method.
- Create a SimpleDateFormat, e.g. MM/dd/yyyy HH:mm:ss where M is month, d is day, y is year, H is hour(0-23), m is minute, and s is second.
- Set the date format lenient false, which means inputs do not have to match the format exactly
- Create a CustomDateEditor(dateFormat, true), where true means empty allowed.
- Register the editor to Date.class.
Thursday, April 10, 2008
Postgresql - Generate Primary Key before Insert
Second in your program, use select nextval('schema.april_april_id_seq') to obtain the next value for primary key. You don't need to plus 1 since Postgresql does it for you. If using Spring JDBC template, just call getJdbcTemplate().queryForInt(the sql).
Third, use the value just obtained as parameter in the insert sql.
Done.
Monday, April 07, 2008
Velocity Layout in Spring
In web.xml, define org.springframework.web.servlet.DispatcherServlet as spring. Mapping *.xhtml to spring. I leave html for real html files.
In spring-servlet.xml, define
viewResolver class=org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver
- viewClass = org.springframework.web.servlet.view.velocity.VelocityLayoutView
- layoutUrl = layouts/mainlayout.vm
- cache = true
- suffix = .vm
- exposeRequestAttributes = true
- exposeSessionAttributes = true
- exposeSpringMacroHelpers = true
- dateToolAttribute = dateTool
- numberToolAttribute = numberTool
velocityConfigurer class = org.springframework.web.servlet.view.velocity.VelocityConfigurer
- resourceLoaderPath = WEB-INF/views
- velocityProperties directive.foreach.counter.name = loopCounter
- directive.foreach.counter.initial.value=0
Create a layout file, mainlayout.vm under WEB-INF/views/layouts. Put html, body, stylesheet stuff in. Note the stylesheet file shall sit outside WEB-INF. e.g. stylesheet href = "includes/main.css" means the main.css file sits at [web-root]/includes forlder.
Put $screen_content whereever you want.
In spring controller, return the ModelAndView name "dashboard", create a dashboard.vm file under WEB-INF/views.
In the dashboard.vm file, put any content in.
Monday, March 31, 2008
Books for JMS
- Paperback: 352 pages
- Publisher: IBM Press (February 25, 2004)
- Language: English
- ISBN-10: 0131468634
- ISBN-13: 978-0131468634
This book offers start-to-finish guidance for building reliable, high-performance JMS-based messaging infrastructure with IBM WebSphere technologies.
IBM expert Kareem Yusuf systematically introduces the latest versions of JMS—both 1.1 and 1.02b. Once you've thoroughly mastered JMS development on any platform, Yusuf turns to the exceptional JMS support found in IBM's WebSphere products. Using extensive code examples, he walks you step-by-step through WebSphere JMS development, configuration, deployment, and administration in several real-world scenarios.
Coverage includes:
- Roles and goals of messaging infrastructure in the enterprise
- Key JMS concepts: messaging domains, messages, and Application Server Facilities
- Defining/structuring content, choosing message types, and manipulating messages
- The JMS API, explained through detailed code examples
- Using JMS with EJB, message-driven beans, servlets, and portlets
- Working with IBM WebSphere JMS providers, administered objects, and tools
- Hands-on tutorials: EJB message exchange, integration with non-JMS applications, and SSL security
- Resource location and physical topologies for maximizing availability and efficiency
Whether you're developing enterprise messaging infrastructure, architecting it, or managing it, this bookdelivers indispensable guidance-straight from the frontlines.
HTTP Request Headers
Its only problem is the header need to applied for every request. It doesn't remember or recall.
I also tested another add-on on Firefox called Modify Headers. It only worked the very first try but failed ever after.
Neither Tamper Data nor Modify Headers works on Internet Explorer.
It is said that IBM Page Details can work on IE.
Thursday, March 27, 2008
Books for Web Services
Web Services
Developing Web Services for Web Applications: A Guided Tour for Rational Application Developer and WebSphere Application Server (Ibm Illustrated Guide Series) (Paperback)
- Paperback: 400 pages
- Publisher: Mc Press; Pap/Cdr edition (September 15, 2005)
- Language: English
- ISBN-10: 1931182213
- ISBN-13: 978-1931182218
Editorial Reviews
This book shows you how easy it is to create and use Web Services with IBM® Rational Application Developer or Web Developer, and WebSphere Application Server.
Intended for novice to intermediate Java programmers, Developing Web Services for Web Applications teaches users how to create Web Services, deploy Web Services to a server, and create client applications that use Web Services. Each chapter of the book teaches a key Web Service concept and takes you on a detailed, guided tour for creating or using a particular Web Service. Even if you’re completely new to Web Services, by the time you finish the lessons in this book, you’ll have all the skills needed to create useful Java programs with Web Services.
Using the “guided tour” approach, the book comes with practical step-by-step instructions and numerous screen captures, making it easy to follow along. While most books teach how to use either a development tool or a particular technology, Developing Web Services for Web Applications combines learning about Web Services with using Rational Developer tools. Each chapter develops a complete Web Service and/or application, with sample code and solution files provided on the accompanying CD-ROM. Also included in each chapter are additional exercises to help reinforce the concepts covered in that chapter.
By the end of the tour, you’ll be able to use Rational Developer tools to build your own Web Services, and you’ll understand why Web Services are gaining popularity as a way to provide services across the Internet.
Developing Web Services for Web Applications:
- Is perfect for all skill levels, from those taking their first steps to those looking to explore more advanced topics
- Teaches you Web Services concepts and terminology as you learn how to use the Rational Developer tools
- Shows you how to create, deploy, publish, and use Web Services
- Explores troubleshooting, using relational databases, using JavaServer Faces Web applications, adding security features, and much more
Contents:
Introduction
Chapter 1: Creating your first Web service and Web application
Chapter 2: Deploying and publishing your Web service
Chapter 3: Discovering Web services
Chapter 4: Handling Web service errors
Chapter 5: Using databases, part 1
Chapter 6: Using databases, part 2
Chapter 7: Using Web services with JavaServer Faces, part 1
Chapter 8: Using Web services with JavaServer Faces, part 2
Chapter 9: Securing Web services, part 1
Chapter 10: Securing Web services, part 2
Appendix A: Installing WebSphere Express
JMS Suggested Readings
Introductions
- Getting Started with Java Message Service (JMS)
- Basic JMS API Concepts
- Introducing the Java Message Service
- Messaging Systems and the Java Message Service (JMS)
- Get the message?
- Listen to heartbeats using JMS
- JMS Introduction
- Should you go with JMS?
- JMS in WIKI
JMS Programming
- JMS Programming Model
- JMS Programming Model (from Sun)
- JMS Programming Model (from IBM)
- Programming JMS applications using AXIS
JMS and WebSphere
Samples
Web Services Suggested Readings
Introductions
- Introduction to Web Services
- A short introduction to Web Services
- Introduction to SOAP
- Introduction to Web services architecture
- Introduction to Service Oriented Architecture (SOA)
- Why Web Services?
- Web Services Platform Elements
- Web Services Example
- Web service in WIKI
- SOAP in WIKI
- WSDL in WIKI
Java Web Services
- Java Web Services at a Glance
- Web Services - Axis
- Java and Web Services Primer
- Developing Web Services at a Glance
- J2EE 1.4 Eases Web Service Development
- Java API for XML Web Services Users Guide
- JAXB Users Guide
- Using WSDL in SOAP applications
Samples
Tutorials
Tuesday, March 18, 2008
Struts Configuration Editor in RSA 7
We solved it by doing the following,
Opened the welcome perspective, enabled web development. Went back to J2EE or Web perspective and right clicked the struts-config.xml, the Editor was listed.
Tuesday, March 04, 2008
J2C CICS COBOL
That causes problem when client sends up less than 300 records.
I solved it by editing the generated Java Binding Class and modifying the lower bound validation to use 0 instead of 300.
Tomcat Debug in Eclipse
Transport dt_socket failed to initialize, rc = 509.
JAVA version = 1.4.2_16
JAVA_HOME = <>\j2sdk1.4.2_16\bin
IDE = Eclipse 3.2
Web Server = Tomcat 5.0.28
I solved this by copying the two dll files (dt_shmem.dll, dt_socket.dll) from "<>\j2sdk1.4.2_16\jre\bin" to "<>\j2sdk1.4.2_16\bin".
Tuesday, January 08, 2008
Commons Logging and IBM WebSphere 6.1
Apache Commons Logging has a problem with WAS 6.1. Its Log4JLogger either can't be loaded or be reported not compatible with LogFactory.
The root cause is WebSphere uses commons-logging and so it's in the root classloader. In addition, WebSphere ships a commons-logging.properties with the following properties set:
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
Therefore by default the application will use JDK logging and not log4j. The solution is to ensure that the right classloader mode is set and the application has an appropriate commons-logging.properties:
Set application classloader mode as PARENT_LAST. Also, add a commons-logging.properties to the application classpath with the following entries:
priority=1
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
The priority flag was introduced in Commons Logging 1.1 to allow an ordering based on priority. To ensure that an application's commons-logging.properties will take precedence over WebSphere's file, a priority of greater that 0.0 must be set.
Wednesday, January 02, 2008
This project needs to migrate WTP metadata
1) The runtime the old code is still pointing to is WAS 6.0 not WAS 6.1 (in RAD7)
2) RAD7 has more options to change more settings
The Solution: I had to fix the problem on the WAR file that is used by the EAR file Following is my fix for the problem in RAD7 PART I with the WAR PROJECT
\---------------------------
1) Right click on the war project and click on properties.
2) Click on Targeted Runtimes in the properties
3) Now check your desired Runtime WebSphere Application Server 6.1
4) Now click on the WebSphere Application Server 6.1 Runtime in the same window
5) You will see under Runtime Composition com.ibm.ws.ast.st.runtime.61 JRE 5.0: WebSphere v61 JRE
6) Now click on Add/Remove Project Facets link in the same window
7) It opens a new windows Project Facets. This page has dependencies when checking the boxes. Therefore...
8) Here First check Java, I selected the version 5.0.
9) Then check Dynamic Web Module (as I am using web module), I selected 2.4
10) Then check WebSphere Web (coexistence) 6.1
11) Then check WebSphere Web (Extended) 6.1
12) Click Finish
13) Click OK in the properties window
14) Now again open the same properties window
15) You will see new types on the Left Hand Side(LHS) windows namely J2EE Module Dependencies.
16) Click J2EE Module Dependencies. Select from the drop down the EAR file name that should have this WAR file
17) Click Java Build Path on the LHS window.
18) Make sure you see WebSphere Application Server v6.1 under your libraries tab on the Right Hand Side(RHS) window.
19) Click on Project Facets and make sure you see the 4 facets namely Dynamic Web Module, Java, WebSphere Web (Co-existence) and WebSphere Web (Extended) listed with the correct values.
20) Click on the Server on the LHS window.
21) Make sure you see the WebSphere Application Server v6.1 selected on the RHS window. If not, select it.
22) Click on Targeted Runtimes. Mostly you should see this time only WebSphere Application Server v6.1
23) Click OK
24) Manually Refresh and Rebuild this project.
PART II with the EAR project
\----------------------------
1) Right click on the EAR project and click properties
2) Click J2EE module dependencies.
3) Make sure desired xxxxxx.war file is checked.
4) Click on Targeted Runtimes.
5) Make sure you have WebSphere Application server 6.1 is checked
6) Click on project Facets
7) Make sure you have EAR 1.4, WebSphere Web (coexistence) 6.1, WebSphere Web (Extended) 6.1 are selected. If not, go to step 5 and click on the add/remove proejct facets link to do it.
8) click on server and check WebSphere Application Server v6.1
9) Manually Refresh and Rebuild this project.
You should be all set. All the best.
Friday, December 21, 2007
IBM HATS in Passport Advantage
Rational Software/IBM WebSphere Host Integration Solution (HIS) for ... v 7.0/
IBM WebSphere Host Access Transformation Services (HATS) Standard v7.0 ... (C97NZML)
IBM WebSphere Host Access Transformation Services Run-Time Web Enablement ... (C97P2ML)
It's so hard to find anything in IBM Passport Advantage.
Tuesday, December 11, 2007
CICS ECI Resource Adapter - execute timeout
0 - No timeout, this is the default value.
any positive int value - in milliseconds
How to Add a VM Argument to WAS 6.1
Open the Administrative Console. Navigate through server -> process definition -> Java Virtual Machine -> Customer Variables.
Done.
Monday, November 26, 2007
J2C CICS ECI - Generate Simple JSP
Enter /minzyWeb as the Web project, ou as the JSP folder.
Show Advanced, if the Resource Reference is missing, enter eisOrderUpdateRef.
Click on Finish.
Notice 4 jsp files were created under WebContent\ou.
J2C CICS ECI - Generate Web Service
Enter \minzyConnect\src\tliu\minzy\eis\ou\OrderUpdateJ2CImpl.java as the J2C bean implementation. Click on "Next >".
Select "Web Service" and click on "Next >".
Browse and select /minzyWeb, show advanced and enter eisOrderUpdateRef as the resource reference, keep JNDI lookup name as eis/OrderUpdate as proposed.
Click on Finish.
Notice minzyWeb was changed to have a reference to minzyConnect, 10 classes generated under tliu.minzy.eis.ou, OrderUpdateJ2CImpl.wsdl generated under WEB-INF/wsdl and webservices.xml, etc under WEB-INF.
Note, do not remove the "gen" folder. It is the generated folder for the 10 new classes.
J2C CICS ECI - Generate J2C Bean Classes
Select ECIResourceAdapter (IBM 6.0.2.1) under J2C 1.5. (CTG 6.1 needs this match up)
Give eis/OrderUpdate as JNDI name.
Click on "New...", select WAS v6.1 as server.
Enter tcp://10.104.252.233 as Connection URL. (For remote, tcp://, for WAS and CTG on same server, local:), AMGCOHA3 as server, 32006 as the port number, user and password etc.. (configurations here shall be obtained from CTG admin)
After that, enter minzyConnect as project, tliu.minzy.eis.ou as package, OrderUpdateJ2C as interface, the implementation class will automatically be given as OrderUpdateJ2CImpl.
At next step, click on Add... to add a method.
Give updateOrder as the method name.
Click on Browse... and select OrderUpdateBind as input type and check on Use the input type for output.
If execute time out is a required argument, enable the Show Advanced and expand Interaction Spec to select executeTimeout - int.
Click on Finish and enter DIC44010 as the Function name.
Click on Finish and generate the J2C Java bean.
Notice the OrderUpdateJ2C and OrderUpdateJ2CImpl were created under tliu.minzy.eis.ou, cicseci6021 i was created and minzyConnect was updated to have cicseci6021 in its build path.
Wednesday, November 21, 2007
J2C CICS ECI - Generate J2C Data Binding Classes
Choose mapping COBOL to Java.
Select z/OS for Platform, IBM-037 for Code page. Click on Query.
Select the DFHCOMMAREA which is the CICS common area.
Select "Shorten names" as Generation Style, minzyConnect as project, tliu.minzy.eis.ou as package, OrderUpdateBind as class.
Class OrderUpdateBind, OrderUpdateBind_DFH_PAL_ID_DATA_DFH_EPC_DATA and OrderUpdateBind_DFH_PAL_ID_DATA will be created under tliu.minzy.eis.ou.
J2C CICS ECI - Obtain COBOL Copybook
The copybook looks like this,
01 DFHCOMMAREA.Do not edit the file.
02 DFH-INPUT-FIELDS.
05 DFH-MRG-NBR PIC 9(07) VALUE ZEROS.
05 DFH-DC-NBR-FILLING PIC X(02) VALUE SPACES.
05 DFH-SESSION-CNT PIC 9(02) VALUE ZEROS.
05 DFH-PAL-ID-DATA OCCURS 5 TIMES.
10 DFH-PAL-ID-NBR PIC 9(03) VALUE ZEROS.
10 DFH-PAL-EPC-NBR PIC 9(09) VALUE ZEROS.
10 DFH-EPC-DATA OCCURS 300 TIMES.
15 DFH-EPC-NBR PIC 9(12) VALUE ZEROS.
02 DFH-STATUS-FIELDS.
05 DFH-RETURN-CODE PIC 99 VALUE ZEROS.
05 DFH-RETURN-TEXT PIC X(80) VALUE SPACES.
05 DFH-PROGRAM-NAME PIC X(08) VALUE SPACES.
05 DFH-ERROR-STATUS PIC X(04) VALUE SPACES.
05 DFH-ERROR-RECORD PIC X(16) VALUE SPACES.
05 DFH-ERROR-SET PIC X(16) VALUE SPACES.
05 DFH-ERROR-AREA PIC X(16) VALUE SPACES.
05 DFH-DML-SEQUENCE PIC 9(08) VALUE ZEROS.
I created a eis folder under minzyConnect. I put DIC44010.cpy under the newly created eis folder.
J2C CICS ECI - Review the Environment
- IBM Rational Software Architect (RSA) v 7.0.0.3
- IBM WebSphere Application Server (WAS) v 6.1, embedded in RSA 7
- IBM CICS Transaction Gateway (CTG) v 6.1
Note, if WAS and CTG sit at the same server, CTG connection URL shall be local:.
Project minzyConnect is created to hold the data binding and J2C beans.
Project minzy is created as EAR holder, and its module project minzyWeb, minzyEnt (for EJB), and minzyClient are also created.
Tuesday, November 20, 2007
CICS Transaction Gateway
Friday, November 16, 2007
Informatica Upgrade to 8.1.1 - Client
- Open the Hub's home page, e.g. http://host:7333/wsh/
- Click on the "Batch Web Services"
- Click on the WSDL icon under Metadata WSDL
- Right click on the pop-up page and select "View Source"
- Save the content as MetaData.wsdl
- Do the same for DataIntegration WSDL, save as DataIntegration.wsdl
- Import these two files to a RSA project
- Add axis-1.4.jar to the project
- Create a Java Application Run,
- Set main class as org.apache.axis.wsdl.WSDL2Java
- Check "Include libraries when searching for a main class" on
- Select Arguments tab
- Enter "--NStoPkg http://www.informatica.com/wsh=com.informatica.www -W informatica-8.1.1/MetaData.wsdl" as Program arguments, where the informatica-8.1.1 is the folder of MetaData.wsdl file
- Run this Java Application
- Informatica client code for MetaData service will be generated
- Do the same for DataIntegration service
- There are some changes from version 7, especially of the connection, workflow and folder
- Modify the client application accordingly
CICS ECI Resource Adapter
- ECIResourceAdapter (IBM : 5.1): This version of the CICS ECI resource adapter is based on Version 1.0 of the J2EE Connector Architecture (JCA 1.0). Because CICS ECI resource adapter for Java verion 5.1 is a JCA 1.0 resource adapter, it will only run in a JCA 1.0 application server or WAS version 5.0.2 (or above). Select CICS 5.1 resource adapter if targeting a WAS v 5.0 server.
- ECIResourceAdapter (IBM : 6.0.2): This version of the CICS ECI resource adapter is based on version 1.5 of the JCA (JCA 1.5). It runs on WAS 6.0.
- ECIResourceAdapter (IBM : 7.0.0): This version based on JCA 1.5. It runs on WAS 6.1.
If you select Configure Resource Adapter Deployment on the Deployment Information page of the J2C wizard, you can use the Resource Adapter Deployment page to configure RAR.
The resource adapter can be deployed as a standalone resource adapter or as part of an EAR file. Typical environments use the standalone method, giving all modules on the application server visibility to the adapter.
Note: Multiple resource adapters should not be installed as standalone on the same runtime server, especially if they are for the same EIS type (for example, CICS ECI 5.1 and CICS ECI 6.2). This is because all standalone resource adapters share the same class loader.
My note: It's probably easier for application maintanence to deploy the adapter per EAR file.
Wednesday, October 31, 2007
Axis 1.1 and 1.2
In Axis 1.2, that class has been replaced by org.apache.axis.constants.Style. When clients try to make connections to web services, it will get an error that enum.Style cannot be found.
I think it will solve the problem to regenerate the stub classes with Axis WSDL2Java emitter from the WSDL definition files. We will see the result after several days.
Monday, October 22, 2007
DelegetingActionProxy
For example, class SpringIndexAction extends Action and declares a setter for the productionManager property. We add an action declaration to the Struts configuration file struts-config.xml.
[action path="/sindex"
type="org.springframework.web.struts.DelegatingActionProxy"
validate="false"]
[forward name="success"
path=".index"/]
[/action]
Notice the action type is set to DelegatingActionProxy, which is a Spring class that delegates all calls to the real bean of the SpringIndexAction class.
Before we can use DelegatingActionProxy, we first need to add the ContextLoaderPlugin bean to the Struts configuration file.
[plug-in
className="org.springframework.web.struts.ContextLoaderPlugin"]
[set-property property="contextConfigLocation"
value="/WEB-INF/actionContext.xml"/]
[/plug-in]
We declare the SpringIndexAction in the actionContext.xml file.
[beans]
[bean name="/sindex" class="com.....actions.SpringIndexAction"]
[property name="productManager"][ref
bean="productManager"/][/property]
[/bean]
[/beans]
When we now make a request to the /sindex.do URL, DelegatingActionProxy looks up the bean with its name set to /sindex. It uses the beans defined in the WebApplicationContext that is loaded by the ContextLoaderPlugin declared in the file specified in its contextConfiguration property. The /sindex bean is the actual SpringIndexAction, it is instantiated, and its productManager property is set.
The difference after using DelegetingActionProxy is that the SpringIndexAction is a fully Spring-managed bean and we have no manual dependency lookup code in the Action.
Monday, October 15, 2007
Form-based Authentication in WAS
One of the login challenges defined in J2EE Specification is form-based login. It enables the application developer to customize the login process and present an application-specific form by making use of the Form Login Authentication Method.
Form login works in the following manner:
1. An unauthenticated user requests a resource protected by the Form Login authentication type.
2. The application server redirects the request to the Login Form defined previously in the Web deployment descriptor.
3. On the HTML login form, the user enters the user ID and password and submits the form.
4. The action triggered by the form submission runs a special WebSphere Application servlet j_security_check. The Web container, after receiving a request for the j_security_check servlet, dispatches the request to another WebSphere servlet that authenticates the user.
5. If the servlet authenticates the user successfully, the originally requested resource is displayed.
Form login configuration using WebSphere Studio
1. Open the web.xml file under the Web project. A Web Deployment Descriptor should be opened in a deployment descriptor editor window.
2. Select the Pages tab, then modify the Login section.
3. Type in the realm name, for example: SecureRealm.
4. Click the drop-down list and select FORM as the Authentication method.
5. In the Login page, click Browse and select your login page from the project, for example: /login/login.html.
6. In the Error page, click Browse and select your login page from the project, for example: /login/loginerror.html (we have used the same page for login and error, but you can define a custom error.jsp page that will present actual error code and error messages).
7. Save and close the Web deployment descriptor file.
Setting the Authentication Method for the application Web module will create a [login-config] section in a Web deployment descriptor XML file, as shown in the following example.
[login-config]
[auth-method]FORM[/auth-method]
[realm-name]SecureRealm[/realm-name]
[form-login-config]
[form-login-page]/login/login.html[/form-login-page]
[form-error-page]/login/loginerror.html[/form-error-page]
[/form-login-config]
[/login-config]
Simple form-based login does not require any extra code development on the server side. The j_security_check servlet used by WebSphere Application Server enforces only the name of the input fields that the developer should put in the custom Login Form. These fields are as follows:
* j_username should be the input field in which a user will type the user ID.
* j_password should be the input field into which the user will type the password.
The action required for the HTTP POST method is j_security_check. A simple HTML code for the custom Login Form is given in the following example:
[!-- ............... --]
[form method="post" action="/itsobank/j_security_check"]
[table width="80%"]
[tr]
[td width="20%" align="right"]Userid:[/td]
[td][input size="20" type="text" name="j_username" maxlength="25"][/td]
[/tr]
[tr]
[td align="right"]Password:[/td]
[td][input size="20" type="password" name="j_password" maxlength="25"][/td]
[/tr]
[tr]
[td][/td]
[td][input type="submit" name="action" value="Login"] [input type="reset" name="reset" value="Clear"][/td]
[/tr]
[/table]
[/form]
[!-- ............... --]
Form-based logout
One of the IBM’s extensions to the J2EE Specification is the form-based logout. After logging out, the user is required to re-authenticate to have access to protected resources again. This logout form can be on any page with calling a POST action on the ibm_security_logout servlet. This form must exist within the same Web application to which the user gets redirected after logging out.
[form method="post" action="ibm_security_logout" name="logout"]
[input type="submit" name="logout" value="Logout"]
[input type="hidden" name="logoutExitPage" value="/login/login.html"]
[/form]
A Real Case with WAS Security
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.
Friday, October 12, 2007
LDAP Browser in Eclipse
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
- 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
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
- 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
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
[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
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
Monday, September 17, 2007
Tuesday, September 11, 2007
Hibernate and Struts - Identifier Altered
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
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
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
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
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中键入中文
默认的输入法是二笔,我不会,改成了智能拼音就好了。和用惯了的全拼有些区别,用用也就习惯了。
简体中文中好多系统菜单翻译得莫名其妙,试了试,不知道怎么切回英文。
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?
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
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
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.
Wednesday, July 25, 2007
WAS 6.1 in RSA 7.0
In WAS 6.1, RMI ORB bootstrap port is defined 2810. Modify it to 7810.
Start WAS 6.1, still complain on port 2810. Restart RAS 7.0.
Profile name "AppSrv01", server name "server1".
From its log, it started. but in the RSA console, it still says starting. Also the publish failed and complained not started.
Even after 30 minutes, it still says starting. So I stopped it.
Restarted the workstation. Found port 2810 gone. Modify WAS 6.1 port back to 2810. Restart RSA.
Start WAS 6.1 and started.
Sunday, June 10, 2007
Fodero Core 5 Package Updater
I then opened a terminal window and run "yum update". It reported the error at Macromedia update. After some research, I was suggested replacing the /etc/yum.repos.d/macromedia-mplug.repo with the following content.
[macromedia]
name=Macromedia for i386 Linux
#baseurl=http://macromedia.rediris.es/rpm/
baseurl=http://sluglug.ucsc.edu/macromedia/rpm/
enabled=1
gpgcheck=1
#gpgkey=http://macromedia.mplug.org/FEDORA-GPG-KEY
gpgkey=http://sluglug.ucsc.edu/macromedia/FEDORA-GPG-KEY
After that, the Package Update came back to normal.
Thursday, May 31, 2007
Unique ID Generation
- Unique to the System.currentTimeMillis()
- Unique to the IP address
- Unique to the object instance System.identityHashCode(this)
- Unique within a millisecond, SecureRandom
A open source named Java UUID Generator is available at http://jug.safehaus.org/.
Business Delegate and Session Facade
ONE to ONE. Often, the business delegate will have the same API as the session facade.
There is a close relationship between the BD and the SF. The client layer interacts with a BD. The BD would in turn, employ the Service Locator pattern to locate the SF. It is common to see a one-to-one mapping between the BD and the SF.
Monday, May 28, 2007
Testing Glossary
- Black-box testing - testing that verifies that given input A the component or system being tested gives you expected results B.
- Boundary-value testing - testing of unusual or extreme situations that your code should be able to handle.
- Function testing - a part of system testing in which development staff confirm that their application meets the specified user requirements.
- Integration testing - testing that verifies that several portions of software work together.
- Regression testing - testing that ensures previously tested behaviors still work as expected after changes have been made to an application.
- Stress testing - testing that ensures the system performs as expected under a high volume of transactions, high number of users, and so on. Also referred to as load testing.
- White-box testing - testing that verifies specific line of code work as defined. Also referred to as clear-box testing.
- Alpha testing - a testing period in which pre-release versions of software products are released to users who need access to the product before it it officially deployed. In return, these users will report any defects to the software developers. Alpha testing is typically followed by beta testing.
- Beta testing - a similar process to alpha testing, except the software product should be less buggy.
- Code inspection - a form of technical review in which the deliverable being reviewed is source code.
- Peer view - a style of technical review in which a project artifact, or portion thereof, is inspected by a small group of experts.
- Use-case scenario testing - a testing process in which users work through use cases with the aid of a facilitator to verify that a user interface prototype fulfills the needs of its users and that the identified classes for a system fulfill the requirements described in the use cases.
- User testing - testing processes in which the user community, as opposed to developers, performs the tests.
- User-interface testing - the testing of the user interface to ensure that it follows accepted standards and meets its requirements. User-interface testing is often referred to as graphical user interface (GUI) testing.
Friday, May 25, 2007
Session Data in Multiframed JSPs
JSPs will, be default, create an HttpSession if it does not already exist. A developer can use <% @page session="false" %> to turn off the automatic session creation from the JSP files that will not access the session. Then if the page needs access to the session information, the developer can use <% HttpSession session = HttpServletRequest.getSession(false); %> to get the already existing session that was created by the original session creating JSP file. This action helps prevent breaking session affinity on the initial loading of the frame pages.
Web Application Session Data
- When developing new objects to be stored in the HTTP session, they should implement Serializable to ensure that they can be persisted into a database or send via the message server if clustered sessions are enabled by the system administrator.
- Maximize use of session affinity and avoid breaking affinity. Session affinity is enabled by default in WebSphere Application Server. It ensures that, except for hardware or software fail-over, requests are handled by the container which initialized that session. Session clustering may be used in addition to affinity to handle fail-over.
- Release HttpSessions when done, call HttpSession.invalidate(). Otherwise the session objects remain in memory until the session timeout expires.
- It does not make sense to protect access to session state only part of the time.
- Distributed HttpSession support does not guarantee transactional integrity of an attribute in a failover scenario or when session affinity is broken.
Tuesday, May 22, 2007
Syntactic and Semantic
- Syntactic -- this involves checking for the format of a field, e.g. number of characters, alpha or numeric, membership in a list, and so forth. This needs to be repeated on the server because of the issues with JavaScript being turned off, loss of synchronization between the two languages in a project.
- Semantic -- this requires domain (business) logic to perform, e.g. comparing postal code with city, and so forth.