Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

Sam Gehouse

Ranch Hand
+ Follow
since Jul 21, 2003
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 Sam Gehouse

I want logger.debug statement from one class (org.myorg.MyClass) to go to only one log file (logY.log, which is appender A1) and not to show in logX.log. With configuration below, logger.debug from org.myorg.MyClass is now shoing in both logX.log and logY.log.

What is the least amount of change (this is maintenance code) that can be done in the following log4j.properties to show logger.debug("aaa") from org.myorg.MyClass only in logY.log (appender A1) and not show in logX.log?

Following is log4j.properties:

This seems to be common error:

I see OutOfMemoryError when I deploy a spring based application in an app server. AspectJ type classes are not getting garbage collected. By looking at other postings, it seems ore like the way application is coded/configured. Some of the postings talk about the problem with having static member variables. Shutdownhook is registered in the code.

Following seems like an interesting article:

http://blogs.sun.com/fkieviet/entry/...e_dreaded_java

That being said, did not notice similar problem with non spring app in the same app server with multiple deploys.

Any suggestion, or advice will be appreciated.
8 years ago
I admit that I am not good with regular expression. If any of you is good with regular expression, could you please suggest a pattern that will help me?

This is the problem statement:
If an input String contains any of the following 16 characters (e.g. !, @, =, etc.) that that input String is invalid.
8 years ago
Can anyone suggest a pragmatic way (e.g. use of object mappint e.g. Dozer, Smooky etc.) without writing code to copy properties from one object to another when the name of the properties may not match. If names of the properties did match in two objects (A.java and B.java), I could have used copyProperties. I also do not want to write tedious code to copy value of attribute a1 from A.java to value b1 in B.java.

Can you suggest of easy way of doing it using object mapping API of Dozer, Smooky etc.?

This is the problem:

Value of attribute a1 (which has public getter and setter) in class A.java has to to be copied to the value of attribute b1 (which has public getter and setter) of class B.java. As the name of the attributes are different (a1 in A.java and b1 in B.java), I cannot use copyProperties. I also do not want to write tedious Java code to pass the value of a1 of A.java to b1 of B.java.

Is it possible to set up Dozer, Smooky etc. that will copy value of a1 attribute of A.java into b1 attribute of B.java?

If I can do that, I can only write configuration code to do so.

Any advice will be appreciated.
8 years ago
I am trying to sign a jar file (e.g., my.jar) using a third party certificate (third.cer). I have placed "my.jar" and "third.cer" in the bin directory. I am getting an error while trying to sign the jar. It tells me that the keystore password is incorrect, which is not true. Any advice will be appreciated.


First, I successfully create a keystore and import the alias.

jarsigner fails


I did a list to make sure that my keystore was created correctly, as shown below:



Any suggestion will be appreciated.

8 years ago
Any adviice will be appreciated. I looked at the documentation, downloaded the sample code. Unable to get the WSDL published. This is what I did:

web.xml


WEB-INF\spring-ws-servlet.xml








WEB-INF\echo.xsd


My Questiions:
1. WSDL is not getting exposed under : http://localhost:9080/echoservice/echo.wsdl

Is my prop EchoRequest in spring-ws-servlet.xml incorrect? I get error as: Error 404: No target servlet configured for uri: /echoservice/echo.wsdl

2. Is my namespace in echo.xsd incorrect?

What do I need to do to expose the WSDL?
8 years ago
Thanks. I am fully aware of that website along with other info published by A. Buerki. Information and documentations available are scare and requires a lot of trial and error experimentation. I was hoping that someone has created comprehensive documentation on the steps required, that is not available in public websites. It is not an academic pursuit. There is a business need to integrate a working applet in GWT.
8 years ago
GWT
Is there a good step-by-step tutorial on how to integratew GWT with Applet?

Is there any technology to do that other than GWTAI?

Is there a good step-by-step tutorial on GWTAI?
8 years ago
GWT
Scenario:
Java API of setTimeToLive(int seconds) can be called on com.ibm.websphere.cache.DistributedMap that is looked up from JNDI resource configured in WebSphere App server 6.1 on z/OS. For example, consider that two separate JNDI resources that are configured in WebSphere App Server as one_hour_cache and one_day_cache. These two JNDI resources are looked up in the Java Code as distMapOneHourCache and distMapOneDayCache respectively. It is possible to use the Java API as:



Questions:
1. Please verify that the setTimeToLive(int seconds) API means that an element placed in that cache will live for the specified number of seconds.
2. Does the setTimeToLive(int seconds) API successfully work in WebSphere App Server 6.1 in z/OS? Is there any specific patch or version needed for this API to work? I saw some postings on APAR fixes on this under: http://www-01.ibm.com/support/docview.wss?rs=180&uid=swg1PK41845

