Tony Smith

Ranch Hand
+ Follow
since Mar 15, 2005
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 Tony Smith

...if two different ClassLoader instances both load the same ... Foo.class in the same JVM, and Foo.class defines a static variable S, then that JVM contains two different variables named "Foo.S", one for each ClassLoader.

And of course, now I ask, when I refer to Foo.S, which class reference is used?
15 years ago
Continuing my exciting adventure of discovery...

I'm ok with the fact that running a main() creates a JVM and the Singleton will exist as long as the JVM is running.

I created a web app called T1. It has within it index.jsp and a jar. The jar contains a Singleton's class file. The Singleton does nothing but return a value with a post-increment:

index.jsp does nothing but invoke getValue() and display the result.

When I browsed T1/index.jsp and refreshed several times, the jsp displayed the incremented value as expected. I opened a new browser window and repeated the process. The counter was shared between the browsers meaning both were executing code within the same JVM.

Then I created T2 which was identical to T1. I bound it to the same deployment descriptor that T1 used.

When I browsed T1/index.jsp and T2/index.jsp in different browser windows, it was clear each application was using a different instance of the singleton.

So each web application, then, gets a separate JVM? (And yeah, I could probably get that from the J2EE specification... That's next...)
15 years ago
When I run the program the 2nd time, the Singleton is gone. Is this because I started a new JVM whic blows away everything, or is it because the singleton was tied to my main somehow?

All along I've just accepted that this works, and it occurs to me I don't know how it works!
15 years ago
So if I am running a 'public static void main()' type of program (versus a servlet, etc), the static variable is associated with the thread running main, so when the thread exits, the static memory is garbage collected?
15 years ago
Sorry, this is moronic, I'm malfunctioning.

I have a class using a stock Singleton design pattern.

Say that I have some method a() which has a loop. Inside the loop, method b() is called. b() uses a singleton. When control returns to a(), what keeps the singleton from being garbage collected? Clearly it's the static variable within the Singleton... but what is the mechanism here? Is it nothing more than, "A static variable in an class gets lobbed into a shared part of the JVM?"

15 years ago
Late post sorry.

I'd recommend you skill up on refactoring before you delve too much into writing the junit tests for legacy code. The reason is that refactoring the code will save you from having to write a lot of supporting test code. For example, you won't have as many anonymous inner classes.

For me, the basic procedure would be something like:
1) Examine the code and notice a test case
2) Is the test case easy to write? If so, write it, goto 1. Else 3.
3) refactor out a chunk of code in the vacinity of what you want to test. Goto 2.

Repeat the above until you're exhausted.
[ October 26, 2006: Message edited by: Tony Smith ]
15 years ago
We've started a large project which involves i18ning our codebase and databases.

We have dozens of C batch programs and a significant java web app that must work with a new database schema as well as the old. To make matters worse, we have 25 databases (and counting, as we add customers.) We also have two database and hardware platforms, DB2 on AIX and a Tandem database which is quite primitive and at this time, necessary. The DB2 database schemas we currently have weren't built with unicode support. The Tandem doesn't support unicode at all. A large part of our effort involves finding ways to expand our use of DB2 by migrating as much functionality from the Tandem as possible.

For functional testing, we'd want an automated way to:
1) specify a configuration ID which will pull a subset of data from a 'gold standard' database and populate a DB2 database and two Tandem databases (one is for client data, one is for information common to all clients.) This mimics our current situation.
2) ER/ETL/migrate data from the 'legacy' schemas to new i18n'ed DB2 and Tandem schemas.
3) Run the current programs and tests against the legacy databases
4) Run the new programs and tests against the i18n'ed databases
5) Compare the results.
6a) For web code, also run the new code against the old schemas.
6b) Compare the results.

The above would have to be possible on a per-developer basis. That is, we could each fetch a configuration and work independently without stepping on each other. Further, a single developer could have multiple copies of the same test running if need be.

This looks like a tremendous amount of work. I doubt our ability to get this done and hit our dates.

