1

I try to add a cache system on a JBoss server, as described in the Resteasy documentation : Resteasy Caching Features, on part 29.3. (Local Server-Side Response Cache) :

The next thing you have to do is to add a ServletContextListener, org.jboss.resteasy.plugins.cache.server.ServletServerCache. This must be specified after the ResteasyBootstrap listener in your web.xml file.

So I did, I've added a ServletServerCache listener as it is said in the web.xml after the ResteasyBootstrap listener :

<listener>
    <listener-class>
        org.jboss.resteasy.plugins.cache.server.ServletServerCache
    </listener-class>
</listener>

Unfortunately, this produce a ClassNotFoundException in the deployment phase :

14:01:44,817 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/DoQuBookWeb]] Erreur lors de la configuration de la classe d'écoute de l'application (application listener) org.jboss.resteasy.plugins.cache.server.ServletServerCache: java.lang.ClassNotFoundException: org.jboss.resteasy.plugins.cache.server.ServletServerCache

(sorry for the french btw)

So my questions are : am I the only one in this case (it seems not to be a common error on google) ? What is/are my mistake/s ? What's the right way ?

For information I use maven, and I include the resteasy-cache-core 2.3.1.GA dependency an dI'm quite a bit lost on this point ...

Thank you in advance for the help.



Edit :

I've looked into the archives deployed on the webserver. And I did found the Jar resteasy-cache-core (containing the ServletServerCache)

Here is described briefly the project architecture :

- Main project
    - Ear project (generate the deployed EAR)
         - pom.xml
    - Ejb project (generate an embeded JAR)
         - all ejbs 
         - pom.xml
    - Web project (generate an embeded WAR)
         - some js stuff
         - web.xml 
         - pom.xml

After a "mvn deploy", in output Maven2 gives an self containing EAR filled with :

- lib / *.jar
- META-INF/
    - application.xml
    - etc
- Ejb-1.0.0.jar (all ejbs)
- Web.war
    - js stuff/
    - META-INF/
        - etc
    - WEB-INF/
        - web.xml CALLING ServletServerCache
        - jboss-web.xml
        - jboss-app.xml
        - lib / *.jar WITH resteasy-cache-core.X.X.X.jar
        - classes/

So, imho, Maven2 bundle it correctly. But what ? This still stand mysterious.

Any idea ? It's not clear for my why the class is still not found.

(Sorry for a so long post)

Godjam
  • 21
  • 4
  • Did you add the relevant JAR that has that class to your build path? If so, do you set up the correct `ClassLoader` for that class? – m0skit0 Aug 13 '12 at 12:50
  • Hello, how can I specify a ClassLoader for the ServlerServerCache class ? And how can I check that the Jar is in the build path (I mean, it's done by maven, isn't it ?) – Godjam Aug 13 '12 at 12:52
  • Eclipse Juno. With maven plugin. – Godjam Aug 13 '12 at 13:23
  • I don't know about Maven, but the Build Path is on right-click on project -> Build Path -> Configure Build Path – m0skit0 Aug 13 '12 at 14:17
  • Thanks for your time, but the JAR is in correctly the dependencies of the project in eclipse (in my view it is automatically imported by the eclipse's maven plugin) – Godjam Aug 13 '12 at 14:59
  • If all else fails in situations like this I just get the source, put a break point around the failure and check the classloader - check where it's looking and what does it have loaded at that point. – blank Aug 13 '12 at 15:12

1 Answers1

2

I use resteasy and tried the jboss-cache that it includes. I just added

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-cache-core</artifactId>
    <version>2.3.5.Final</version> <!--or the version you use-->
</dependency>

to my pom.xml, and added

<listener>
    <javaee:listener-class>
        org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
    </javaee:listener-class>
</listener>

<servlet>
    <servlet-name>resteasy-servlet</servlet-name>
    <servlet-class>
        org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
    </servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>resteasy-servlet</servlet-name>
    <url-pattern>/MyRestContext</url-pattern>
</servlet-mapping>

<context-param>
    <param-name>resteasy.server.cache.maxsize</param-name>
    <param-value>10000</param-value>
</context-param>

<context-param>
    <param-name>resteasy.server.cache.eviction.wakeup.interval</param-name>
    <param-value>5000</param-value>
</context-param>

<listener>
    <listener-class>
        org.jboss.resteasy.plugins.cache.server.ServletServerCache
    </listener-class>
</listener>

to my web.xml file.

Of course, do not forget to add the other resteasy dependencies as well.

pulu
  • 495
  • 1
  • 7
  • 16