Re: NoClassDefFoundError: com/opensymphony/workflow/loader/AbstractWorkflowFactory

"Pat Lightbody" <[email protected]>
Newsgroups gmane.comp.java.open-symphony.devel
Message-ID <047201c33ccf$888ffb20$caf010ac@moose>
Sucky... glad it worked out for you. I've opened WF-178 to make sure we
don't use Class.forName(), just as a precautionary thing.

-Pat

----- Original Message -----
From: "Travelli Stefano" <[email protected]>
To: <[email protected]>
Cc: "Barsotti Paolo" <[email protected]>
Sent: Friday, June 27, 2003 9:37 AM
Subject: R: [Opensymphony-developers] NoClassDefFoundError:
com/opensymphony/workflow/loader/AbstractWorkflowFactory


> It was a good suggestion. Thanks, but it was not the case. For those who's
interested, here is how my trip in the class-loader hell was finally over:
>
> Last week I wrote a custom WorkflowFactory that extends
AbstractWorkflowFactory, that is:
>
> public class MactWorkflowFactory extends AbstractWorkflowFactory
> {
>     public WorkflowDescriptor getWorkflow(String name) throws
FactoryException
>     {
> [...]
>
> I put this class in a jar. This jar stays together with osworkflow,
propertyset and oscore jars in web-inf/lib or in the Class-Path attribute of
the "war" manifest.mf file.
>
> osworkflow.xml declared the factory:
>
>     <factory class="it.formula.mact.process.MactWorkflowFactory" />
>
>
> The very first time the application used a workflow instance, osworkflow
loaded the configuration, found for the factory class name and tried to load
an instance of the WorkflowFactory.
> This is exactly what you can see in the stack trace below, and the process
failed with that error.
>
> The only way I found to make it works was putting a reference to
osworkflow jars in the manifest.mf file of my application jar. That is:
>
> mact3-process.jar (here is where my custom workflow factory resides)
> - manifest.mf -> Class-Path: osworkflow-2.5.0.jar propertyset-1.1.0.jar
oscore-2.2.0.jar
>
> I noticed that I don't need this for testing my workflow factory with
junit, that is outside the application server. A normal class-path with all
the needed jars is enough to run the test without problems.
> I cannot say if it's an application specific issue or a class-loading
specification in servlet API. My app-server is Macromedia JRun4 and usually
it honors the specification very strictly.
>
> Two final notes:
>
> 1. ConfigLoader in osworkflow loads the workflow factory class with
Class.forName(). Since the class is made of "static" methods I think this is
bad idea because this way ConfigLoader look for the workflow factory with
the class-loader who loaded the ConfigLoader itself. Instead it should use
Thread.currentThread().getContextClassLoader().loadClass(). (However this
didn't solved my NoClassDefFound problem)
>
> 2. The configuration design forces to have the osworkflow jars loaded by
the last class-loader in the application server class-loader hierarchy. In
fact osworkflow holds the config stuff in static variables. What about
reworking this in order to have an WorkflowInstanceFactory that loads and
holds the configuration in instance variables? The WorkflowInstanceFactory
could produce instances of Workflow objects and should be held by the
application or placed somewhere, maybe in a JNDI tree where the app could
retrieve it.
> In this "service oriented" way osworkflow jars could be loaded by some
ancient class-loader and each application could define its WorkflowFactory,
Store configuration and so on. (This would get a simple solution to my
NoClassDefFound problem).
>
>
> cheers
> stefano
>
> -----Messaggio originale-----
> Da: Pat Lightbody [mailto:[email protected]]
> Inviato: venerdì 27 giugno 2003 0.40
> A: [email protected]
> Oggetto: Re: [Opensymphony-developers] NoClassDefFoundError:
> com/opensymphony/workflow/loader/AbstractWorkflowFactory
>
>
> Could it be posssible you have an older osworkflow jar laying around
> somewhere?
>
> -Pat
>
> ----- Original Message -----
> From: "Travelli Stefano" <[email protected]>
> To: <[email protected]>
> Cc: <[email protected]>
> Sent: Thursday, June 26, 2003 3:19 AM
> Subject: [Opensymphony-developers] NoClassDefFoundError:
> com/opensymphony/workflow/loader/AbstractWorkflowFactory
>
>
> > I wrote a custom WorkflowFactory and make it works in a test
environment.
> >
> > Using the same config inside a web application it throws a strange
> NoClassDefFoundError
> >
> > java.lang.NoClassDefFoundError:
> com/opensymphony/workflow/loader/AbstractWorkflowFactory
> >         at java.lang.ClassLoader.defineClass0(Native Method)
> >         at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
> >         at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
> >         at
> jrunx.util.JRunURLClassLoader.defineClass(JRunURLClassLoader.java:187)
> >         at
> jrunx.util.JRunURLClassLoader.findClass(JRunURLClassLoader.java:152)
> >         at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
> >         at
> jrunx.util.JRunURLClassLoader.loadClass(JRunURLClassLoader.java:77)
> >         at java.lang.ClassLoader.loadClass(ClassLoader.java:292)
> >         at
> jrunx.util.JRunURLClassLoader.loadClass(JRunURLClassLoader.java:77)
> >         at
> jrunx.util.JRunURLClassLoader.loadClass(JRunURLClassLoader.java:69)
> >         at
> com.opensymphony.workflow.config.ConfigLoader.load(ConfigLoader.java:95)
> >         at
>
com.opensymphony.workflow.AbstractWorkflow.loadConfig(AbstractWorkflow.java:
> 523)
> >         at
>
com.opensymphony.workflow.AbstractWorkflow.<init>(AbstractWorkflow.java:81)
> >         at
>
com.opensymphony.workflow.basic.BasicWorkflow.<init>(BasicWorkflow.java:32)
> >         at jrun__home22ejspa._jspService(jrun__home22ejspa.java:1314)
> >         at
jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
> >         at jrun.jsp.JSPServlet.service(JSPServlet.java:110)
> >         at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
> >         at
> jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
> >         at
>
jrun.servlet.JRunRequestDispatcher.invokeNext(JRunRequestDispatcher.java:408
> )
> >         at
> jrun.servlet.JRunRequestDispatcher.include(JRunRequestDispatcher.java:340)
> >         at
> it.formula.momongaj.servlet.ViewManager.perform(ViewManager.java:112)
> >         at
> it.formula.momongaj.servlet.ViewManager.doGet(ViewManager.java:37)
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> >
> > ...
> > ...
> >
> > Don't stay hours  (as I did) looking for class-path issues. It's not
> ClassNotFoundException but NoClassDefFoundError and I'm quite sure that
> class-path is correct.
> >
> > Any ideas?
> >
> > stefano
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: INetU
> > Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> > _______________________________________________
> > Opensymphony-developers mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/opensymphony-developers
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Opensymphony-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-developers
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Opensymphony-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-developers



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.