Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Spring: Error message "no declaration can be found for element 'util:constant'

Tags:

I'm trying to use util-constant for ioc but I'm getting the following error message:

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'util:constant'.

All of the spring 3.1.1 dist jars are in my classpath and I was able to successfully run my program prior to making the changes that included the use of the util:constant tag.

Here's my ioc xml file:

 <beans xmlns="http://www.springframework.org/schema/beans"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:util="http://www.springframework.org/schema/util"  xmlns:tool="http://www.springframework.org/schema/tool"  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">   <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">     <property name="locations">         <value>classpath:config.properties</value>     </property> </bean>  <bean id="main" class="pikefin.Main"> <property name="executorSample" ref="executorSample"/> </bean>   <bean id="executorSample" class="pikefin.ExecutorSample">     <constructor-arg ref="threadPoolExecutor" />  </bean>   <bean id="threadPoolExecutor" class="java.util.concurrent.ThreadPoolExecutor">     <constructor-arg index="0" value="2"/>     <constructor-arg index="1" value="2"/>     <constructor-arg index="2" value="10"/>     <constructor-arg index="3"><util:constant static-field="java.util.concurrent.TimeUnit.SECONDS"/></constructor-arg>     <constructor-arg index="4" ref="arrayBlockingPool"/> </bean>  <bean id="arrayBlockingPool" class="java.util.concurrent.ArrayBlockingQueue">     <constructor-arg value="5"/> </bean>  </beans>  
like image 912
opike Avatar asked May 09 '12 19:05

opike


1 Answers

This is the correct declaration of util namespace (don't forget about specifying schemaLocation):

<?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:util="http://www.springframework.org/schema/util"    xsi:schemaLocation="      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd      http://www.springframework.org/schema/util  http://www.springframework.org/schema/util/spring-util-3.1.xsd">   </beans> 

See more at C.2.2 The util schema.

like image 72
Tomasz Nurkiewicz Avatar answered Sep 30 '22 17:09

Tomasz Nurkiewicz