Manny Garcia

Greenhorn
+ Follow
since Apr 04, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Manny Garcia

Badal Chowdhary wrote:VisualVM is a free Java profiling tool. I did use this to play around and got a basic Java program attached to this profiler. What is the state of your heap memory?



Howdy Badal,

I have a web application with one Restful web service that blows out memory. It happens in a single thread that's grabbing messages off a JMS queue, turning them into Java objects and then storing them in a MySQL db. It runs great for about a half hour (when I'm stress testing) with mem usage not climbing up more that when that thread in the app isn't running and then without warning, BLAM! mem usage ramps up and inside a 3-5 second window I start seeing heap errors.

I've seen other profiling tools that look easy to hook up to a simple Java app but I need to attach this to a web app that's running inside glassfish. How easy is it to do that with VisualVM? I've had no luck finding any instructions on a free profiler that can do that.


Regards,

Manny
7 years ago
Howdy,

I'm looking at a memory issue in some code in a few classes that run in a web app. I'm using Glassfish3.1 and have a fairly straight forward REST web app with some Java EE elements (it uses JMS to do some offline processing, etc). The problem is that when I test a part of the app under stress and monitor the server (a Linux server) using top I see the CPU usage at nice acceptable levels for about 20 minutes them BAM! 98-100% levels for ever after. I need to profile the app to figure out what is owning the CPU but I've never used a profiler before and am baffled by all of the online documentation I've found so far. I was hoping to use HPROF since it's built-in but I can not figure out the correct steps to use it.

Is there a plain English document that explains (with examples) how to use HPROF on a web app running in a server (in my case Glassfish 3.1) and read the CPU profile data?

I will accept another solution so long as I can get it easily for free (i.e. I can't use jProfiler because the license costs money), though my preference would be to use hprof.

Regards,

Manny
7 years ago
Hi James,

I'm a back end java developer but I've always been interested in doing a little fun front-end stuff, particularly when it comes to gaming. Aside from your book () can you recommend a site that gives a quick description of the capabilities of HTML 5, something that could in a page convince me that this is a skill that I need to pick up to have some real fun?

Regards,

Manny
I tried waiting it out, overnight and still the problem persisted. I tired about every permutation of a ps lookup I could and could find nothing referencing that port. Finally our IT guy gets back to me and says that they've been diddling with the hosts file on that machine and that requests to start glassfish might actually be going to another server where the same application is running, hence my inability to locate that port on this particular machine. He's going to mess with the hosts file and get back to me. If this works I intend to do violence to our IT guy.

I generally don't delve into this sort of thing, so I'm not sure if his explanation is bullsh*t or not. I'm a code monkey, so this has been a rather frustrating experience on the whole.

Regards,

Manny
Howdy,

I'm attempting to start an instance of a glassfish server immediately after I've (gracefully) stopped it. When I try to restart it I get the following error:
There is a process already using the admin port 4849 -- it probably is another instance of a GlassFish server.

The problem is I do a netstat looking for the process that owns that port and I can't find anything! I have to find a pid to kill so I can restart the server. Does anyone have any ideas?

Regards,

Manny
All interesting ideas. Thanks folks.

Regards,

Manny
7 years ago
Holy cow Paul, that was easy! Thank you.

Regards,

Manny

Paul Clapham wrote:And here I thought you had a question about web services!

If you want something to be done when your web application starts, just create a class which implements ServletContextListener and put your code into the contextInitialized method. Configure the name of that class into your web.xml in the appropriate place.

7 years ago
I have a large-ish web app with a lot of moving parts. In particular I have a lot of cached data that doesn't get initialized until the first time a class is instantiated. My question is: Is there a way to set up a class with a method that will be called when the web app is started so that I can ensure that my cache is loaded before the first time someone wants to use it and perform any other start up tasks I'd like as well?

Regards,

Manny
7 years ago
Good to have that confirmation. I will dig deeper into this then.

Regards,

Manny
Howdy,

I have an app that among other things takes a list of objects and stores them in a db. Since this doesn't need to be done synchronously, I wrote it so that the list was iterated over and each item put into a JMS queue where it was consumed by another thread. It works fine, but the problem I have is that my producer seems to wait until each object is processed by the consumer. I was specifically using JMS in order to return to the app after sending off the objects. So my question is: Should my producer be running in it's own thread in order to have it perform the way I was expecting or am I possibly doing something else wrong.

I have avoided using code samples as I hope that this can be answered at a high level.

Regards,

Manny
Well, I found something that worked. I did not find any documentation that said to do it this way, but it has the virtue of working:




Regards,

Manny
8 years ago
Hi,

I'm using jersey 1.8 from the jersey bundle and running on glassfish 3.1. I'm writing a REST web service and all has been peachy, until I need to send a specific response code. Every time I try to get a ResponseBuilder object I get a very generic jersey exception. Here's my code:



The method errors out on line 20. Note I know that this code doesn't do anything useful. I'm attempting to return a 403 response with a custom header. In my testing I deliberately call the method with parameters that will cause a ForbiddenException (a custom exception) to be thrown. Here is the error I see when I attempt to execute line 20 above:


Prior to this the method's return type was JSONObject and I wasn't attempting to modify the response in any way and life was hunky-dory. Does anyone have any ideas what I could do to make this work? I've been at it for hours.


Regards,

Manny
8 years ago
Wow thanks for all of the replies. I've got the day off and the whole weekend ahead of me so I'll start checking out my options immediately.

Best Regards,

Manny
8 years ago
Hello all. I've been writing server-side code for a long time now and was looking at doing a few projects just for my own enjoyment. Previously everything I've done has had a web interface, usually written by someone else. I want to do a few projects for fun that are stand alone desktop apps and need to pick a UI for it. From what I've been reading Swing seems to be on the road to obsolescence and was wondering what options I have out there. I could use either Eclipse or Netbeans, I'm agnostic as to which to use. I've noticed that Netbeans has a lot of support for Swing though as I mentioned Swing is not going to become a part of the JDK.

So my question is: What is a good UI framework to use for a desktop application? What are the pros and cons of some of the choices?

Regards,

Manny
8 years ago
I was curious if it would be better to synchronize a block of code on the class that contains the block rather than on an instance of the class. My thinking was that if the synchronization were on the instance and there were multiple instances of that class about then the synchronization wouldn't work. For example:



For the record, I am aware of the AtomicInteger class and it's ilk. Also the implementation of IntProvider is not important for the purposes of this discussion (it could be anything). I am trying to sort out the different possible behaviors of the implementation of myMethod in MyClass and OtherClass in a multithreaded environment.


Regards,

Manny
8 years ago