I am thinking that there must be some configuration management software out there to reduce the brunt of this. I invite any and all opinions and alternative ideas.
15 years ago
Can you just cast the result set to an OracleResultSet?
15 years ago
Our install of RAD has a 5.1 application server installation option. Once you install that, you then need to run the mother of all patches (available from within WSAD) which takes hours and hours to download. So start the download when you leave for the day.
15 years ago
You are correct that it is different in 5.1.

I'm using 5.1 in order to maintain consistency with our Websphere 5.1 production server.
15 years ago
WSAD 5.1, 1.4.2 JVM, recent CVS.

I created a working Struts project, put it in CVS. updates/commits work fine.

Now, I want to deploy the code base on another developer's machine where this project has never been.

I can't see how to import from CVS as a project.

How do I do this without hackery?
[ October 24, 2006: Message edited by: Tony Smith ]
15 years ago
Ok, adding the EAR tothe code mangler is a good idea.

Take 1 -

I did that and, from Windows (not WSAD) checked the project out.
Then I checked out the EAR, again from Windows.

Now WSAD won't recognize these directories - they aren't 'projects' known to WSAD.

Take 2 -

I moved the checked-out goodies to c:\temp, then did an IMPORT from WSAD which put the files into a weird place (Servers). I deleted them out - it isn't what I want.

It comes down to I don't know how to check projects directly out of CVS in such a way that they are known to WSAD as projects.
15 years ago
I've been fiddling with this all off and on all day (again.)

This time, from windows, I did a CVS checkout into my workspace.
Then I created a new J2EE Application Application Project attempting to use the same name as I checked out. This failed because the directory already existed. So I renamed the stuff I checked out, made the Project and associated ProjectEAR projects, and swapped my checked-out code into the place where I think it should be.

After getting the JVM right (1.4.2) and the libraries set up, everything compiled.

However, now I am getting "CHKJ1004E: The URI, Blah.war, does not match anything in the EAR file.application.xmlBlahEAR/META-INFline 3" errors and
"CHKJ1000E: Validation failed because the application client file is not valid. Ensure that the deployment descriptor is valid.Blah"

errors. Everything looks good but you know how that is.

I'll jack around with this and get it to work. Until the next time I want a clean deploy. Then I'll be going through this again.

How do you all do this?

15 years ago
Thanks for the reply. I am 100% positive the files are in CVS. My WSAD 5.1 installation reports one of then as version 1.15 (with the proper tag, I did a release a few weeks back.) But that's WSAD 6 and will require a project conversion to 6 I suppose.

I can't even recreate the project properly in 5.1 (for other reasons.) So let me put off the WSAD 6 issues for another day.

I was going to go through the steps I normally go through to create the project in 5.1, then realized I don't have a procedure. I make it work on each developer's machine and it stays there forever, being CVS UPDATEd when needed.

So allow me to rephrase. How does one properly create a new Web Project (project + projectEAR) from a seeingly working Web project that's in CVS? As I was trying to explain how I did it, I created the project without using CVS then was in the position of having to import from CVS, overwriting any files WSAD had just created. Sounds wrong.
[ October 20, 2006: Message edited by: Tony Smith ]
15 years ago
We're using WSAD 5.1 and moving to 6 as soon as the spirit moves me.

I decided I'd check out my app into WSAD 6. I got CVS configured and did the "import CVS with wizard" thing.

The first problem is that not all my files came down. Some of my jars were marked as "deleted" at some point in the past, like 5 revisions ago. These jars live happily in 5.1 and seem to behave. Any idea on how to address this?

Second, is the difficulty in creating a project from scratch using a project in CVS as a starting point. I have almost certainly mis-configured the projet. We've had to hand-massage every developer installation to get it to work. I guess I have put files in the wrong place. I put my company's jar files in WebContent/WEB-INF/lib. Is this better used for standard jars exclusively? Or is the problem that I included websphere-ish jars in my project? This is probably more of a J2EE question than anything, but whatever I do needs to work with WSAD.
[ October 20, 2006: Message edited by: Tony Smith ]
15 years ago