2
votes

A corrupt dynamic content model to Alfresco (5.0.d CE) was deployed and activated.

By corrupt I mean, the content model is not valid, because a wrong type has been used which does not exist. Something like:

<property name="my:name">
    <type>test</type>
</property>

where "test" is obviously not valid - but the mistake in the model does not really matter here.

So, this content model was deployed dynamically to the

Repository > Data Dictionary > Models 

and then unfortunately activated via Alfresco API call (and not via Share UI; since the Share UI usually checks if a model is valid before actually allowing to activate it).

This causes the Alfresco repository to not start anymore but fail with the error:

2016-01-19 18:17:11,780 ERROR [org.springframework.web.context.ContextLoader] [localhost-startStop-1] Context initialization failed
org.alfresco.service.namespace.NamespaceException: A namespace prefix is not registered for uri my.test.model

on booting up.

My question is now how to deactivate this corrupt model again without having access to the running Alfresco repository instance, this not able to access the Data Dictionary > Models folder anymore.

I already tried to deploy a customModel.xml and custom-model-context.xml with the same model name etc. inside to the /alfresco/tomcat/shared/classes/alfresco/extension folder, but this does not seem to override the dynamic model. When booting up Alfresco, I still get the error above.

Any ideas anybody? Thanks!

Just for reference, this is the corrected dummy customModel.xml file that I use to override the old one, which simply just has the same model name as the corrupt one:

<?xml version="1.0" encoding="UTF-8"?>

<!-- Custom Model -->

<!-- Note: This model is pre-configured to load at startup of the Repository.  So, all custom -->
<!--       types and aspects added here will automatically be registered -->

<model name="my:testModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!-- Optional meta-data about the model -->
   <description>Custom Model</description>
   <author></author>
   <version>1.0</version>

   <imports>
      <!-- Import Alfresco Dictionary Definitions -->
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!-- Import Alfresco Content Domain Model Definitions -->
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!-- Introduction of new namespaces defined by this model -->
   <!-- NOTE: The following namespace custom.model should be changed to reflect your own namespace -->
   <namespaces>
      <namespace uri="my.test.model" prefix="my"/>
   </namespaces>

</model>
3

3 Answers

6
votes

Any model deployed to the Data Dictionary is stored as the raw XML file in the content store. The simplest solution in this case would be to locate that XML file and update its content with the corrected model that you have listed. You should be able to easily identify any model file by performing DB queries on the alf_node, alf_qname, alf_node_properties, alf_content_data and alf_content_url tables, i.e. doing a query like this

select alf_content_url.content_url
from alf_node
    left join alf_qname on alf_node.type_qname_id = alf_qname.id
    left join alf_node_properties on alf_node_properties.node_id = alf_node.id
    join alf_content_data on alf_content_data.id = alf_node_properties.long_value
    left join alf_content_url on alf_content_url.id = alf_content_data.content_url_id
where
    alf_qname.local_name = 'dictionaryModel'
    and alf_content_url.content_url is not null

After the model is corrected, a restart should work properly as only QNames are actually stored in the database but everything else is always re-loaded from the XML files (classpath or content store).

1
votes

I think that you could have done a grep to search the file in the file system. Too late now...

0
votes

My solution for now was to delete parts of the /alf_data/contentstore/ (I roughly knew at what time the model has been deployed). Since it's all in .bin format, I'm not sure what other files I deleted as well, but it weren't too many ;-) Afterwards, Alfresco at least starts again.