Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Kelly Dolan

Ranch Hand
+ Follow
since Jan 08, 2002
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kelly Dolan


Specifically TransactionSynchronizationRegistry does not work in our case because it was introduced with JTA 1.1 and JBoss 4.0.1sp1 seems to only support JTA 1.0.1. However, JTA 1.0.1 supports the Synchronization interface and the Transaction interface defines a registerSynchronization() API.

I was able to create a class that implements Synchronization and registers it with the current transaction.

6 years ago
I have a situation in which something needs to occur before a transaction is committed, but I cannot invoke this everywhere tx.commit() eventually gets called. Is there a way to configure a listener within JBoss such that it is notified before a transaction is committed (or at least before tx.commit() actually does the commit)?

Our application is using JBoss 4.0.1sp1.

6 years ago
Sorry, ut is a javax.transaction.UserTransaction. The DB connections are obtained and used properly (e.g., closed in finally block) in the // do stuff logic. The DB connection commit and rollback methods are not called by our code directly. Rather they are invoked by the transaction on its commit/rollback.
I respectfully thank you for your response. I do not necessary disagree w/ your feedback but that is not the subject of this post. My post is trying to get at what occurs given the code snippet as it is.
I agree the described scenarios will rarely occur but we're encountering a bug that is being elusive, someone noticed this code and now there are some saying this may be problem. While it may be true, it has not yet been proven and I'm trying to avoid premature and improper code changes made based on theory.

I left out a lot of detail ...
(a) the db connection auto-commit is set to false
(b) the catch block does not necessarily catch all possible exceptions (checked, unchecked or errors); note: the IDE will not complain about checked exceptions if the method declares them in its signature

So my questions remain...I'm still looking to understand what occurs if ut.rollback is not called in the 2 different scenarios.


In code I came across, I see pretty standard stuff:

I have 2 questions:

1) Scenario 1:
* on call of the local method, create ut as a local method variable
* ut.begin()
* an exception is thrown either by the do lots of stuff or commit line
* the exception is not caught and therefore rollback is not called
* ut goes out of scope and is destroyed

What is the state of the database? Since the changes were not committed or were not successfully committed, does the database reflect the state before all changes were made? Or is the database in an unstable state?

2) Scenario 2 (note: assume only one thread):
* ut is a data member and created in the constructor
* on call of the local method, ut.begin() is called
* an exception is thrown either by the do lots of stuff or commit line
* the exception is not caught and therefore rollback is not called
* on call of the local method again, ut.begin() is called
* etc.

What is the state of the database? In this case, we may have ut.begin(), do stuff fails, ut.begin() or ut.begin(), do stuff, ut.commit()-fails, ut.begin() if the catch block is not executed.

Obviously, the code needs improved but I'd like to understand the impact so that we make the correct changes (e.g., catch Exception vs. catch Throwable vs. rollback in finally block). There is much debate over the choices but that is not what I intend for this post. Also, if there is a better forum for this post, please feel free to move.

Hi all! First let me say I'm embarrassed that I even need to ask this question as I thought I should have found a solution by now.

