Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

spring

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'
like image 685
nobody Avatar asked Aug 22 '11 12:08

nobody


People also ask

Is JNDI used in spring?

JPA Configuration – Model, DAO and Service. With this, you have everything you need in order to use your JNDI datasource in your Spring application.


3 Answers

You have an incorrect namespace declaration somewhere, probably for beans as well as JEE.

As per the documentation, the JEE XMLNS declaration should be:

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

<!-- <bean/> definitions here -->

</beans>
like image 73
Alex Avatar answered Oct 30 '22 14:10

Alex


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

like image 25
beny23 Avatar answered Oct 30 '22 14:10

beny23


Looks like spring did not found the org/springframework/ejb/config/spring-jee-3.0.xsd at runtime.

This file is located in spring-context-3.0.x.RELESE.jar, check that this file is deployed correct.

like image 43
Ralph Avatar answered Oct 30 '22 13:10

Ralph