Joe Cheung

Ranch Hand
+ Follow
since Oct 18, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Joe Cheung

My application is running on machines located in NY. How can I convert the current time to UK TZ? Anyone give me the code?

By the way, anyone has the list of "ID for all countries" which we use to specify timezone in setTimeZone?
17 years ago
I am developing an EJB project in WSAD in which I have created a source folder storing all config. and properties files (I have examined the exported EAR file that it cantined these files). However, I found the EJB cannot locate the file. Shown below are the code snippet of loading the properties file "app.properties" with different approaches but all failed:

// Approach 1
final ResourceBundle rb = ResourceBundle.getBundle ("app.properties");

// Approach 2
final ResourceBundle rb = ResourceBundle.getBundle ("/app.properties");

// Approach 3
final ResourceBundle rb = ResourceBundle.getBundle ("app.properties",Locale.getDefault (), ClassLoader.getSystemClassLoader ());

// Approach 4
final ResourceBundle rb = ResourceBundle.getBundle ("/app.properties",Locale.getDefault (), ClassLoader.getSystemClassLoader ());

What's the problem? How can I solve it?
I am developing an EJB project in WSAD in which I have created a source folder storing all config. and properties files (I have examined the exported EAR file that it cantined these files). However, I found the EJB cannot locate the file. Shown below are the code snippet of loading the properties file "app.properties" with different approaches but all failed:

// Approach 1
final ResourceBundle rb = ResourceBundle.getBundle ("app.properties");

// Approach 2
final ResourceBundle rb = ResourceBundle.getBundle ("/app.properties");

// Approach 3
final ResourceBundle rb = ResourceBundle.getBundle ("app.properties",Locale.getDefault (), ClassLoader.getSystemClassLoader ());

// Approach 4
final ResourceBundle rb = ResourceBundle.getBundle ("/app.properties",Locale.getDefault (), ClassLoader.getSystemClassLoader ());

What's the problem? How can I solve it?
To increase the chance of GC, I usually use the following approach to call GC to clean up the memory:

Test testObj = new testObj; // Suppose it is a very large object

/* after some complex processing */
testObj = null; // make the Object (memory location) unable to be referenced and then become a candidate for GC
System.gc(); // Call GC to clean up the memory


Is this approach always reclaim the memory used by testObj as I expected?

Any other good practices for GC in Java Coding (not JVM tunning)?
17 years ago
Anyone has Java Tibco RV example code? I searched but can't find any reference on web
17 years ago
What's the difference between them?

I see something confused me as I saw hibernate use Jakarta Commons Logging (JCL)by importing the following classes for logging:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

At the same time, it defined all logging properties in log4j.properties rather than commons-logging.properties. Is it strange to use JCL with log4j property file???
Sorry, it should be posted at another topic. Please ignore this post
17 years ago
What's the difference between them?

I see something confused me as I saw hibernate use Jakarta Commons Logging (JCL)by importing the following classes for logging:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

At the same time, it defined all logging properties in log4j.properties rather than commons-logging.properties. Is it strange to use JCL with log4j property file???
17 years ago
I have a J2EE project using LOG4J running on IBM WebSphere Server (WAS). I don't understand why I can't disable the INFO log by defining the log priority as WARN for a package. Shown below is the snippet of my log4j.properties:

# The INFO log in Java classes in package com.testing should be suppressed
log4j.logger.com.testing=warn

and I use the followings to define the logger:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Log log = LogFactory.getLog(Test.class);

log.info("This is INFO"); // it should be suppressed
log.warn("This is WARNING"); // it can be shown

When I run the Java class in WAS, the INFO log still appear. However, the INFO log didn't show up when I run it as ordinary Java Application.

What's wrong?
17 years ago
I have a J2EE project using LOG4J running on IBM WebSphere Server (WAS). I don't understand why I can't disable the INFO log by defining the log priority as WARN for a package. Shown below is the snippet of my log4j.properties:

# The INFO log in Java classes in package com.testing should be suppressed
log4j.logger.com.testing=warn

and I use the followings to define the logger:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Log log = LogFactory.getLog(Test.class);

log.info("This is INFO"); // it should be suppressed
log.warn("This is WARNING"); // it can be shown

When I run the Java class in WAS, the INFO log still appear. However, the INFO log didn't show up when I run it as ordinary Java Application.

What's wrong?
I found that some files that are necessary to run my java project, says a properties file, in a JAVA source package folder were not copied to the "default output folder" when I built the project. How can I customize the build process to include these files into the corresponding package folder in WSAD?
RSA stands for "Rational Software Architect" which is built on top of "Eclipse" developed by IBM
I have 2 questions related to using config. files in EJB projects developed in RSA 6.0.1:

1) I have defined a folder "cfg" as a source folder in which I defined some config. files, I expect RSA should copy all config. files to the default output folder which is "ejbModule" but it didn't. So, what's the problem? (it worked fine for web projects in the sense that all config. files were copied to WEB_INF/classes.)

2) To use config. files, I put all config. files in folder "ejbModule" in the EJB project JAR file and it worked fine! However, it didn't work if I put the file one level inner: "ejbModule/config". So, what's wrong with this approach?

Thanks!
I am using RSA 6.0.1 to develop a EJB project in which LOG4J is also used to log some userful information when the EJB is running. I found that RSA didn't package the log4j-1.2.11.jar into the EAR file even I have added the JAR file in the EJB project. Therefore, I have to copy the JAR file to the folder "Utility JARs" in the EAR and define the entry "Class-Path: log4j-1.2.11.jar" in META/INF/MANIFEST.MF manually or the EJB will result in NoClassDefFound for the log4J otherwise.

Can RSA do it automatically for me?
Jeanne,

It works! Thank!

Another similar question is what I should do if the EJB needs to refer to some config. files like log4j.properties or other XML config. files?