简体   繁体   English

API alfresco repository version 6.X or 7.X 应用上下文的初始化问题

[英]initialization problem of the application context of the API alfresco repository version 6.X or 7.X

When I want to initialize the application context of the Alfresco repository version 6.X or 7.X (I have tested the latest version 7.78 and the version 6.57), I have these errors:当我想初始化 Alfresco 存储库版本 6.X 或 7.X 的应用程序上下文(我已经测试了最新版本 7.78 和版本 6.57)时,出现以下错误:

Configuration problem: Failed to import bean definitions from URL location [classpath:alfresco/application-context-core.xml]配置问题:无法从 URL 位置导入 bean 定义 [classpath:alfresco/application-context-core.xml]

Offending resource: class path resource [alfresco/application-context.xml];违规资源:类路径资源 [alfresco/application-context.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:alfresco/core-services-context.xml]嵌套异常是 org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:无法从 URL 位置导入 bean 定义 [classpath:alfresco/core-services-context.xml]

Offending resource: class path resource [alfresco/application-context-core.xml];违规资源:类路径资源 [alfresco/application-context-core.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 587 in XML document from class path resource [alfresco/core-services-context.xml] is invalid;嵌套异常是 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自类路径资源 [alfresco/core-services-context.xml] 的 XML 文档中的第 587 行无效; nested exception is org.xml.sax.SAXParseException;嵌套异常是 org.xml.sax.SAXParseException; lineNumber: 587;行号:587; columnNumber: 107;列数:107; cvc-datatype-valid.1.2.1: 'cm:constraintRegistry' is not a valid value for 'NCName'. cvc-datatype-valid.1.2.1:“cm:constraintRegistry”不是“NCName”的有效值。

My code is very simple:我的代码很简单:

public class AlfrescoApp {

    public static void main(String[] args) {

        try {
            ServiceRegistry serviceRegistry = null;
            ApplicationContext context = null;
            context = new ClassPathXmlApplicationContext("alfresco/application-context.xml");

            serviceRegistry = (ServiceRegistry) context.getBean(ServiceRegistry.SERVICE_REGISTRY);
            AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();

            NodeService nodeService = serviceRegistry.getNodeService();

        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }

}

and this is the content of my POM.xml file:这是我的 POM.xml 文件的内容:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.alfresco.project</groupId>
    <artifactId>white_box_project_alfresco</artifactId>
      <packaging>jar</packaging>
      <version>1.0-SNAPSHOT</version>

  <dependencies>
        <dependency>
               <groupId>org.alfresco</groupId>
              <artifactId>alfresco-repository</artifactId>
              <version>7.78</version>
        </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.32</version>
            </dependency>          

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>4.1.0.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>4.1.0.RELEASE</version>
            </dependency>

             <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>4.1.0.RELEASE</version>
            </dependency>
           <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
                <version>4.1.0.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>4.1.0.RELEASE</version>
            </dependency>
           <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-expression</artifactId>
                <version>4.1.0.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>3.2.14.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>4.1.0.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring</artifactId>
                <version>2.5</version>
            </dependency>
  </dependencies>

    <build>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>Cp1252</encoding>
                </configuration>
            </plugin>
        </plugins>

    </build>

<repositories>
        <repository>
            <id>alfresco-public</id>
            <url>https://artifacts.alfresco.com/nexus/content/repositories/public/</url>
        </repository>
    <repository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Repository Group</name>
      <url>http://repository.jboss.org/nexus/content/groups/public/</url>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <updatePolicy>daily</updatePolicy>
      </snapshots>
    </repository>
  </repositories>

</project>

I don't know why I have these errors with this above code.我不知道为什么上面的代码会出现这些错误。 Please could you help me to solve this problem?请你能帮我解决这个问题吗?

The problem is that you mixed up various versions of the Spring framework jar-s in your pom.xml.问题是您在 pom.xml 中混合了 Spring 框架 jar-s 的各种版本。 To fix this, simply remove all unnecessary dependencies from your pom.xml and don't use old versions of Spring, like that "all-in-one" 2.5 version.要解决此问题,只需从 pom.xml 中删除所有不必要的依赖项,并且不要使用旧版本的 Spring,例如“一体机”2.5 版本。

The old Spring versions seem not to allow ":" in bean identifiers ( NCName type forbids this, to be concrete).旧的 Spring 版本似乎不允许在 bean 标识符中使用“:”(具体来说,NCName类型禁止这样做)。 This is the case of one of the beans defined inside "alfresco/core-services-context.xml" which is mentioned in the errors output you supplied:这是在您提供的错误输出中提到的“alfresco/core-services-context.xml”中定义的bean之一的情况:

<bean id="cm:constraintRegistry" class="org.alfresco.repo.dictionary.constraint.ConstraintRegistry" />

If you look at the pom.xml of the alfresco-repository-7.78.jar, you will see it relies on Spring version 5.1.8.RELEASE - to avoid problems, try to use the very same version in your project as well.如果您查看 alfresco-repository-7.78.jar 的 pom.xml,您将看到它依赖于 Spring 版本 5.1.8.RELEASE - 为避免出现问题,请尝试在您的项目中也使用完全相同的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Infinispan xml配置从6.x迁移到7.x - Migrating Infinispan xml configuration from 6.x to 7.x Java 7.x中的validateTree不起作用(在Java 6.x中很好) - validateTree in Java 7.x doesnt work (in Java 6.x was fine) JSF 2.0可以与Websphere应用程序服务器版本7.x一起使用 - Can JSF 2.0 be used with Websphere application server version 7.x 从 JBoss 4.2.x 升级到 JBoss 5.x、6.x、7.x 和 WildFly 8.x 的好处(和提示)? - Benefits (and tips) of an upgrade from JBoss 4.2.x to JBoss 5.x, 6.x, 7.x and WildFly 8.x? Kit Kat与所有更高版本5.x,6.x和7.x之间的Android内容提供商冲突 - Android content-provider conflict between Kit Kat and all later versions, 5.x, 6.x and 7.x 上下文初始化失败-Alfresco - Context initialization failure - Alfresco 切换上下文时未定义Android 6.x Webview - Android 6.x Webview undefined when switching context Android 6.x中的权限 - Permissions in android 6.x Jboss EAP 6.x上的org.springframework.ws和Xalan问题 - org.springframework.ws and Xalan problem on Jboss EAP 6.x Alfresco上下文初始化失败:NoClassDefFoundError - Alfresco Context initialization failed : NoClassDefFoundError
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM