cancel
Showing results for 
Search instead for 
Did you mean: 

HTTPConfigSource??

soeursourire
Champ in-the-making
Champ in-the-making
Hi!

I am trying to read a XML file that is stored in Company_Home by its http url however I have this error :

caused by:
org.alfresco.config.ConfigException: Failed to parse config stream

caused by:
org.dom4j.DocumentException: Error on line 31 of document : Open quote is expected for attribute "width" associated with an element type "table". Nested exception: Open quote is expected for attribute "width" associated with an element type "table".


I get this error when I am doing this:
XMLConfigService svc = new XMLConfigService(new HTTPConfigSource(http://localhost:8080/alfresco/download/direct/workspace/SpacesStore/4cc5bdbc-c323-11da-9641-7f540d7...));
svc.init();


Although I do not have error while doing this with the same xml file:

XMLConfigService svc = new XMLConfigService(new FileConfigSource("./src/projects/web-client/source/web/WEB-INF/EF_Config_Pages.xml"));
svc.init();       


Cannot I use XMLConfigService with a url? What do I do wrong here?
Thanks
34 REPLIES 34

soeursourire
Champ in-the-making
Champ in-the-making
Even while doing this that does not work:

List<String> configFile = new ArrayList<String>(1);
configFile.add("http://localhost:8080/alfresco/download/direct/workspace/SpacesStore/4cc5bdbc-c323-11da-9641-7f540d7...");
XMLConfigService svc = new XMLConfigService(new HTTPConfigSource(configFile));

soeursourire
Champ in-the-making
Champ in-the-making
Should I use this url instead:
"http://localhost:8080/alfresco/EF_Config_Pages.xml" ?

Because while doing that:
List<String> configFile = new ArrayList<String>(1);

String xmlToParse = "http://localhost:8080/alfresco/EF_Config_Pages.xml";

configFile.add(xmlToParse);

XMLConfigService svc = new XMLConfigService(new HTTPConfigSource(configFile));
       
svc.init();   –>this is not null !
       
Config config = svc.getConfig("DefaultLanguage");
        –> this is not null !
       
children = config.getConfigElement("children");
        –>this is null and I do not understand why?

My XML contains this:
<alfresco-config>
<!–  Default language  –>
<config evaluator="string-compare" condition="DefaultLanguage">
<children>
  <theDefaultLanguage>en</theDefaultLanguage>
  </children>
  </config>
[…]

Thanks for your answer.

gavinc
Champ in-the-making
Champ in-the-making
When using the download servlet, were you using an authenticated session? It may be that the request was actually sending the HTML for the login page?

In your last attempt, it certainly looks OK. From what I can see the line
children = config.getConfigElement("children");
should give you back something i.e. not null.

The config service has a fair bit of debugging so you could try turning that on. In projects/core/source/java/log4j.properties add the following lines:


log4j.logger.org.alfresco.config=debug
log4j.logger.org.alfresco.web.config=debug

Could you possibly run your simple test you have above and post the debug output?

soeursourire
Champ in-the-making
Champ in-the-making
Thanks a lot for your answer.
In my programmation I am doing the following in a class defined in faces-beans and that gets the authentication service:

String configPageXMLPath = "http://localhost:8080/alfresco/EF_Config_Pages.xml";

this.pers_defaultLanguage = xmlService.getDefaultLanguage(configPageXMLPath).toString();

where xmlService is a simple class that calls the code above. I do not define this class in the application-context.xml and I do not call the authenticationService… Should I?


Here is the debug:

javax.faces.el.EvaluationException: Exception while invoking expression #{EFE_NewUserWizard.startWizard}
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
at javax.faces.component.UICommand.broadcast(UICommand.java:86)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
at org.alfresco.web.app.servlet.AlfrescoFacesServlet.service(AlfrescoFacesServlet.java:49)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:73)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.NullPointerException
at org.alfresco.web.config.EF_XMLParse.getDefaultLanguage(EF_XMLParse.java:92)
at org.alfresco.web.bean.wizard.EF_NewUserWizard.init(EF_NewUserWizard.java:297)
at org.alfresco.web.bean.wizard.AbstractWizardBean.startWizard(AbstractWizardBean.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
… 32 more

Thanks again

gavinc
Champ in-the-making
Champ in-the-making
I need you to turn on debugging for the config service and post the debug output to determine why you get the NullPointerException.

Alternatively, all you are doing is trying to get some config setting so is there any reason why you can not put the custom config in the web-client-config-custom.xml file? Or does it HAVE to be read via a URL?

If you are using Tomcat place the web-client-config-custom.xml file in tomcat/shared/classes/alfresco/extenstion and it will get read in automatically.

You can then do the following in your code:


ConfigService configSvc = Application.getConfigService(FacesContext.getCurrentInstance());
Config config = svc.getConfig("DefaultLanguage");
ConfigElement children = config.getConfigElement("children");

This wiki page has some more details on web-client-config-custom.xml: http://wiki.alfresco.com/wiki/Web_Client_Configuration_Guide

Hope this helps.

soeursourire
Champ in-the-making
Champ in-the-making
Thanks.
I added the code you gave me in log4j.properties
log4j.logger.org.alfresco.config=debug
log4j.logger.org.alfresco.web.config=debug

Is it not sufficiant to turn it on?

For this config file I could effectively put it in the custom config, however I need to get some XML files stored in the space of admin and to parse them. If I am using contentService to get it I will obtain a OutputStream but I will not be able to parse it. So I was trying to get them by an url. I have to store these files in a space and version them because they will change. So I did not find other solution to get them. And I will also need to write in this XML files, is it possible with your XMLConfigService?

Thanks again for your help.

gavinc
Champ in-the-making
Champ in-the-making
Yes, it should be sufficient to turn it on, do you not see any extra output in alfresco.log?

Yes, everything you say is possible with XMLConfigService, i was just ensuring there wasn't an easier way to achieve what you wanted.

Both ways you have mentioned before, the download servlet and the more direct URL should work if you are calling them from within another bean. Let's get the debug output and see whats happening.

soeursourire
Champ in-the-making
Champ in-the-making
Which methods can be used in XMLConfig to write into an XML?

I was looking at server.log before not alfresco.log. I removed my alfresco.log from WebClient, Repository and Core but then while doing my operations no log is created.

And in server.log I have this (but I guess it is not what you are looking for?):

java.lang.NullPointerException
   at org.alfresco.web.bean.wizard.EF_NewUserWizard.getConnectedUserName(EF_NewUserWizard.java:249)
   at org.alfresco.web.bean.wizard.EF_NewUserWizard.init(EF_NewUserWizard.java:290)
   at org.alfresco.web.bean.wizard.AbstractWizardBean.startWizard(AbstractWizardBean.java:114)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
   at javax.faces.component.UICommand.broadcast(UICommand.java:86)
   at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
   at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
   at org.alfresco.web.app.servlet.AlfrescoFacesServlet.service(AlfrescoFacesServlet.java:49)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:73)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
   at java.lang.Thread.run(Thread.java:595) 

gavinc
Champ in-the-making
Champ in-the-making
No, it's alfresco.log I'm looking for.

If you change <projects>/core/source/java/log4j.properties and rebuild the WAR then redeploy.

Start Tomcat and run your test again, you should find alfresco.log in the Tomcat bin directory.

alfresco.log files in the repository, web client etc. directories are created when you run unit tests.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.