We have many Struts actions ( all in the same package and our struts.xml file uses one <action> w/ a wildcard to handle all of the mappings (see below). We want to re-organize our Struts actions into subpackages and thought we'd have one <action> per subpackage. For the life of me, we cannot get this to work. Below is our current configuration followed by some changes we attempted based on the documentation and posts I ran into. I appreciate all help.


The struts.xml file:

Our JavaScript code used to call the actions looks like the following where 'actionName' is something like 'GetAbc'.

Our web.xml contains

Lastly, the URL to start our application is something like http://server:port/MyApp/viewer. This entire configuration WORKS.


Now we have some Struts actions in /com/mycompany, /com/mycompany/aaa, /com/mycompany/bbb, etc.

#1: The struts.xml file:

Changed actionName values to 'aaa/GetAbc' so Ajax.Request is now '/s/aaa/GetAbc.action'.

RESULT: On post of http://server:port/MyApp/viewer/s/aaa/GetAbc.action, Unable to instantiate Action, com.mycompany.GetAbcAction, defined for 'GetAbc' root cause ClassNotFoundException for com.mycompany.GetAbcAction. Seems like it's still matching on "*" pattern. Don't understand why it's not matching later pattern. Tried defining "aaa/*" pattern before and after "*" w/ same result. Eventually found documentation that said when 1+ patterns match, last wins.

#2 - changed struts.xml to use Advanced Wildcard regex constants (see

RESULT: application no longer deployed so removed

#3 - try defining different package

RESULT - same as #1 above.

Help! Thanks!
7 years ago
Thanks, I saw this tutorial along w/ many others. I also just figured out that the annotation only apply to EJB classes...something I missed. I tried adding them to a simple POJO and found nothing fired.

My beef w/ the TimerService in the specific case I referenced is that it must "wake up" every so often to check to see if anything needs done. The "check" can be expensive and therefore this unnecessarily eats resources - it's yet another thread, it's taking up CPU cycles, DB cycles and it's possible the check does not complete before the next fire. This is something that does not occur w/ the current Thread implementation. Also as I mentioned before it requires adding complexity to the business logic to ensure only one item is processed at a time.

I'm sure the existing code can be converted into something compliant. This will be time consuming because the business logic is not designed to work the new way (e.g., the thread run() method is in an inner class or part of an object hierarchy) - in other words, this is not an easy or straight-forward modification. It seems like one needs to create EJBs for every little last thing (lots and lots of EJBs). Also, it seems I cannot guarantee the exact same behavior. Right now I just feel like my hands have been tied up and I can't do what I need to do. I guess when writing code for the first time in this kind of environment you know what you have to work w/, you set expectations, you design and implement appropriately. However, it's tough when an older application has existing behavior and business rules that don't seem to be supportable (in the what one is supposed to do sense) w/ the new ways of doing things. Just blowing off some steam...
I'm currently learning about EE threads (e.g., TimerService, Asynchronous EJB, Asynchronous Servlet) because on upgrading some very legacy code to the latest and greatest, I learned doing threads on your own (e.g., Runnable, TimerTask, Thread) in an EJB environment is a no-no. I think I understand the basics but have some questions.

I ran across some legacy code that spawns one thread. This thread has a run() method w/ a while(true) and inner try/catch that ensures the thread never dies. The logic w/in the run() method checks a condition and if the condition is met does something and on completion re-checks the condition. If the condition is not met it calls wait(). Somewhere else in the code, something else happens and calls notifyAll() which in essence wakes the thread up causing it to re-check the condition.

In the example above I see 2 things. First, there is only and ever one thread. If there are multiple things to do, the thread does each sequentially (by re-checking the condition). Second, when there is nothing to do there is no overhead - the thread sleeps until it's notified there is something to do.

Can I implement something equivalent to this w/ the EE approved thread mechanisms? It seems to me if I used TimerService w/ a single invocation timer and the existing run() implementation, I'm still in violation of the EE spec (e.g., should not susped or resume threads)...or am I? If I used TimerService w/ an interval time and the existing run() method minus the while(true) loop, it would result in multiple threads and also incur overhead checking the condition every interval. Also, the run() method might need added complexity to ensure only one thing is handled at one time. For example, assume the timer fires and starts to handle one thing and before it finishes, the timer fires again. This could be undesirable and I'm not sure it's possible to find an interval time that guarantees this. Lastly, it seems if I used an Asynchronous EJB/Servlet call (instead of invoking notifyAll()), this makes sure a thread only occurs when necessary but still makes things complicated to ensure only one thing occurs at a time.

It seems like it is going to be quite a mess and time consuming to upgrade the legacy code to comply w/ the EE specification. The code that creates/uses the threads and have fine-grained control over them are tightly integrated and conversion does not appear to be straightforward. It's a shame complete control no longer seems to be there (unless I'm totally missing something). I understand the managed vs. unmanaged issues ... will there ever come a time when we can still do threads like we used to but perhaps "request" them from the container? I'm also thinking about the use of 3rd party libraries like Quartz which spawns threads to execute jobs - these are now unmanaged and therefore should be unmanaged but the TimerService just doesn't seem to come close to the functionality Quartz can provide and some of what we're currently using and can't lose.

Any and all thoughts to provide understanding are welcome,
I'm upgrading an application that currently uses Xalan 2.6 to Xalan 2.7.1. I ran into an issue and I'm trying to confirm if this was a change in behavior and what I can do about it.

The XML file being transformed let's say is named "/a/b/c/Main.xml" and includes the following in its content: <include xmlns=""; href="chapter_c35.xml" />

With 2.6, the transformation of the XML file completes w/o errors or exceptions but the content of chapter_c35.xml is not included. I assume chapter_c35.xml is not found. The XML content is actually in-memory and using breakpoints, I confirmed there was no attempt to access this content.

