0
votes

maven-assembly plugin exports and executable jar called escomled-machine-learning-0.0.1-SNAPSHOT-jar-with-dependencies.jar. But when I try to run the jar, it gives me an exception:

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context] Offending resource: class path resource [appContext.xml]

My pom.xml file:

       <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version> 3.2.4.RELEASE</version>
        </dependency>
...

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>

                <configuration>
                        <tarLongFileMode>posix</tarLongFileMode>

                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.escomled.machinelearning.ml.Escomled_Streams_H2O_ML</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>assemble-all</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

My appContext.xml file:

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hz="http://www.hazelcast.com/schema/spring"
    xmlns:task="http://www.springframework.org/schema/task" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.hazelcast.com/schema/spring http://www.hazelcast.com/schema/spring/hazelcast-spring-3.2.xsd 
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd ">
    <context:annotation-config />
    <context:component-scan base-package="com.escomled" />
    <context:component-scan base-package="com.escomled.*" />
    <import resource="classpath*:config/blackBoard.xml" />
    <task:annotation-driven />

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>file:///home/escomled/escomled_server/config/escomled.properties</value>
            </list>
        </property>
    </bean>

    <bean id="blackboard" class="com.escomled.blackboard.impl.BlackboardImpl">
        <property name="hazelcastInstance" ref="hazelcastClient" />
    </bean>
</beans>

NOTE: I tried with maven-shade plugin, but no success.

1

1 Answers

0
votes

It is not problem with your maven assembly plugin, it is with Spring configuration. Check your xml file and look for namespace inclusion in tag on begging. Something like this. Also check if you have all spring jars

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">