Announcement Announcement Module
Collapse
No announcement yet.
jee:jndi-lookup error: no declaration can be found for element 'jee:jndi-lookup' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • jee:jndi-lookup error: no declaration can be found for element 'jee:jndi-lookup'

    Hi,

    When I'm trying to obtain remote reference to EJB usind JNDI or remote-slsb the following error occurs:

    Code:
    Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 19 in XML document from class path resource [pl/edu/uj/spring/ejb/remote/context.xml] is invalid; 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'.
    Here is code (very simple):
    Code:
    package pl.edu.uj.spring.ejb.remote;
    
    import javax.ejb.Stateless;
    
    @Stateless
    public class MyBean implements MyRemoteBean {
        public String getSomeString() {
            return "SOME STRING";
        }
    }
    Code:
    package pl.edu.uj.spring.ejb.remote;
    
    import javax.ejb.Remote;
    
    @Remote
    public interface MyRemoteBean {
        String getSomeString();
    }
    Code:
    package pl.edu.uj.spring.ejb.remote;
    
    public class MySpringComponent {
        private MyRemoteBean myBeanRemoteReference;
    
        public void setMyBeanRemoteReference(MyRemoteBean bean) {
            this.myBeanRemoteReference = bean;
        }
    
        public String service() {
            return myBeanRemoteReference.getSomeString();
        }
    }
    Code:
    package pl.edu.uj.spring.ejb.remote;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class SpringApplication {
        public static void main(String[] args) {
            ApplicationContext ctx = new ClassPathXmlApplicationContext("pl/edu/uj/spring/ejb/remote/context.xml");
            MySpringComponent component = ctx.getBean("mySpringComponent", MySpringComponent.class);
            System.out.println(component.service());
    
        }
    }
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:tool="http://www.springframework.org/schema/tool/"
           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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
        <!-- remote-slsb also doesn't work. the same exception :(
        org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict,
        but no declaration can be found for element 'jee:remote-slsb'
    
        <jee:remote-slsb id="myStatelessRemoteBean" jndi-name="MyBean/remote"
                        business-interface="pl.edu.uj.spring.ejb.remote.MyRemoteBean"/>
    
        -->
        
        <jee:jndi-lookup id="myStatelessRemoteBean" jndi-name="MyBean/remote"/>
    
        <bean id="myComponent" class="pl.edu.uj.spring.ejb.remote.MySpringComponent">
            <property name="myBeanRemoteReference">
                <ref local="myStatelessRemoteBean"/>
            </property>
        </bean>
    
    </beans>

    I'm using the lates version of Spring framework (3.0.3) and (if it has any impact) IntelliJ IDEA. What I did wrong?
    Thanks in advance!

  • #2
    The exception is pretty clear imho... YOu don't have a declaration for the jee namespace...

    The only 2 namespaces which are correctly defined are the beans and context namespace.

    Comment


    • #3
      Shame on me...
      Thank you very much. Here is working version for other newbies
      Code:
      <?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
                                 ">

      Comment


      • #4
        Thanks, i was struggling from hours !

        Comment


        • #5
          org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 11 in XML document from ServletConte
          xt resource [/WEB-INF/frontcontroller-servlet.xml] is invalid; 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 'context:
          component-scan'.

          hi sir... how to clear this error pls help me...

          this is my xml code...

          frontcontroller-servlet.xml

          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:context="http://www.springframework.org/schema/context"
          xmlns:tool="http://www.springframework.org/schema/tool/"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:tx="http://www.springframework.org/schema/tx"
          xmlns:jee="http://www.springframework.org/schema/jee"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd
          http://www.springframework.org/schema/jee http://www.springframework.org/schema/context
          http://www.springframework.org/schema/aop http://www.springframework.org/schem...ng-aop-2.5.xsd http://www.springframework.org/schem...ontext-2.5.xsd http://www.springframework.org/schem...ng-jee-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
          <context:component-scan base-package="com.nareshit"/>
          <jee:jndi-lookup id="ds" jndi-name="java:comp/env/mydns" />

          <bean class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
          <property name="prefix" value="/"/>
          <property name="suffix" value=".jsp"/>
          </bean>
          </beans>


          web.xml
          ............

          <web-app>
          <servlet>
          <servlet-name>frontcontroller</servlet-name>
          <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
          <load-on-startup>1</load-on-startup>
          </servlet>
          <context-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/frontcontroller-servlet.xml</param-value>
          </context-param>
          <listener>
          <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
          </listener>
          <servlet-mapping>
          <servlet-name>frontcontroller</servlet-name>
          <url-pattern>*.html</url-pattern>
          </servlet-mapping>
          <!--<welcome-file-list>
          <welcome-file>login.jsp</welcome-file>
          </welcome-file-list> -->
          </web-app>

          Comment

          Working...
          X