Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Ehcache and cache names containing a slash

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ehcache has a bug that causes FileNotFoundExceptions when a cache has a name containing a slash (like "sessions/userId") and overflowToDisk="true". The problem is that the cache's data and index file paths are created from its name without any escaping of illegal characters.

Does anyone know a workaround besides overflowToDisk="false"?
[originally posted on jforum.net by sbridge]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem like that, but i think isn't the same.
I get an error when i try use EhCache:
..........
ERROR [ExceptionWriter ] java.lang.IllegalArgumentException: Cache name cannot contain '/' characters.
........

I don't know what's the problem?
[originally posted on jforum.net by feusebio]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the EhCache XML config file parser actually validates the cache name unlike the API which has a minimum of validation (probably to optimize execution times), hence the IllegalArgumentException.

Download the JForum source code and go through all the classes listed in "cacheable.objects" property of your SystemGlobals file. Remove any slashes from the FQN static final fields. This will solve your problem. Or you can implement your own CacheEngine to translate the cache names first. In both cases, the name used in the EhCache config will be the new or translated version.

[originally posted on jforum.net by sbridge]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fix it with a simple modification at net.jforum.SessionFacade.java class, at the bigining of class in the declaration var section, where we have:

private static final String FQN_LOGGED = FQN + "/logged";
private static final String FQN_COUNT = FQN + "/count";
private static final String FQN_USER_ID = FQN + "/userId";

i put:

private static final String FQN_LOGGED = FQN + "_logged";
private static final String FQN_COUNT = FQN + "_count";
private static final String FQN_USER_ID = FQN + "_userId";

but now i have a problem, some template vars don't have value after login, like us.isAdmin.
[originally posted on jforum.net by feusebio]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked your log file to see if the missing vars are the result of an exception thrown before they can be set?

I suspect that you will need to correct the FQNs in ForumRepository too.

[originally posted on jforum.net by sbridge]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sbridge,

Do you have Jforum run with EhCache?
I have some dificulties to fix my problem, i correct the FQNs in ForumRepository too, but the forum after a sucess login get undefined value for
"us.isAdmin" at forum_list.html template file:
-------------------------------------
<#list userSessions as us>
<#if us.isAdmin()>
<#assign color = adminColor/>
..........................
</#list>
------------------------------------------

When i use the DefaultCache of Jforum, i don't have this problem, only just for EhCache.

Thanks
[originally posted on jforum.net by feusebio]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
net.jforum.repository.TopicRepository also has a FQN containing a slash. It is the last one besides the two you have already fixed.

My solution was to implement my own net.jforum.cache.CacheEngine which replaces all '/' with '.' in the fqns. A ConcurrentMap is used to cache the translations for faster lookup. It is a very custom class created for my own unique requirements (JForum has to work with other code that also wants to configure/start/stop EhCache) so you should write your own. It seems to work but has not been tested under heavy load nor has every page/template been tested.


[originally posted on jforum.net by sbridge]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try implement EhCache in a fresh Jforum source, but i get same problem with undefined value for expression "is.Admin" in the forum_list.htm file template. And i fix the problem for cache name with slashes, but the problem with undefined expression, seams that it is something with session. The error appear only when user do login and get logged.
[originally posted on jforum.net by feusebio]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting "Expression us.isAdmin is undefined" with Ehcache even with overflowToDisk="false" and with all slashes replaced. Anyone has the solution?

Pino

[originally posted on jforum.net by Pino.OW]
 
All of the following truths are shameless lies. But what about this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!