Cameron Dalton

Greenhorn
+ Follow
since Nov 14, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Cameron Dalton

Good morning, everyone. I'm working with Struts 1.1, and I'd like to get 2 error message sections on a single page. To give you an idea of what I mean: I'd like one section above the form for adding a record (which might have validation errors for the form, or save errors, etc), and then another error message section underneath that but above a list of existing records (which might have errors or warnings that occurred while retrieving the records). Is this possible? From what I've seen so far, I can only figure out how to add errors to one error store, and then they're all displayed in the same place.

Thanks for your help.
15 years ago
Thanks for your response, Javid. Here's the interesting parts of my hibernate.cfg.xml:



This is not running in a J2EE container as it's a standalone Java app, so I didn't think I could use a datasource. Maybe I'm wrong though...
We have a long running stand-alone application which listens on a JMS queue for messages telling it to run. When a message comes in, a Hibernate session is opened, queries are performed, and then the session is closed using Session.close(). There is no transaction management because no writes are being performed.

Now I was under the impression that Session.close() closes the underlying JDBC connection with the database. However, something seems to remain open or aware of the database server because if the database is restarted before the next JMS message comes in, there is a SocketException thrown (with messages like "connection reset by peer", "socket write error", etc). The open session does not throw the exception; it is thrown by the first query.

What do I need to do to completely close the connection so that when a JMS message is received a brand new connection is made from scratch?

Thanks for your help with this problem.
I don't HAVE to use IBM's version (although IBM says I do), but the JAR downloads increase if I don't. When I tried that a couple days ago, it couldn't find some IBM classes that aren't bundled in the JARs I mentioned. I thought that when I have more time I'd do a jar search to find out which JAR contains these extra classes, add them to the JNLP, and then try it on Sun's 1.6. I once upon a time tried it on Sun's 1.5 and had the same memory footprint (although I'm not sure about the console thing since I didn't know about it back then to check).

When I do give that a shot I'll let you know what happened, since you're curious.
16 years ago
Yep, just the standard console that you can turn on and off from the Java Control Panel. It does seem that it's related to the JARs but I don't get how the console is related. Version is 1.5.0, but it's from IBM so who knows...

Anyway, thanks for your help. I imagine I'll give up on this now and head down a different path to reduce memory footprint.
16 years ago
Thanks for your response, Martijn. The application is a single JMS consumer. I understand that requires extra threading in the background, but I'm not sure why that would involve lots of memory usage. No data is loaded (other than small JMS messages), and logging is very minimal. The one thing that is exceptional is the amount of JARs downloaded by JWS and added to the classpath. This application loads IBM's app client JAR collection, which contains 60 JAR files in a total of 68.5MB. I wouldn't think JWS-loaded JAR files would be maintained in memory until a class is actually loaded by the class loader, but I guess you never know. But even still, why would the memory usage drop so significantly after something so unrelated as minimizing the Java Console?
16 years ago
Hello. I wrote an application which is currently invoked using Java Web Start. I'm not posting in that forum because I'm not sure this issue is related to JWS.

When looking at the Windows Task Manager, I can see that as my application starts up the memory usage quickly ramps up to around 130,000K. When I have the Java Console set to display, and I minimize the console, memory usage drops to around 4,000K. Restoring the console bumps memory usage up to around 12,000K.

If I run my application with Java set to NOT show the Java Console, memory usage is still around 130,000K after application startup.

I have a couple questions here. First, if minimizing the console cuts memory usage down to 4,000K, why doesn't my application have such low memory usage when the console is not displayed at all? Second, is there any way I can reduce the memory footprint without having to minimize the console? This application is supposed to run indefinitely and without human interaction on system startup, and shouldn't require a user to minimize the console. Does anyone have any ideas on these questions?

Thank you.
16 years ago
Balu, that's a great idea. I did that and was able to lookup the value, which means the web.xml change was picked up. I'm not sure what's going on here. But I'm plugging away and will hopefully make some progress soon. Any more ideas are certainly welcome!

Thanks.
16 years ago
The server seems to restart normally and I didn't notice any warning or error messages in the log. But you're right to wonder about that; I have occasionally had problems with applications not recognizing an update to the web.xml file but recognizing other file updates. Hmm...
16 years ago
I understand that welcomeMessage is null and that I haven't instantiated it. As I understand it, I shouldn't have to instantiate it because the @Resource annotation is supposed to locate the env-entry block in web.xml and inject the env-value into welcomeMessage. There are examples of this on Sun's site: http://java.sun.com/developer/technicalArticles/J2EE/injection/index.html under the heading "A Simple Servlet". I believe my code matches the example.

However this is not working as I'd expect it too. The idea is that I don't have to instantiate the object and it will be instantiated for me. This way I can use environment-specific properties (support email addresses, WSDLs, etc) without headache. I hope this clears up the situation.

Also, I know that the toString() is superfluous; I added it so that I'd get the stack trace you asked for.
16 years ago
Thanks for your response. I did throw it into a package, thanks for the reprimand. Laziness due to this being just a test project, but you're right.

Anyway, I changed the servlet so it would throw a NullPointerException instead of just printing null. Here's the new servlet code:



And here's the stack trace. It's pretty much what you'd expect.

16 years ago
I have an env-entry defined in my web.xml and when I attempt to print it from a simple servlet all I get is null. And of course if I attempt to invoke any methods on the object I get a NullPointerException.

I read somewhere that this can happen if you're using version 2.4 instead of 2.5, so I changed to 2.5 and I still have the same issue. Here's the web.xml:



And here's the servlet. Displaying this env-entry is all it does:



Thanks for your help.
16 years ago
I find myself writing a method that requires multiple synchronized() blocks within the method. I'm looking for some opinions here. Is it better to:

- synchronize the entire method (to have fewer synchronizations), or
- synchronize many times within the method (to have less code synchronized and reduce the scope of synchronization)

I believe performance will be better with just the single synchronization due to overhead involved with acquiring the lock, like flushing the memory cache. But it is also best practice to keep the scope of synchronization as small as possible to help guard against deadlock. I think I'm leaning one way more than the other, but what do you all think?

Thanks for your input.
I discovered a solution using wait() and notifyAll() that I overlooked originally.
16 years ago

Originally posted by Martijn Verburg:
Can I ask why you're staying away from JMS? It's designed to do exactly this



I'm hoping to avoid all the overhead of JMS connections and all the extra threading that goes along with them. This will only take place on a single server, not across multiple servers.
16 years ago