admin@glassfish.java.net

Re: Code changes

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Tue, 09 Oct 2007 09:24:31 -0700

Irfan Ahmed wrote:
>
>
> Ken Paulsen wrote:
>>> This is what I have replaced the code with.
>>> if
>>> ($constant{org.jvnet.glassfish.comms.admin.gui.extensions.util.SipUtil.RESOURCE_NAME})
>>> {
>>> setResourceBundle(key="sip"
>>> bundle="org.jvnet.glassfish.comms.admin.gui.extensions.resources.Strings");
>>> }
>>> and added a public static final String RESOURCE_NAME in the SipUtil
>>> class.
>>>
>>> However I now get a ClassNotFoundException. Actually the requirement
>>> is such that if I removed the sailfin-gui.jar file, which contains
>>> the sailfin specific code, I should not see Sailfin nodes. Now if I
>>> remove the jar file, I will get the exception. Excerpt from the logs
>>> follows:
>>>
>>> Caused by: java.lang.IllegalArgumentException:
>>> 'org.jvnet.glassfish.comms.admin.gui.extensions.util.SipUtil' was
>>> not found! This must be a valid classname. This was found in
>>> expression
>>> $constant{org.jvnet.glassfish.comms.admin.gui.extensions.util.SipUtil.RESOURCE_NAME}.
>>> at
>>> com.sun.jsftemplating.el.VariableResolver$ConstantDataSource.resolveValue(VariableResolver.java:755)
>> My mistake... I checked the case where the CONSTANT wasn't there, but
>> not the case where the class wasn't there. :( So I guess that check
>> won't work.
>>
>> Do you have any ManagedBeans? If yes, then you could check to see if
>> it exists. For example, if you have MyManagedBean w/ a property
>> "exists":
>>
>> if ("#{myManagedBean.exists=true}") {
>> ...
>> }
>>
> This would require me to create a sip-faces-config.xml file and place
> the same in the WEB-INF/lib directory. That would add another
> dependency on our code. Is there any other generic way.
Hi Irfan,

You can do this w/o adding the dependency. JSF allows any jar file to
contain a faces-config.xml file. You can place this inside your jar
file at META-INF/faces-config.xml. You can look at jsftemplating.jar
file for an example of how this is done.
> Is it possible to change the code for the $constant function to catch
> the ClassNotFoundException.
Yes, although I have mixed feelings about this. Constants should
normally exist and an error helps people find what they did wrong. If I
remove the exception, then typos will be more difficult to find. We can
discuss this at the next jsftemplating developer meeting which is 10/23
@ 12:00 PST (not a great time for you... sorry!). Or we can discuss it
at the next admin GUI ITeam meeting (enough JSFT developers are on that
call to discuss this issue)... that meeting is held on Tuesdays @ 9AM
PST -- in fact I'm on that call right now.

Ken
>
> Rgds,
> Irfan
> --
> Irfan Ahmed | Sun Microsystems Inc., Bangalore, India. |
> 9180-66927726, x27726