A class meant for an alfresco behavior and its bean, how do they work and how are they deployed trough eclipse
Posted
by
MrHappy
on Stack Overflow
See other posts from Stack Overflow
or by MrHappy
Published on 2013-10-11T09:22:31Z
Indexed on
2013/10/25
9:55 UTC
Read the original article
Hit count: 1203
(This is a partial repost of a question asked 10 days ago because only 1 part was answered(not included), I've rewritten it into a way better question and added 3 more tags)
where do I put the DeleteAsset.class or why isn't it being found?
I've put the compiled class from the bin of the workspace of eclipse into
alfresco-4.2.c/tomcat/webapps/alfresco/WEB-INF/classes/com/openerp/behavior/
and right now it's giving me
Error loading class [com.openerp.behavior.DeleteAsset] for bean with name 'deletionBehavior' defined in URL [file:/home/openerp/alfresco-4.2.c/tomcat/shared/classes/alfresco/extension/cust??om-web-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: com/openerp/behavior/DeleteAsset (wrong name: DeleteAsset)
when I put it in there. (See bean below!)
The code(I'd trying to work without the model class, idk if I made any silly mistakes on that):
package com.openerp.behavior;
import java.util.List;
import java.net.*;
import java.io.*;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.apache.log4j.Logger;
//this is the newer version
//import com.openerp.model.openerpJavaModel;
public class DeleteAsset implements NodeServicePolicies.BeforeDeleteNodePolicy {
private PolicyComponent policyComponent;
private Behaviour beforeDeleteNode;
private NodeService nodeService;
public void init() {
this.beforeDeleteNode = new JavaBehaviour(this,"beforeDeleteNode",NotificationFrequency.EVERY_EVENT);
this.policyComponent.bindClassBehaviour(QName.createQName("http://www.someco.com/model/content/1.0","beforeDeleteNode"),
QName.createQName("http://www.someco.com/model/content/1.0","sc:doc"), this.beforeDeleteNode);
}
public setNodeService(NodeService nodeService){
this.nodeService = nodeService;
}
@Override
public void beforeDeleteNode(NodeRef node) {
System.out.println("beforeDeleteNode!");
try {
QName attachmentID1= QName.createQName("http://www.someco.com/model/content/1.0", "OpenERPattachmentID1"); // this could/shoul be defined in your OpenERPModel-class
int attachmentid = (Integer)nodeService.getProperty(node, attachmentID1);
//int attachmentid = 123;
URL oracle = new URL("http://0.0.0.0:1885/delete/%20?attachmentid=" + attachmentid);
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
//System.out.println(inputLine);
in.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
This is my full custom-web-context file:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN'
'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Registration of new models -->
<bean id="smartsolution.dictionaryBootstrap" parent="dictionaryModelBootstrap"
depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/extension/scOpenERPModel.xml</value>
</list>
</property>
</bean>
<!-- deletion of attachments within openERP when delete is initiated in Alfresco-->
<bean id="DeleteAsset" class="com.openerp.behavior.DeleteAsset" init-method="init">
<property name="NodeService">
<ref bean="NodeService" />
</property>
<property name="PolicyComponent">
<ref bean="PolicyComponent" />
</property>
</bean>
and content type: <type name="sc:doc"> <title>OpenERP Document</title> <parent>cm:content</parent>
There's also this when I open share
An error has occured in the Share component: /share/service/components/dashlets/my-sites.
It responded with a status of 500 - Internal Error.
Error Code Information: 500 - An error inside the HTTP server which prevented it from fulfilling the request.
Error Message: 09230001 Failed to execute script 'classpath*:alfresco/site-webscripts/org/alfresco/components/dashlets/my-sites.get.js': 09230000 09230001 Failed during processing of IMAP server status configuration from Alfresco: 09230000 Unable to retrieve IMAP server status from Alfresco: 404
Server: Alfresco Spring WebScripts - v1.2.0 (Release 1207) schema 1,000
Time: Oct 23, 2013 11:40:06 AM
Click here to view full technical information on the error.
Exception: org.alfresco.error.AlfrescoRuntimeException - 09230001 Failed during processing of IMAP server status configuration from Alfresco: 09230000 Unable to retrieve IMAP server status from Alfresco: 404
org.alfresco.web.scripts.SingletonValueProcessorExtension.getSingletonValue(SingletonValueProcessorExtension.java:108)
org.alfresco.web.scripts.SingletonValueProcessorExtension.getSingletonValue(SingletonValueProcessorExtension.java:59)
org.alfresco.web.scripts.ImapServerStatus.getEnabled(ImapServerStatus.java:49)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:606)
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
org.mozilla.javascript.JavaMembers.get(JavaMembers.java:117)
org.mozilla.javascript.NativeJavaObject.get(NativeJavaObject.java:113)
org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:1544)
org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1375)
org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1364)
org.mozilla.javascript.gen.c6._c1(file:/opt/alfresco-4.2.c/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets/my-sites.get.js:4)
org.mozilla.javascript.gen.c6.call(file:/opt/alfresco-4.2.c/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets/my-sites.get.js)
org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
org.mozilla.javascript.gen.c6._c0(file:/opt/alfresco-4.2.c/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets/my-sites.get.js:51)
org.mozilla.javascript.gen.c6.call(file:/opt/alfresco-4.2.c/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets/my-sites.get.js)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
org.mozilla.javascript.gen.c6.call(file:/opt/alfresco-4.2.c/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets/my-sites.get.js)
org.mozilla.javascript.gen.c6.exec(file:/opt/alfresco-4.2.c/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets/my-sites.get.js)
org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScriptImpl(JSScriptProcessor.java:318)
org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:192)
org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1305)
org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:70)
org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:240)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
org.springframework.extensions.webscripts.WebScriptProcessor.executeBody(WebScriptProcessor.java:310)
org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
org.springframework.extensions.surf.render.RenderService.process(RenderService.java:599)
org.springframework.extensions.surf.render.RenderService.renderSubComponent(RenderService.java:505)
org.springframework.extensions.surf.render.RenderService.renderChromeInclude(RenderService.java:1284)
org.springframework.extensions.directives.ChromeIncludeFreeMarkerDirective.execute(ChromeIncludeFreeMarkerDirective.java:81)
freemarker.core.Environment.visit(Environment.java:274)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.IfBlock.accept(IfBlock.java:82)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.Environment.process(Environment.java:199)
org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:438)
org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
org.springframework.extensions.surf.render.RenderService.processRenderable(RenderService.java:204)
org.springframework.extensions.surf.render.bean.ChromeRenderer.body(ChromeRenderer.java:95)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
org.springframework.extensions.surf.render.bean.ChromeRenderer.render(ChromeRenderer.java:86)
org.springframework.extensions.surf.render.RenderService.processComponent(RenderService.java:432)
org.springframework.extensions.surf.render.bean.ComponentRenderer.body(ComponentRenderer.java:94)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
org.springframework.extensions.surf.render.RenderService.renderComponent(RenderService.java:961)
org.springframework.extensions.surf.render.RenderService.renderRegionComponents(RenderService.java:900)
org.springframework.extensions.surf.render.RenderService.renderChromeInclude(RenderService.java:1263)
org.springframework.extensions.directives.ChromeIncludeFreeMarkerDirective.execute(ChromeIncludeFreeMarkerDirective.java:81)
freemarker.core.Environment.visit(Environment.java:274)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.Environment.process(Environment.java:199)
org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:438)
org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
org.springframework.extensions.surf.render.RenderService.processRenderable(RenderService.java:204)
org.springframework.extensions.surf.render.bean.ChromeRenderer.body(ChromeRenderer.java:95)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
org.springframework.extensions.surf.render.bean.ChromeRenderer.render(ChromeRenderer.java:86)
org.springframework.extensions.surf.render.bean.RegionRenderer.body(RegionRenderer.java:99)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
org.springframework.extensions.surf.render.RenderService.renderRegion(RenderService.java:851)
org.springframework.extensions.directives.RegionDirectiveData.render(RegionDirectiveData.java:91)
org.springframework.extensions.surf.extensibility.impl.ExtensibilityModelImpl.merge(ExtensibilityModelImpl.java:408)
org.springframework.extensions.surf.extensibility.impl.AbstractExtensibilityDirective.merge(AbstractExtensibilityDirective.java:169)
org.springframework.extensions.surf.extensibility.impl.AbstractExtensibilityDirective.execute(AbstractExtensibilityDirective.java:137)
freemarker.core.Environment.visit(Environment.java:274)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
freemarker.core.Environment.visit(Environment.java:428)
freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
freemarker.core.Environment.visit(Environment.java:428)
freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.Macro$Context.runMacro(Macro.java:172)
freemarker.core.Environment.visit(Environment.java:614)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.IfBlock.accept(IfBlock.java:82)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.Macro$Context.runMacro(Macro.java:172)
freemarker.core.Environment.visit(Environment.java:614)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.Environment$3.render(Environment.java:246)
org.springframework.extensions.surf.extensibility.impl.DefaultExtensibilityDirectiveData.render(DefaultExtensibilityDirectiveData.java:119)
org.springframework.extensions.surf.extensibility.impl.ExtensibilityModelImpl.merge(ExtensibilityModelImpl.java:408)
org.springframework.extensions.surf.extensibility.impl.AbstractExtensibilityDirective.merge(AbstractExtensibilityDirective.java:169)
org.springframework.extensions.surf.extensibility.impl.AbstractExtensibilityDirective.execute(AbstractExtensibilityDirective.java:137)
freemarker.core.Environment.visit(Environment.java:274)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.Environment.visit(Environment.java:406)
freemarker.core.BodyInstruction.accept(BodyInstruction.java:93)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.Macro$Context.runMacro(Macro.java:172)
freemarker.core.Environment.visit(Environment.java:614)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:221)
freemarker.core.Environment.process(Environment.java:199)
org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:438)
org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
org.springframework.extensions.surf.render.RenderService.processTemplate(RenderService.java:721)
org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.body(TemplateInstanceRenderer.java:140)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
org.springframework.extensions.surf.render.bean.PageRenderer.body(PageRenderer.java:85)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
org.springframework.extensions.surf.render.RenderService.renderPage(RenderService.java:762)
org.springframework.extensions.surf.mvc.PageView.dispatchPage(PageView.java:411)
org.springframework.extensions.surf.mvc.PageView.renderView(PageView.java:306)
org.springframework.extensions.surf.mvc.AbstractWebFrameworkView.renderMergedOutputModel(AbstractWebFrameworkView.java:316)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:74)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:374)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:1771)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:724)
Exception: org.springframework.extensions.webscripts.WebScriptException - 09230000 09230001 Failed during processing of IMAP server status configuration from Alfresco: 09230000 Unable to retrieve IMAP server status from Alfresco: 404
org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScriptImpl(JSScriptProcessor.java:324)
Exception: org.springframework.extensions.webscripts.WebScriptException - 09230001 Failed to execute script 'classpath*:alfresco/site-webscripts/org/alfresco/components/dashlets/my-sites.get.js': 09230000 09230001 Failed during processing of IMAP server status configuration from Alfresco: 09230000 Unable to retrieve IMAP server status from Alfresco: 404
org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:200)
UPDATE: I think I've found the problem. Being a newbie to eclipse I haven't managed the dependecies well I think. Could anyone link me to a tutorial describing how to get org.alfresco.repo.node.NodeServicePolicies;
as seen in import org.alfresco.repo.node.NodeServicePolicies;
and other such imports into eclipse, I've got the alfresco source from svn but the tutorial I've found seems to fail me.
java/lang/Error\00\F1Unresolved compilation problems:
The declared package "com.openerp.behavior" does not match the expected package "java.com.openerp.behavior"
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.alfresco cannot be resolved
The import org.apache cannot be resolved
The import com.openerp cannot be resolved
NodeServicePolicies cannot be resolved to a type
PolicyComponent cannot be resolved to a type
Behaviour cannot be resolved to a type
NodeService cannot be resolved to a type
Behaviour cannot be resolved to a type
JavaBehaviour cannot be resolved to a type
NotificationFrequency cannot be resolved to a variable
PolicyComponent cannot be resolved to a type
QName cannot be resolved
QName cannot be resolved
Behaviour cannot be resolved to a type
Return type for the method is missing
NodeService cannot be resolved to a type
NodeService cannot be resolved to a type
NodeRef cannot be resolved to a type
QName cannot be resolved to a type
QName cannot be resolved
NodeService cannot be resolved to a type
\00\00\00\00\00(Ljava/lang/String;)V\00LineNumberTable\00LocalVariableTable\00this\00'Ljava/com/openerp/behavior/DeleteAsset;\00init\008Unresolved compilation problems:
Behaviour cannot be resolved to a type
JavaBehaviour cannot be resolved to a type
NotificationFrequency cannot be resolved to a variable
PolicyComponent cannot be resolved to a type
QName cannot be resolved
QName cannot be resolved
Behaviour cannot be resolved to a type
\00(LNodeRef;)V\00\00\B0Unresolved compilation problems:
NodeRef cannot be resolved to a type
QName cannot be resolved to a type
QName cannot be resolved
NodeService cannot be resolved to a type
© Stack Overflow or respective owner