cancel
Showing results for 
Search instead for 
Did you mean: 

ServiceRegistry

tejaswini
Champ in-the-making
Champ in-the-making
i am trying to read a node using contentReader. for that i should have a ServiceRegistry. what i am doing is getting that with help of injection in .xml but after that i am getting exceptions. will anybody help me out?
thanks in advance.
15 REPLIES 15

mrogers
Star Contributor
Star Contributor
Not without details of the exception.  Your code would also help people to answer you.

The service registry is a hack for the times when you can't use injection, so you should not need it.

tejaswini
Champ in-the-making
Champ in-the-making
i am using  the web-config-custom.xml for refrences of nodeRef etc.  i am able to get the path,name and id of the node which i select or browse(the particular node i am interested in).now i want to get the content.g.text or picture inside. how i can do that?

thanks for the quick reply

tejaswini
Champ in-the-making
Champ in-the-making
good morning.,
   i am doing something like this—>
       class WebSettingBean implements Serializable
       {
         protected ServiceRegistry serviceRegistry;

   //getter and setter methods
        public void setActive(ActionEvent event) {
       
       //some actions and System.out.println()s
       }
     whn i run this code it works fine and i get the  output on console
     now i am adding two statements to evaluate() as
           ApplicationContext cxt = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");
           ServiceRegistry serviceRegistry=(ServiceRegistry)cxt.getBean("serviceRegistry");
 
the bean has configured in someco-action-context.xml as

<bean id="name" class="com.someco.bean.WebSettingsBean">
   <property name="serviceRegistry">
      <ref bean="ServiceRegistry"/>
   </property>
   <property name="repository">
      <ref bean="JCR.Repository"/>
   </property> 
</bean>

the web-client-config-custom conatains

<action id="web_enable">
            <permissions>
               <!– each permission can be an Allow or Deny check –>
               <permission allow="true">Write</permission>
            </permissions>
            <!– new code –>
            <evaluator>com.someco.action.evaluator.WebEnableEvaluator</evaluator>
            
            <label-id>enableWeb</label-id>
            <image>/images/icons/create_website.gif</image>
             <action-listener>#{WebSettingsBean.setActive}</action-listener>
            
            <action>dialog:executeScript</action>
            <action-listener>#{BrowseBean.setupSpaceAction}</action-listener>
            
            
            <params>
               <param name="id">#{actionContext.id}</param>
               <param name="active">true</param>
            </params>
         </action>


i am getting exceptions as

javax.faces.el.EvaluationException: Exception while invoking expression #{WebSettingsBean.setActive}
   org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:156)
   javax.faces.component.UICommand.broadcast(UICommand.java:89)
   javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
   javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
   org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
   org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
   org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
   javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
   org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   java.lang.reflect.Method.invoke(Method.java:597)
   org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   $Proxy196.doFilter(Unknown Source)
   org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
   org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   java.lang.reflect.Method.invoke(Method.java:597)
   org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   $Proxy196.doFilter(Unknown Source)
   org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
root cause

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ftsIndexerTrigger' defined in class path resource [alfresco/scheduled-jobs-context.xml]: Invocation of init method failed; nested exception is org.quartz.ObjectAlreadyExistsException: Unable to store Job with name: 'ftsIndexerJobDetail' and group: 'DEFAULT', because one already exists with this identification.
   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1175)
   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
   org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
   org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
   org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
   org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
   org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
   org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)
   com.someco.bean.WebSettingsBean.setActive(WebSettingsBean.java:191)
   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   java.lang.reflect.Method.invoke(Method.java:597)
   org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
   javax.faces.component.UICommand.broadcast(UICommand.java:89)
   javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
   javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
   org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
   org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
   org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
   javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
   org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   java.lang.reflect.Method.invoke(Method.java:597)
   org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   $Proxy196.doFilter(Unknown Source)
   org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
   org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   java.lang.reflect.Method.invoke(Method.java:597)
   org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   $Proxy196.doFilter(Unknown Source)
   org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
   

   hope this will give u an idea of my problem
  goodday!!!!

mrogers
Star Contributor
Star Contributor
You should not need to call the following code since the context is already loaded.

ApplicationContext cxt = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");
ServiceRegistry serviceRegistry=(ServiceRegistry)cxt.getBean("serviceRegistry");

tejaswini
Champ in-the-making
Champ in-the-making
good morning.,
  thnks…
   so how we can get the ServceRegistry?
  if its available then how to access? and if its present then whn i try———–>

  System.out.println("service regisrt="+serviceregistry);
why it gives null???

   will u pls tell me how to do that?
   its very urgent….


goodday!!!

tejaswini
Champ in-the-making
Champ in-the-making
good morning.,
   i am still stuck on the same problem and i dont know how to move further. let me know the way by which i can achieve that.
pls hurry up ….
   goodday!!!!

cheffilet
Champ in-the-making
Champ in-the-making
This is a realy bad idea on starting a separatly managed Beancontext!

This looks like using Alfresco Explorer JSF Client. This means you´re able to use FacesContext instance which is bound to the local thread!

ServiceRegistry serviceRegistry = org.alfresco.web.bean.repository.Repository.getServiceRegistry(FacesContext.getCurrentInstance());

cheffilet
Champ in-the-making
Champ in-the-making
This is a realy bad idea on starting a separatly managed Beancontext!

This looks like using Alfresco Explorer JSF Client. This means you´re able to use FacesContext instance which is bound to the local thread!

ServiceRegistry serviceRegistry = org.alfresco.web.bean.repository.Repository.getServiceRegistry(FacesContext.getCurrentInstance());

bwagner
Champ in-the-making
Champ in-the-making
any hint how to do this for JCR Repository? I tried the wiki example


final ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");
final Repository repository = (Repository) context.getBean("JCR.Repository");

which leads to errors