cancel
Showing results for 
Search instead for 
Did you mean: 

Java Backed webscript: NoClassDefFoundError

peds
Champ in-the-making
Champ in-the-making
Hello,

I am trying to make a Java backed webscript, bascially modeled of a tutorial found here: http://ecmarchitect.com/images/articles/alfresco-webscripts/web-script-article.pdf.

I have a Java class that extends
org.alfresco.web.scripts.DeclarativeWebScript

and overrides a method:
executeImpl(org.alfresco.web.scripts.WebScriptRequest req, org.alfresco.web.scripts.WebScriptRequest status)

The problem I have is when starting Alfresco there is an error:
java.lang.NoClassDefFoundError: org/alfresco/scripts/WebScriptStatus

As far as I can tell, the tutorial I am using is from an older version of Alfresco (2.1?) that is not compatible with 2.9b, which I have.

I found here: http://forums.alfresco.com/en/viewtopic.php?f=4&t=10904, that the "WebScriptStatus" class has been renamed "Status." However, when I change the Java code to use
org.alfresco.web.scripts.Status
it "cannot be resolved to a type" and I get an error about not properly overriding the superclass method.

I have the 2.9b sdk and 2.9b alfresco, and I haven't had any luck finding documentation, so I'm hoping that someone here can point me in the right direction.

Thanks,
Ben
7 REPLIES 7

pmonks
Star Contributor
Star Contributor
It sounds like the code is being compiled against a different version of Alfresco than it's being running in.  Can you double check that the SDK and Alfresco server are indeed the exact same build of Alfresco 2.9?

Cheers,
Peter

peds
Champ in-the-making
Champ in-the-making
The alfresco version I am using is: Community Network - v2.9.0 (B 683)

I got the SDK from here :https://sourceforge.net/project/showfiles.php?group_id=143373&package_id=189441, and am using the file called: alfresco-community-sdk-2.9.0B.zip. Poking around I haven't seen a build associated with it, but all the files in the zip are dated 12/11/2007.

Thanks,
Ben

peds
Champ in-the-making
Champ in-the-making
On the files off subversion, there is a DeclarativeWebScript that has both versions of executeImpl, a deprecated version that takes a WebScriptStatus object and a new one that takes a Status object. How would I use that version in Alfresco, so it supports both? or else does anyone know which SDK supports the Status object? It seems strange to me that an Alfresco server and SDK released within days of each other would be incompatible.

peds
Champ in-the-making
Champ in-the-making
I have found a solution/workaround.

I create a project, and include the SDK AlfrescoEmbedded in the build path, but I also include an external JAR, which is the alfresco-web-framework.jar from the WEB-INF/lib directory. This works, though I doubt it is the best solution…

pmonks
Star Contributor
Star Contributor
If you're retrieving the SDK files from SVN then chances are you're compiling against a markedly different version of Alfresco than 2.9.  As best I recall, the last published build of 2.9 was released on April 18th, so there's been more than 3 months of v3.0 development work accumulating in SVN since then.

The basic rule is that you need to compile all of your extension code against the exact same version of the SDK as the version of Alfresco that you're running.

Cheers,
Peter

peds
Champ in-the-making
Champ in-the-making
Hi Peter,

I am using the sdk files from sourceforge, and the release dated 2007-12-09, with the Alfresco windows installer from sourceforge also dated 2007-12-09. Using the release jar to do my development has been fine.

Thanks,
Ben

slothrop
Champ in-the-making
Champ in-the-making
I'm having a similar but slightly different problem.  When I run the build script from Eclipse, the war file is assembled correctly.  When I run the MMT from the command line (from the Alfresco/bin directory), The war file is assembled without any error messages but gives this error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webscript.fr.starxpert.admin.user-rights.get' defined in file [C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\module\admin\module-context.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/alfresco/web/scripts/WebScriptStatus
Caused by: java.lang.NoClassDefFoundError: org/alfresco/web/scripts/WebScriptStatus]
when I start Alfresco.  This happens both when I use the alfresco-mmt.jar file that came with my v2.9B download and when I use the alfresco-mmt-2.1.0.jar file.  I can't see any difference between the war files that are assembled.

I am using the 2.9.0B version of the SDK.  One of my classes extends AbstractWebScript (it's closely based on the Demo Web Script that I downloaded from the Alfresco web site) but I can't override the method from AbstractWebScript that uses WebScriptStatus because it's final.  Anyway if it's a version compatibility problem, why does it work from Eclipse?