Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Marc Heruela

Ranch Hand
+ Follow
since Jul 23, 2009
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 Marc Heruela

Campbell Ritchie wrote:You ought not to use number literals for dates; use Calendar.JANUARY, etc.

haha.. good one..
9 years ago
Also if you want to generate java.util.Date out from a Calendar object, i think Calendar.getTime() is a much better approach.
9 years ago
Try this:

note that just printing newDate (java.util.Date type) will just call the toString() method. If you need specific formatting, use SimpleDateFormatter.format()
9 years ago

Nathan Pruett wrote:What kind of memory issues are you experiencing? Exceptions? Symptoms?


Sorry for the late reply.. but it seems that one of our developer took the connection from the framework, used it and did not close that resource, hence the memory issue after some time the server starts. already fixed the code to not let our code handle the connection..

9 years ago
Hi guys,

This may sound a little stupid for a java developer for four years but I'm currently confuse.

I've installed jdk6 and glassfish 3.2 separately; tried to build the simplest ejb project and invoked the ejb from a stand-alone client (Java class), but I have an error saying Remote interface is not available in EJB 3.1 Lite. Sure enough, right there and then I found out Java has now two profiles, one for Lite and one Full. EJB 3.1 Lite is a subset of EJB 3.1 Full....... EJB3.1 Lite is part of Java EE 6 Web which is a subset of Java EE 6 Full (please correct me if I am wrong). So I assumed that I need to look for Java EE 6 Full specification (I assumed that what I have installed is the Java EE 6 Web specification, which I am so sure the jdk6 installer I downloaded does not specify it to be web profile). Then finally I went to Oracle and got this, java_ee_sdk-6u4-windows-ml.exe. Installing it prompted me the error telling me that I need at least 1.6 version of Java (TM) 2 Runtime Environment installed (I am sure I have it, but why do I need jre6 to install jdk6 if jdk6 already has jre6, I don't understand this). Okay I already installed the above sdk but the installer UI tells me it is installing Glassfish 3.1.2. What's happening, I thought I'm installing java ee sdk 6u4?

I am new to EJB3, I've been using jdk5 with spring, hibernate, struts2 in tomcat6 with no problem. Please shed me some light. I tried "googling" and read a lot, just want to confirm from the experts.


ps: I already have my simple EJB project up and running, but just want to clarify the above.. for future reference for some confuse soul as me..
9 years ago
Hi guys,

I may sound stupid with my question but please bear with me, recently we have this issue with our various projects when we're starting them. Probability allowed it that when we started our projects the URL defined in our DOCTYPE definition could not be accessed. Specifically: (I know the chance of this issue occurring is pretty slim but it happened to us)

The above snippet can be found in our struts2-jquery-plugin-3.0.2.jar/struts-plugin.xml. The error is when the url specified above is unreachable. Although we can ping the, we can not access the struts-2.1.7.dtd resource, it generates a Socket Exception and trying to request it using our browser yields the same result (NONE). Further, I am pretty sure we have internet connection because I can visit other sites just fine, and I'm also pretty sure that the project is working because we just restarted the server hence it's already up and running. The problem is gone after waiting for 10 minutes. But my boss wants me to workaround this issue to prevent the same situation from happening again. Just want to ask if there's a way aside from modifying the DOCTYPE into SYSTEM and downloading the said DTD place it in our local. I dont want risking modifying the jars.

A sincere response is much appreciated. Modifying the jar is my last choice. Thanks -marcdkun
10 years ago

hong zhong wrote:I have the same problem

hi.. i think you better check your internet connection.. at least that's my problem.. the tld of struts-default.xml is not loaded because the test server is not connected to the internet.... check if it is not restricting the tld url.. try visiting it to test..
Now there's one neat suggestion. haha im so stupid i never thought of that (my mind is pretty beaten already.. thanks)

Thanks a lot.

Much appreciated.

11 years ago
i already found a workaround.

but to answer your question sir. here is why i wanna access the request object in the constructor.

if i go to a certain page, say page A, using link_1, i will put default values on the fields (many fields) of the form on page A, otherwise, i will let it be null.

so on my action, i manually invoke the setters of the action. but i have to check which link i came from. that is why i want to initialize a flag on the constructor.

thanks sir.

11 years ago
This might not be a good practice, or Im not sure, but may I know how to access
the request object on the action class' constructor?

It seems ServletActionContext.getRequest() returns null.


Any help/explanation is much appreciated!

11 years ago
i think i found the answer. i dont know why but adding referenceColumn name inside @JoinColumn annotation solves the problem.

please advise if my solution is correct.

Additional Info:
Im using Hibernate, Spring Struts (Using Hibernate Annotation), on MySQL 5.1 RDBMS.


my foreign key bankaccount.bankcode references to issuingbank.bankcode which is not a primary key, but a unique key.

(i think the above is the caused of the problem since the primary key of issuingbank is an integer; explains the getInt() part,
but i dont know why)
Forgive my ignorance, but i've been trying to google/yahoo this thing for 2 days in a row already.
Hope you can shed me some light.

I have these database objects/tables below:

As you can see i have issuingbank table with a child table bankaccount with a onetomany relationship (wrt to issuingbank).
bankaccount.bankcode has a foreign key defined that references to issuingbank.bankcode.

I did my Hibernate Annotation mapping below:

When I try to load all issuingbank data EAGERLY using getHibernateTemplate.loadAll(IssuingBank.class),
I was able to load all IssuingBank data, and only some BankAccount data, even though the FETCHTYPE is EAGER. Further investigation (or maybe I am wrong),
is that I noticed that all data with issuingbank.bankcode value parsable to Integer
are loaded, while all data with issuingbank.bankcode value not parsable to integer were not loaded.
ANd when I try to load all BankAccount using getHibernateTemplate(BankAccount.class), I get and exception:

Caused by: java.sql.SQLException: Invalid value for getInt() -

It tried accessing all bankcode value as an int, but since it cant be cast it's an error.
Why did it tried to access the value via getInt() when in fact in the database it is varchar? Have I done something wrong in my map?

Also, how come the generated query is like this:

it tried to join via bankaccount.bankcode and; i have explicitly define that the mapping should be issuingbank.bankcode to bankaccount.bankcode.

I would be very glad if you tell me what I've don wrong.


Here's the significant part of my applicationContext.xml

12 years ago
Hello guys,

Im having this weird problem. We've developed a system that is behaving really awkwardly.
On our local it runs like a precious gem (it runs fine), but when we upload it in a server (my manager told me it's a very powerful linux server),
it has a memory issue. First minute after successfully starting tomcat (5.5), we can test the system, but after sometimes, it hang up.

Im just wondering why this is the case. We have developed 3 projects previously and all are running fine on the same server whenever uploaded.
The only differences I can think of (the only difference apparent to me), is the transactional part of my applicationContext.xml.

As you can see, in my previous projects, when I declaritively make my services transactional, I will only specify the package name, and all
transactional services are stored there. In this project, our lead asked us to group services based on logic, so it turned out a lot of packages and classes.
So when i declaratively make my services transactional, i had a lot <aop:advisor>. Just wanna confirm if this really is the one causing the memory issue?
But it's working fine on our local machine (VISTA). Sorry if the question seems stupid but im running out of idea.

Thanks for any response,
12 years ago