Thursday, December 24, 2009

Windows logs off immediately after logging in

After upgrading the hard disk on my laptop to a bigger capacity, I ran into an issue where Windows logged me off immediately after logging in. After reading a number of posts online and a couple of attempts in vain, finally found the one that explained the origin of the issue.

Here is the link.
http://www.troublefixers.com/windows-logs-off-automatically-while-login/
"Guti" response on Sep 7th, 2009 is on the mark.

http://support.microsoft.com/kb/223188 - Problem as stated from Microsoft Support

The question thereafter is how do you fix the registry key when the system does not let you log in. There are a number of articles that state how to access the registry remotely and you try this and that and the clock goes by without making any progress due to any one of the following.
  • your system may not be on the network

  • you may have turned off "Remote Registry" service from starting up.

  • cannot seem to get remote registry access working

  • in my case, the laptop was not even "pingable".

Here is what I did to fix that and mine is Windows XP.
  • put the old drive (smaller) back in my laptop and booted it up.

  • put the new and bigger hard disk back in the USB enclosure and connected t to the laptop.

  • located the registry file :\windows\system32\config\system.

  • used a binary file editor such as "TextPad" to open this file.

  • moved all references such as \DosDevices\C: to \DosDevices\X: (Pick an unused drive etter as appropriate for your laptop). There may be more than one occurrence of this string in the file and you need to replace all of them.

  • moved all references such as \DosDevices\E: to \DosDevices\C: (E was the drive letter assigned when the bigger hard disk enclosure was connected the first time).

  • saved the file and then replaced the old hard drive with new hard drive.

  • voila!

Ensuring only one active BPEL instance for a unique transaction

We noticed some users managed to submit a form more than once that led to the starting of two or more BPEL process instance of the same kind for some long running transactions.

Though any subsequent messages meant for this process were handled and processed by the process manager, it led to data inconsistency issues because of two active processes for the same transaction id.

We went down the familiar path of preventing a user from creating such a condition and it was getting harder and harder to fix it. So we decided to approach it from the process side and this is what we did to enable only one active process instance for a given transaction (correlation id).

- added a new message and an operation namely "ignore"
- implemented an event handler for "ignore" on the process's main scope. This handler did not to do anything other than sinking the message.
- set up correlation on this event handler to match the correlation id of the transaction.
- removed the message and operation from the WSDL for ignore before distributing it to the client to avoid any confusion.

This worked because any attempt to start a new process due to duplicate submissions
fails due to a conflicting receive condition created by the event handler for the main scope. This may dump quite a bit of exceptions in the logs, but it helped!

Saturday, October 17, 2009

OCFS Cluster(block) size and performance

You may know that 1024(1MB) is the recommended OCFS cluster
size for data files while 4(4K) for program files. But OCFS
with 1024(1MB) cluster size seems to lead to performance issues
when it has directories with a large number of big files.
The file system, used to hold archive logs and export dumps,
showed gradual degradation as more and more files were
created/moved in, and at some point in time Windows explorer
failed to show the contents of a directory leading to server
reboot - noticed in a Windows 2003 - 64 bit environment.

Reformatting the drive with 4K cluster size seems to fix the issue.
So consider the number of many files that are going to be in the
drive, how often they are going to be accessed(I/O performance)
and how huge they are going to be over time before selecting a
cluster size not just based on whether it is going to have data
files or program files.

Size and determining factors

  • 4K - A huge number of files in the file system irrespective
    of the size such as program files, exports, archive logs etc.

  • 1024K - A few, but large files such as data files that need a
    lot of caching to improve I/O performance.

Unix: sleep <seconds> && command - equivalent in Windows

If your system has Windows Server resource tool kit, then the above construct should work fine as it has "sleep" command. If not, the following comes very close with a few hassles and gotchas.

Short Version: choice /T secs /D Y command
Long Version: choice /N /T secs /D Y >NUL command

    - Requires a number of key strokes.
    - You need to have or install choice.exe to be availabe in your path.
    - Notice that '||' is used instead of '&&'. Pipe-pipe is required if you wish to hit "Ctrl-C" to abort both choice and command together. If you used "&&" and hit "Ctrl-C", your command will still execute because choice returns a 0(zero - true) upon encountering "Ctrl-C".

Wednesday, April 22, 2009

Generating total in Excel using R1C1 References

If you have to import CSV or RPT(SQL Server) files into Excel and then manipulate it to generate a report, you can have these formulae (R1C1 Style) in your scratch pad, and cut and paste them into appropriate cells without even thinking about editing them.