With 2.7.1, the transformation of the XML file fails throwing the exception org.apache.xalan.xsltc.TransletException: org.apache.xml.utils.WrappedRuntimeException: C:\a\b\c\chapter_c35.xml (The system cannot find the path specified)
at org.apache.xalan.xsltc.dom.LoadDocument.documentF(

QUESTIONS: Is this a known change from 2.6 to 2.7.1? Was 2.6 incorrectly not failing when it can not resolve an include? Or did something change in the way includes are resolved (e.g., what gets called)?

Now, as for why the content of chapter_c35.xml is not found...I'm trying to confirm if this is really a bug in the application or if it is expected for this particular case (e.g., only want styled snippet of XML) but in the meantime, the TransformerFactory and Transformer objects do not have a URI resolvers set but the Source object that represents the XML content has a URI resolver set. Using breakpoints, I confirmed this is not called (for either 2.6 or 2.7.1).

QUESTIONS: Is there any particular reason why the Source URI resolver would not be called? Our URI resolver is a class that is a function of the source itself (i.e., each Source has its own resolver to account for differences). Good or bad, I'm not sure if a shared URI resolver set at the TransformerFactory or Transformer level would work w/o non-trivial changes.

To close out this thread, I found where the funky character pattern was coming from...somewhere within our own code. So, this isn't a problem w/ XSLT in general.
I'm working in some legacy code and encountering a very strange problem.

I have XML that contain <title> elements and the value of these elements contain processing instructions. On application of XSL, the output contains [%{#:#}%] where # is either blank or some number. What I've discovered so far is...

1. It seems to occur when the value of the title is stored in a variable. (e.g., <xsl:variable name=blah><xsl:value-of select=normalize-space() /></xsl:variable>)
2. The use of text() or "." instead of normalize-space() does not change matters.
3. If I don't use a variable and pass normalize-space() to the thing that is actually using it, things work.
4. I do not experience this in plain Java. i.e., using Java objects to perform the transformation
5. I do not experience this in plain IE. i.e., where the XML file references the XSL file and performs the transformation
6. I do not experience this in plain JavaScript. i.e., when I write a script function that uses the IE ActiveX objects (3.0)
7. I experience this in IE8 w/ code that uses the IE ActiveX objects (3.0). The difference between this code and the sample I wrote for (5) is unknown ... the real code is very cryptic and mostly generated so it's a slow process trying to figure out what exactly is going on.

So, just curious - has anyone seen this before and know what to do? Any suggestions on where else I might be able to find an answer? Currently, I'm trying to find occurrences of this and avoid the use of variables but I'm finding it difficult in some locations.

I'm in a strange situation. I have an XML document. I hand the XML document as a string to a "black box" that evaluates the content and returns a list of findings. I next display the XML document (using XSL) along w/ the findings. On click of a finding, I need to scroll to the corresponding location in the document.

The core business logic for the display currently supports scroll to given an XPATH and offset (the offset I believe being the number of characters w/in the element identified by the XPATH). Each finding corresponds with some location w/in the XML content (PCDATA) but the locations are represented as the character offset from the beginning of the XML as a string. The locations take into consideration the XML declaration, comments, PIs, etc.

One approach is to convert a fixed location w/in an XML string to an XPATH and offset w/in an element. Does anyone know if there is a library or function that exists that does this? This is not something I care to implement. I have a Plan B if not.

I'm in desperate need for a solution.

I'm working on an application that deploys in JBoss 4.0.1 SP1 and integrating with a 3rd party component that calls (org.w3c.dom.)Node.getTextContent(). On call of this method, my log files contain a NoSuchMethodError. I've determined that the JBoss lib/endorsed directory contains xml-apis.jar which defines the interface for the Node class and it does not define this method. I've also determined that this jar and the accompanying ones (e.g., xalan) are for Xalan 2.6.0.

I've tried upgrading these jar files to Xalan 2.7.x and on start I see boat loads of errors in my log file (e.g., various rar files do not deploy). I've tried the latest Xalan 2.7.1 jars from the Apache web site. I've also tried the Xalan 2.7.0 jars from the JBoss 4.0.5 distribution.

Has anyone ever successfully addressed this problem? What options do I have?

1. Upgrade to JBoss 4.0.5? I can ask but I can say with most certainty that this is NOT an option for me right now.
2. Wrap the integration w/ the 3rd party component in a command line application and call it from the server code? I'm sure this would work but it's not ideal, especially since I need to pass a lot of information back and forth to this 3rd party component.
3. Get JBoss 4.0.1 SP1 to work w/ an API that defines and implements Node.getTextContent()? How is this done?
4. Other?

I should add that I've also tried putting newer jars in the "lib" folder of the application's WAR file in hopes it would pick these up first but this did not work.

8 years ago
Note: I posted this on a Windows 7 forum and have not gotten much response. I realize this may not be a Java issue but I'm hoping someone may understand my problem and know what to do about it.

I have a Java application that establishes a socket connection w/ another application on a different machine. When this connection is disrupted (e.g., pull out network cable), I recognize this condition and take some action.

The application creates a Socket object, sets keep alive to true an then calls ObjectInputStream.readUnshared(). This call "hangs" until the server returns something or it times out. In the case when the network connection is disrupted and the call returns as a result...

In a Windows XP 32-bit environment, this happens quickly ... in seconds.

In a Windows 7 64-bit environment, this happens slowly ... in about 5 minutes.

If I run netstat in the Windows 7 environment, the TCP connection shows ESTABLISHED for about 5 minutes after the network cable has been unplugged. (In WXP, it changes in seconds.)

I've googled, searched both the Microsoft and this forum and have heard a few people refer to 5 minutes as being a "default" timeout value. I've also looked at the TCP spec, etc. to learn a bit more, understand it better, etc. in an attempt to find something I can configure to reduce the 5 minutes to seconds but I've not run into anything that works. I found documentation for a registry entry named TcpTimedWaitDelay for the TCP/IP service. It describes the default to be 240 seconds (4 minutes) and suggests it be set to 30. In the W7 environment, this entry was not set so I added it and restarted the machine. This did not work.