cancel
Showing results for 
Search instead for 
Did you mean: 

Exception Starting Server afte Spring framework Registration

oluwasegzy
Champ in-the-making
Champ in-the-making
Can somebody help me with how to resolve this issue,

I am using a java class as my controller for webscript.

I registered my Spring framework configuration file as shown below

<?xml version=’1.0’ encoding=’UTF-8’? >
<!DOCTYPE beans PUBLIC ‘-//SPRING//DTD BEAN 2.0//EN’
http://www.springframework.org/dtd/spring-beans-2.0.dtd’>
<beans>
<bean id="webscript.org.example.javadir.get"
class="org.example.JavaDir" parent="webscript">
<property name="repository" ref="repositoryHelper"/>
</bean>
</beans>

but i have this exception when starting my Alfresco Tomcat Server

Offending resource: class path resource [alfresco/application-context.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\javadir-context.xml]; nested exception is org.apache.xerces.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
   at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
   at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
10 REPLIES 10

mikeh
Star Contributor
Star Contributor
Don't use an editor that inserts "smart quotes".

Thanks,
Mike

oluwasegzy
Champ in-the-making
Champ in-the-making
Thanks MikeH,

I have used a better editor and it seems to have worked but am still having this exception when launching the Alfresco application


[file:/C:/Alfresco/tomcat/shared/classes/alfresco/extension/custom-vti.properties]
11:04:26,507  INFO  [management.subsystems.ChildApplicationContextFactory] Startup of 'Replication' subsystem, ID: [Replication, default] complete
11:04:36,187  INFO  [module.vti.VtiServer] Vti server started successfully on port: 7070
11:05:34,997 UserSmiley Frustratedystem INFO  [extensions.webscripts.AbstractRuntimeContainer] Initialised Repository Web Script Container (in 3322.1367ms)
11:05:35,183  ERROR [web.context.ContextLoader] Context initialization failed
java.lang.ClassCastException: org.example.JavaDir cannot be cast to org.springframework.extensions.webscripts.AbstractWebScript
   at org.springframework.extensions.webscripts.DeclarativeRegistry.initWebScripts(DeclarativeRegistry.java:462)
   at org.springframework.extensions.webscripts.DeclarativeRegistry.reset(DeclarativeRegistry.java:178)
   at org.springframework.extensions.webscripts.AbstractRuntimeContainer.reset(AbstractRuntimeContainer.java:242)
   at org.alfresco.repo.web.scripts.RepositoryContainer.init(RepositoryContainer.java:591)
   at org.alfresco.repo.web.scripts.RepositoryContainer.reset(RepositoryContainer.java:565)
   at org.alfresco.repo.web.scripts.RepositoryContainer$4.doWork(RepositoryContainer.java:519)


Before this exception, there were some ClassNotFoundException i encountered, which i had to paste the appropriate jar into the  classpath of Alfresco

mikeh
Star Contributor
Star Contributor
java.lang.ClassCastException: org.example.JavaDir cannot be cast to org.springframework.extensions.webscripts.AbstractWebScript
Looks like your class definition is wrong. Difficult to debug without source. I suggest you look at our code and see what you've done wrong.

Thanks,
Mike

oluwasegzy
Champ in-the-making
Champ in-the-making
I dont seems to find a fault with the source code,



package org.example;

import java.util.HashMap;
import java.util.Map;
import org.alfresco.repo.model.Repository;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.scripts.Cache;
import org.alfresco.web.scripts.DeclarativeWebScript;
import org.alfresco.web.scripts.Status;
import org.alfresco.web.scripts.WebScriptException;
import org.alfresco.web.scripts.WebScriptRequest;

public class JavaDir extends DeclarativeWebScript {
   private Repository repository;

   public void setRepository(Repository repository) {
      this.repository = repository;
   }
   public Repository getRepository(){
      return repository;
   }

what am i actually doing wrong

mrogers
Star Contributor
Star Contributor
DeclarativeWebScript is in org.springframework.extensions.webscripts so your "import" is incorrect.

I'm surprised you can even compile your code, I suspect you are compiling against an old version.

oluwasegzy
Champ in-the-making
Champ in-the-making
The DeclarativeWebScript class i extended is the same class on the code in the Alfresco Book am using, it got imported from
org.alfresco.web.scripts

Also from what i read, the DeclarativeWebScript  class from org.alfresco.web.scripts is one of the two JAVA classes that implement the most difficult part of the interface org.alfresco.web.scripts.WebScript.

I dont understand it when u said i should import and use  DeclarativeWebScript  from org.Springframework.extensions.script


Am compiling the code against the alfresco-labs-sdk-3c SDK

mrogers
Star Contributor
Star Contributor
You need to use the right / matching version of SDK.  

I suspect you are using alfresco > 3.3 and your SDK is not for that version.   In particular the web script framework moves to SpringSource in versions > 3.3.

The Labs 3c SDK is for Labs 3c only  :!:

oluwasegzy
Champ in-the-making
Champ in-the-making
Thanks,

can i get a link to the Alfresco 3.4d SDK,  thats the version of alfresco am using

mrogers
Star Contributor
Star Contributor
Can you not see the big orange download icon in the top right hand corner?

http://wiki.alfresco.com/wiki/Community_file_list_3.4.d