cancel
Showing results for 
Search instead for 
Did you mean: 

Building SomeCo Example Code with Maven SDK

rjoinson
Champ in-the-making
Champ in-the-making
Hi All,

I'm attempting to port the SomeCo example application to an AMP using the Maven Alfresco SDK:

https://artifacts.alfresco.com/nexus/content/repositories/alfresco-docs/alfresco-lifecycle-aggregato...

I've hit a problem to do with the build of the web client code and I'm hoping that someone might give me a pointer or two on solving my problem.

The steps I'm doing are:

(1) mvn archetype:generate -DarchetypeCatalog=https://artifacts.alfresco.com/nexus/content/groups public/archetype-catalog.xml -Dfilter=org.alfresco.maven.archetype:

– which downloads the SDK dependencies and the sample AMP Maven archetype.

(2) I'm testing that the base archetype builds and functions correctly, as detailed here:

https://artifacts.alfresco.com/nexus/content/repositories/alfresco-docs/alfresco-lifecycle-aggregato...

So far so good, the archetype builds and works out-of-the-box.

(3) Next, I'm adding the someco directories and files to my project structure, as described here,


http://wiki.alfresco.com/wiki/Maven_For_Dummies

… but of course, trying to stay close to the new Maven archetype structure as this article is out of date.

(4) I hit a problem when I attempt to build the project, caused by having either of the following two entries in src/main/config/module-context.xml:

<bean id="com.someco.someco-repo.bootstrapConfigBootstrap"
         class="org.alfresco.web.config.WebClientConfigBootstrap"
         init-method="init">
   <property name="configs">
      <list>
         <value>classpath:alfresco/module/${artifactId}/ui/web-client-config.xml</value>
      </list>
   </property>
</bean>
<bean id="com.someco.someco-repo.bootstrapMyAmpBundlesBean"
         class="org.alfresco.web.app.ResourceBundleBootstrap">
   <property name="resourceBundles">
      <list>
         <value>alfresco.module.${artifactId}.messages.webclient</value>
      </list>
   </property<
</bean>

These entries in module-content.xml appear to require that I add the following to my pom.xml, in order to get the project to build:

       <dependency>
         <groupId>${alfresco.groupId}</groupId>
         <artifactId>alfresco-web-client</artifactId>
         <version>4.2.c</version>
      </dependency>

The project now builds, but then I get the following run time error when I attempt to do 'mvn test':


org.alfresco.demoamp.test.DemoComponentTest  Time elapsed: 0.56 sec  <<< ERROR!
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:alfresco/application-context-core.xml]
Offending resource: class path resource [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/tx-cache-context.xml]
Offending resource: class path resource [alfresco/application-context-core.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from class path resource [alfresco/tx-cache-context.xml]; nested exception is javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@2e5bbd6] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.


– The error is confusing, because, afaik, org.apache.xerces.jaxp.DocumentBuilderFactoryImpl does
support XML schema

– My build environment is as follows:

Alfresco Maven SDK v4.2.c

– I'm running on the following JDK with Eclipse Kepler:

Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

– My development platform is a workstation running Red Hat Enterprise Linux Server release 6.4 (Santiago)

– I'm getting the same error using Eclipse Juno on Java 1.6.

– This problem only seems to affect web client code.  The SomeCo content model seems to work OK with the new Maven Archetype.


Has anyone else successfully built the someco example with the Alfresco Maven SDK and/or encountered and solved the same problem as me?

Hope you can help?

–Robin
4 REPLIES 4

mibesis
Champ on-the-rise
Champ on-the-rise
Post starting lines from

src/main/config/module-context.xml


And as a side-note: stay away from "AMP using the Maven Alfresco SDK".

rjoinson
Champ in-the-making
Champ in-the-making

Thanks for your reply, Maribor. Sorry about the delay in coming back.

Here's post you requested (1) and also the file it references (2).

Either of the commented out beans in (2) causes the error to be thrown when uncommented.

Best Regards,
-- Robin

(1)
<?xml version='1.0' encoding='UTF-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
<!-- This is filtered by Maven at build time, so that module name is single sourced. -->
<import resource="classpath:alfresco/module/${project.artifactId}/context/service-context.xml" />
</beans>

(2)

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans>

<!-- A simple class that is initialized by Spring -->
<bean id="changeme.exampleBean" class="org.alfresco.demoamp.Demo" init-method="init" />

<!-- A simple module component that will be executed once -->
<bean id="changeme.exampleComponent" class="org.alfresco.demoamp.DemoComponent" parent="module.baseComponent" >
<property name="moduleId" value="${project.artifactId}" /> <!-- See module.properties -->
<property name="name" value="exampleComponent" />
<property name="description" value="A demonstration component" />
<property name="sinceVersion" value="2.0" />
<property name="appliesFromVersion" value="2.0" />
<property name="nodeService" ref="NodeService" />
<property name="nodeLocatorService" ref="nodeLocatorService" />
</bean>
<bean id="com.someco.someco-repo.dictionaryBootstrap"
parent="dictionaryModelBootstrap"
depends-on="dictionaryBootstrap">
&ltproperty name="models">
<list>
<value>alfresco/module/${artifactId}/model/scModel.xml</value>
</list
</property>
<property name="labels">
<list>
<value>alfresco/module/${artifactId}/messages/scModel</value>
</list>
</property>
</bean>
<!-- bean id="com.someco.someco-repo.bootstrapConfigBootstrap"
class="org.alfresco.web.config.WebClientConfigBootstrap"
init-method="init">
<property name="configs">
<list>
<value>classpath:alfresco/module/${artifactId}/ui/web-client-config.xml</value>
</list>
</property>
</bean -->
<!--bean id="com.someco.someco-repo.bootstrapMyAmpBundlesBean"
class="org.alfresco.web.app.ResourceBundleBootstrap">
<property name="resourceBundles">
<list>
<value>alfresco.module.${artifactId}.messages.webclient</value>
</list>
</property>
</bean -->
</beans>

jpotts
World-Class Innovator
World-Class Innovator
I am going to convert the Alfresco Developer Series content tutorial to leverage Maven to build an AMP. If you've already done it, I'd rather just merge in your pull request than duplicate your work. Let me know if that's the case, otherwise, I'll get started and I'll update this thread when it is done and checked in to github.

Jeff

jpotts
World-Class Innovator
World-Class Innovator
I've migrated the custom content types tutorial to use Maven and AMPs. Take a look:
https://github.com/jpotts/alfresco-developer-series/tree/master/content

You might compare it to your pom.xml and see if it helps you figure out what the problem with your version is.

Jeff