You may have to turn on support for R1C1 addressing in MS-Excel by checking off
Tools -> Options -> General (tab) -> R1C1 Reference style.

Here is the formula that I used to sum up all the values in a given column from the
top to the cell just above the total.

"=SUM(R1C:R[-1]C)" - note that no numeric value follows C to address current column.

Thursday, April 16, 2009

Top down Web Service Re-generation using JDeveloper

You may have noticed (or got burnt!) that JDeveloper overwrites your server side Java implementation class with a skeleton whenever you have to re-generate a web service due to changes to WSDL or Schemas?

Here is a way around this issue.

Your application server container will find your implementation class, if you do the following.

  • Write your own service implementation class with appropriate operations and make it extend JDeveloper generated server skeleton class.
  • Locate element <servlet> in /public_html/WEB-INF/web.xml
  • Modify <servlet>/<servlet-class>element to refer to your class (package.classname) instead of JDeveloper generated class.

Wednesday, April 15, 2009

Mapping a Java Object to two tables using Hibernate - Possible?

One can hibernate one or more than one object to a single table in a database.
Is it possible for an object to be mapped to two different tables? The answer is , No. But the desired effect can be achieved with a minimal effort by taking advantage of Hibernate's support for inheritance hierarchy as follows.

One may wonder where is the need for this kind of behavior.

When an object is persisted in a table that is a queue table or used like a scratch pad (a reader process may delete a record from this table after consuming it), there may be a need to capture the persisted object in a secondary table for logging, auditing or reconciliation purposes.

Here are the steps ...

1. Create a new POJO(say com.mycom.hb.module.SecondaryObject) and make it extend your base Hibernate POJO(say PrimaryObject) that is already hibernated. This object should look simple because the secondary table is exactly same as the primary table.
(It is not a big issue if the secondary table includes more fields. Just implement
the setters and getters for the additional fields if necessary.)

2. Externalize all the property mappings from primary.hbm.xml in a standalone file namely props.xml. This goes a long way and saves a lot of work for secondary table mapping.

3. Use entity reference declaration as shown in hibernate documentation to include property mappings for primary.hbm.xml from props.xml, defined in Step 2. (Chapter 9.1.6 - Table per concrete class, using implicit polymorphism - This is NOT the mapping approach we will take, but used as the reference for entity declaration and references.)

4. Map newly created POJO in secondary.hbm.xml and use entity references to pull in properties from props.xml. The mapping strategy for this approach is going to be "Table per subclass" and the mapping file for the secondary.hbm.xml may look like the following. Remember that making secondary object extend primary object in Java class definition is not just enough. It need to be specified in the joined-subclass definition as follows to get this working.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
[<!ENTITY myprops SYSTEM "com/mycom/hb/module/props.xml">]>
<hibernate-mapping>
<joined-subclass
name="com.mycom.hb.module.SecondaryObject"
table="SECONDARY_TABLE"
schema="app_schema"
extends="com.mycom.hb.module.PrimaryObject">
<key column="REC_NO" /><!-- primary key -->
&myprops;
</joined-subclass>
</hibernate-mapping>



5. Include secondary.hbm.xml in your hibernate_configuration.cfg.xml

6. Build and populate SecondaryObject and persist them from your data access classes. After persisting SecondaryObject, you could find data actually persisted in both PRIMARY_TABLE and also a copy of it in SECONDARY_TABLE.

Thursday, April 2, 2009

Distinguishing numbers from strings in a String(varchar) coulmn.

Have you ever come across a need to filter out numbers(or number like) that are stored in a column along with string values?

e.g. Let us say myTable.myColumn of type varchar(50) has the following values.
    EA-234
    1234567
    CT/234
    9876543
    10203040
    AB/04/02/09


and you want to select only the rows that have "1234567, 9876543 and 10203040".
The following query is very consise and efficient than building a "like" search for all allowed prefixes.

select * from myTable
where myColumn between '0' and 'A'
and myColumn not like 'A%'


Remember that the ranges are inclusive in a "between" clause, so you may have to eliminate all the values begining with "A". One may be able to use a different filter such as "and len(myColumn) = 7" or rewrite the where clause as
myColumn >= '0' and < 'A' to achieve it instead of "not like" depending on actual data.

Note: It may noted that "9" cannot be used in the above query instead of "A" because the filter will not include values such as "99" or "921" etc.