Весенняя загрузка ActiveMQ JMS показывает, что ресурс не существует: ресурс ServletContext [/xsd/product.xsd] - PullRequest
0 голосов
/ 11 ноября 2018

Ниже приводится мой JMSConfig.java

@Configuration
public class JMSConfig {

    private static final Logger logger = LoggerFactory.getLogger(JMSConfig.class);

    @Bean
    public MarshallingMessageConverter createMarshallingMessageConverter(final Jaxb2Marshaller jaxb2Marshaller) {
        return new MarshallingMessageConverter(jaxb2Marshaller);
    }

    @Bean
    public Jaxb2Marshaller createJaxb2Marshaller(@Value("${context.path}") final String contextPath,
                                             @Value("${schema.location}") final Resource schemaResource) {

        Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
        jaxb2Marshaller.setContextPath(contextPath);
        try {
        jaxb2Marshaller.setSchema(schemaResource);
        }catch(Exception e) {
            logger.error("Error occurred while getting xsd resource for jaxbsMarshaller. Reason :"+e);
        }

        Map<String, Object> properties = new HashMap<>();
        properties.put(Marshaller.JAXB_FORMATTED_OUTPUT, true);

        jaxb2Marshaller.setMarshallerProperties(properties);
        return jaxb2Marshaller;
    }

}

Ниже приведен мой файл схемы потребителя:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.admin.com/product"
    xmlns:tns="http://www.example.org/product"
    elementFormDefault="qualified">

    <element name="product">
        <complexType>
            <sequence>
                <element name="productName" type="string"></element>
            </sequence>
            <attribute name="productId" type="string" use="required"></attribute>
        </complexType>
    </element>
</schema>

Ниже мое приложение. Свойства

# ===============================
# = ACTIVEMQ & JMS 
# ===============================
spring.activemq.broker-url=tcp://localhost:61616
outbound.endpoint=ORDER.PROCESSING.D
context.path=com.admin.product
schema.location=xsd/product.xsd

Ниже приводится мой pom.xml:

<dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-jms</artifactId>
            <version>5.1.0.RELEASE</version>
        </dependency>
        <!-- These two dependency is for JMS messeging -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-broker</artifactId>
        </dependency>

        <dependency>
            <groupId>com.admin</groupId>
            <artifactId>admin1.5.7</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
        </dependency>

Есть предложения по устранению этой ошибки?

Когда я запускаю приложение весенней загрузки для издателя, я вижу ошибку не найденного ресурса, который, в соответствии с этим, не может найти файл схемы, который является product.xsd.

Также я добавил зависимость от потребителей в моих издателях pom.xml:

<dependency>
            <groupId>com.admin</groupId>
            <artifactId>admin1.5.7</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
...