Bug 41018 - Linking global resources using ResourceLink broken
Summary: Linking global resources using ResourceLink broken
Status: RESOLVED WORKSFORME
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: Unknown
Hardware: PC All
: P2 minor (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2006-11-22 07:48 UTC by n.beekman
Modified: 2006-11-25 06:56 UTC (History)
0 users



Attachments
Patch which fixes described problem. (848 bytes, patch)
2006-11-22 07:52 UTC, n.beekman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description n.beekman 2006-11-22 07:48:59 UTC
It seems that including a global defined resource using ResourceLink is broken.
The link gets bound in JNDI, but retrieving it results in null being returned.

This was the case in Tomcat versions 5.5.12 and higher, I believe it is still
broken in Tomcat 6. See attached patch for a fix.
Comment 1 n.beekman 2006-11-22 07:52:43 UTC
Created attachment 19159 [details]
Patch which fixes described problem.
Comment 2 Remy Maucherat 2006-11-22 08:45:17 UTC
-1 for the patch. It's simply that Context.OBJECT_FACTORIES usage is not
supported at the moment (same for all the other reference types).
Comment 3 n.beekman 2006-11-22 09:50:39 UTC
(In reply to comment #2)
> -1 for the patch. It's simply that Context.OBJECT_FACTORIES usage is not
> supported at the moment (same for all the other reference types).

I think it's rather strange to program a bug in getFactoryClassName() because of
Context.OBJECT_FACTORIES being unsupported.

How about changing it into:

public String getFactoryClassName() {
  String factory = super.getFactoryClassName();
  if (factory != null) {
    return factory;
  } else {
    return DEFAULT_FACTORY;
  }
}

That would work well in case a custom factory is passed to the constructor, and
in case no factory (or null) is specified.

On a side note: I'm curious why this issue was never encountered, the
documentation contains plenty of documentation about the global resources
feature, is it not recommended some way, or is it simply because no one uses it?
Comment 4 Remy Maucherat 2006-11-22 13:51:25 UTC
Obviously because there's no reason to set Context.OBJECT_FACTORIES, so people
don't do it, and they don't run into the unimplemented code.
Comment 5 Mark Thomas 2006-11-23 15:14:10 UTC
ResourceLink works for me. If you have a test case (simplest possible jsp /
servlet / war + source where appropriate) that demonstrates this issue please
re-open this report and attach your test case.
Comment 6 n.beekman 2006-11-25 06:43:02 UTC
(In reply to comment #5)
> ResourceLink works for me. If you have a test case (simplest possible jsp /
> servlet / war + source where appropriate) that demonstrates this issue please
> re-open this report and attach your test case.

I found the problem: since Tomcat 5.5 you can use the Transaction-element
instead of the Resource-element, however this is unsupported/broken when used
inside GlobalNamingResources-element. Hence I got null as result of the lookup.
Should I file a new bug for this problem? The problem goes away when using the
old-school Resource.

You are right about the patch, it does not solve this problem, I think I changed
two things at once (applying the patch and using Resource instead of Transaction).
Comment 7 Mark Thomas 2006-11-25 06:56:47 UTC
I suggest you post to the users list to confirm that what you are trying to do
is valid and that you have indeed found a bug. If the discussion on the users
lists suggest that a bug does exist then please open a new issue.