Hello,
I would like to have to share a data structure though JNDI. This data structure
behaves like a synchonized cache (let's say a data structure based on an
instance of HashMap). Some session beans of mine will then use this shared
cache to store/access some stuff.
How should I do implement this shared cache ? I would like to understand what
is the best practice to share a data structure between all instances a a
session bean ?
I understand <env-entry> tags only allos you to share some basic types.
Therefore, I tried to bind such a cache in the init() method of a servlet
(loaded at startup) :
InitialContext context = new InitialContext();
| // Create application sub context
| try {
| Context appContext = context.createSubcontext("java:comp/env/myApp");
| } catch (NameAlreadyBoundException e) {
| // Do nothing
| }
| try {
| Context cacheContext =
context.createSubcontext("java:comp/env/myApp/cache");
| } catch (NameAlreadyBoundException e) {
| // Do nothing
| }
| context.rebind("java:comp/env/myApp/cache/aCache", new Cache());
In my session bean code, I attempt to get access to my cache with :
try {
| InitialContext context = new InitialContext();
| return (Cache) context.lookup("java:comp/env/myApp/cache/aCache");
| } catch (NamingException e) {
| ... /...
| }
However, when a session bean attempts to access to the shared cache, I get a
NameNotFoundException saying 'myApp not bound' (note that the cache looked like
well bound at startup of the initialization servlet).
Any ideas how I should proceed ?
Fred
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3859050#3859050
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3859050
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user