3. Instead of using the API of setTimeToLive(int seconds) in the Java code (after looking up the JNDI resource), is it possible to configure this time to live setting in the WebSphere App Server console? For example, set the value as 3600 for one_hour_cache JNDI resource in the WebSphere AppServer console only, instead of coding for it in the Java program. Which panel(s) in the App server Console will allow us to do this setting, instead of coding for it in the Java code?
4. Does timeToLive(int second) in the Java API gets reset, if the element in the cache is looked up? For example, an element (e.g., e1) is in the one_hour_cache. That element e1 is looked up at 10:05AM using the distMapOneHourCache.get(Object) API. That means, its timeToLive will expire at 11:06AM. However, if e1 is looked up again at 10:30 AM using the distMapOneHourCache.get(Object) API, does the clock get reset for ONLY e1 and e1 lives in the one_hour_cache for 1 more hour, till 11:31 AM? Is it correct that the time to live for an element in the cache gets reset, every time the element is looked up from the cache using get(Object) API?
5. If the distMapOneHourCache.containsKey(Object), or distMapOneHourCache.containsValue(Object) API are used to look up the element e1, does the time to live for e1 in the one_hour_cache also gets reset for one more hour, till it is touched again?
6. Consider that an element in the distributed cache is expired. Does that mean that the element in the cache is also removed? The reason I ask this question is because, some (open source cache e.g. ehcache) invalidates the cache at times and removes later.
8 years ago
I created a custom annotation that can be applied on every method at this time. My intention is to limit the use of this annotation and not allow annotation on methods that have void as the return type. In other words, if a method has a return type as void, then I cannot apply my custom annotation on that method. If an attempt is made to apply custom annotation on that method (method that has void as the return type), then raise a compile time error (red X in the IDE).

For example, the name of the custom annotation is MyCustomAnnotation.

In a Java class, I have a method as:
public void myMethod(){....}

If an attempt is made to annotate myMethod, then show a compile time error (red X in the IDE).

How can I force a compile time error, if particular types of methods (all the methods that retun void) are annotated with MyCustomAnnotation?
8 years ago
I would like to find the return type of the method from org.aspectj.lang.Signature and org.aspectj.lang.ProceedingJoinPoint classes.

My code is like:



Form sig.toLongString() , I can get the entire thing.
From sig.getName(), I get the name of the method, which is getIt.
myTargetClass returns the name of the class, which is org.Service.MyClass.

pjp.getArgs() will return values of the arguments in an array which is good.

There is no API available to get the return type, which is java.util.List


I can use poor man's solution and parse the String obtained from sig.toLongString() to get the return type.

But I am wondering if there is any clean API available to get the return type (java.uti.List), instead of parsing sig.toLongString().


The view exists in DB2 for that schema. I can successfully run the generated SQL (that is generated by iBatuis by querying the View) in DB2 and get correct result.

While there is no table with the name V_MY_VIEW, there is view with the name V_MY_VIEW. The error code 42704 is thrown if table is not found. But the goal here is to run against the View and not the table.

I am not clear why 42704 error is thrown while I was primarily querying the view.
I am using iBatis (2.5) with DB2 version 8.x and Spring 2.5. Is there any issue in querying a view (as opposed to table)? It is a very simple select as:




org.impl.CodeBean is a simple POJO with String attributes only with public getter and setter. StringTrimTypeHandler are custom code written.

My SQL are working when I am using table, as opposed to View.

When I call the above findAll from JUnit for View, I get exception as:



I must be missing something.

Query from View is supported in iBatis, correct?
I am using iBatis version 2 and Spring 2.5

My XML looks like:


my1.xml looks like:



When I start the server with the application deployed, I get error as:



What should I be using for:
http://ibatis.apache.org/dtd/sql-map-config-2.dtd?

The link, http://ibatis.apache.org/dtd/sql-map-config-2.dtd is also broken.

Changing http://ibatis.apache.org/dtd/sql-map-config-2.dtd to http://ibatis.apache.org/dtd/sql-map-config-2.dtd, as I have it in my1.xml, I get exception as incorrect XML format.

My question:
What do I need to use in place of: http://ibatis.apache.org/dtd/sql-map-config-2.dtd?
The code works successfully, as long as I keep the name of the default "ehcache.xml". I can load it using code:


However, if I change the name of "ehcache.xml" to "myehcache.xml", I get exception. I load the "myehcache.xml" as:



The "myehcache.xml" is in the src folder of the project.

If I do do, I get error as:



"myehcache.xml" is as:



As soon as I change the name of the "myehcache.xml" to "ehcache.xml", the code works.

Any suggestion will be appreciated.
9 years ago