cancel
Showing results for 
Search instead for 
Did you mean: 

Share jar package and activiti class loader

rcosta1
Champ in-the-making
Champ in-the-making
Hi,

I would like to share a package that I write cross all my webapp inside a tomcat 6.0.5 installation of activiti 5.9.
I have read that "$CATALINA_HOME/shared/lib seems to be gone in 6.0 (it was there in 5.5)".
I have try various scenarios:

- to put my jar file inside tomcat "$CATALINA_HOME/shared/lib" folder but when I use activiti-explorer I recive "Could not load class …"
  (catalina.properties is configured to read all jars into this folder: "shared.loader=${catalina.base}/shared/lib/*.jar" )
  It's strange that "$CATALINA_HOME/shared/lib/ojdbc14.jar" work well
 
- to put my jar file inside tomcat "$CATALINA_HOME/lib/" but it's the same (in activiti-explorer I recive "Could not load class …")

Alternative I have to put my jar inside all webapp but I would like to know how can I share my jar.

Best regards
Riccardo Costa
10 REPLIES 10

frederikherema1
Star Contributor
Star Contributor
Adding the "shared/lib/*jar" in catalina.props should expose the all jar's in the shared class loader for all web apps. Activiti uses the following mechanism to lookup classes:

  • Try custom classloader, if set in configuration

  • If previous fails, use  Thread.currentThread().getContextClassLoader()

  • If previous fails, use ReflectUtil.class.getClassLoarder() (default class loader where activiti jar is loaded in)
Strange that even in the main "/lib" folder, this doesn't work. What is the "cause" exception of the "could not load class"?

npasquetto
Champ in-the-making
Champ in-the-making
Hi Frederik, I've got exactly the same behavior than Riccardo.

What is the "cause" exception of the "could not load class"?

The exceptions are:
org.activiti.engine.ActivitiException: couldn't instantiate class
Caused by: org.activiti.engine.ActivitiClassLoadingException: Could not load class:Caused by: java.lang.NoClassDefFoundError: org/activiti/engine/delegate/JavaDelegateIt seems that problem isn't on the visibility of my implementation but on the visibility of the activiti engine libraries. Could be?

Best Regards

frederikherema1
Star Contributor
Star Contributor
Yes, it seems to be the case… Altrough it's strange that activiti-classes itself can't find activiti-classes in the class loader :s

npasquetto
Champ in-the-making
Champ in-the-making
Yes, it seems to be the case… Altrough it's strange that activiti-classes itself can't find activiti-classes in the class loader :s

Really.

frederikherema1
Star Contributor
Star Contributor
NoClassDefFoundError will come if a class was present during compile time but not available in java classpath during runtime. So make sure the activiti-jars on on the runtime-path and visible to the class loader.

Beware, the SHARED class loader (libs shared with all web apps) can't access the web-app specific classes (which probably contains the activiti-jar).

Make sure the activiti-jar (engine) is available in the SHARED path IF you depend on it…

npasquetto
Champ in-the-making
Champ in-the-making
Thanks for the reply, Frederik!

But it's not very clear for me, when you say:
Beware, the SHARED class loader (libs shared with all web apps) can't access the web-app specific classes (which probably contains the activiti-jar).

Make sure the activiti-jar (engine) is available in the SHARED path IF you depend on it…
It's OK, but I'm in a different situation: I search for my jar from the webapp in the shared class loader, but the webapp has the activiti-jar in his class loader.

frederikherema1
Star Contributor
Star Contributor
To summarize what Iw as saying:
- Your jar-file (containing the JavaDelegate implementation) is present in the SHARED class path.
- The activiti-engine.jar file is in the web app's class loader (WEB-INF/lib).

If this is the case, than it makes sense.. Try adding activiti-engine-5.*.jar in the shared class path as well, since YOUR jar-file depends on it.

npasquetto
Champ in-the-making
Champ in-the-making
Hi frederik,
Try adding activiti-engine-5.*.jar in the shared class path as well, since YOUR jar-file depends on it.
Ok, thanks for your instructions!

npasquetto
Champ in-the-making
Champ in-the-making
Hi Frederik,
Try adding activiti-engine-5.*.jar in the shared class path as well, since YOUR jar-file depends on it.
After adding the engine jar another exception has been thrown that required also the slf4j jar. Adding slf4j this exception has been thrown org.activiti.engine.ActivitiException: org.mytest.MyDelegate doesn't implement org.activiti.engine.delegate.JavaDelegate nor org.activiti.engine.impl.pvm.delegate.ActivityBehaviorBut the same jar (same file), used in the webapp lib folder run correctly. I don't understand why.