Search code examples
javaspring

Spring <jee:jndi-lookup> tag & `SAXParseException`


Here are the excerpts of my Spring context .xml file.

    <?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/batch"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

    <beans:import
        resource="classpath:com/batch/jobs/data-source-context.xml" />

    <job id="xxxx">
        <step id="loadRecord">
            <tasklet>
                <chunk reader="dtaFileItemReader" writer="dtaGroupWriter"
                    commit-interval="${job.commit.interval}" />
            </tasklet>
        </step>
    </job>              
    <jee:jndi-lookup id="dataSource" jndi-name="jdbc"></jee:jndi-lookup>        

    <beans:bean id="incrementerParent" class="${batch.database.incrementer.class}">
        <beans:property name="dataSource" ref="dataSource" />
        <beans:property name="incrementerName" value="ID" />
    </beans:bean>

I get an exception saying that:

nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jee:jndi-lookup'

Solution

  • You are mixing Spring (beans, aop and tx) 2.0 with the JEE schema from Spring 3.0, which will probably lead to issues.