5 Replies Latest reply on Jun 24, 2007 8:44 AM by tahir bashir

    Problem in spring integration

    tahir bashir Newbie

      hi ,
      I am trying to intergrate spring to jboss but am getting error

      i am using jboss jboss-4.0.5.GA

      i am using example to delpoy JBoss-Spring.ear
      also added jboss-spring-jdk5.jar to deploy diretory of default of server and also added spring libraries in default lib directory

      when deploy in jboss, I get following error of JBoss-Spring not bound

      15:26:54,096 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in
      factory [org.springframework.beans.factory.support.DefaultListableBeanFactory de
      fining beans [randomizer,horoscope]; root of BeanFactory hierarchy]
      15:26:54,159 INFO [DefaultListableBeanFactory] Destroying singletons in factory
       {org.springframework.beans.factory.support.DefaultListableBeanFactory defining
      beans [randomizer,horoscope]; root of BeanFactory hierarchy}
      15:26:54,159 ERROR [ContextLoader] Context initialization failed
      org.springframework.beans.factory.BeanCreationException: Error creating bean wit
      h name 'randomizer' defined in ServletContext resource [/WEB-INF/applicationCont
      ext.xml]: Initialization of bean failed; nested exception is javax.naming.NameNo
      tFoundException: JBoss-Spring not bound
      javax.naming.NameNotFoundException: JBoss-Spring not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java
      :124)



      the structure of ear file is

      JBoss-Spring.ear/
      META-INF/
      application.xml

      business.ejb3
      packed ejbeans

      spring-pojo.spring/
      org\
      jboss\
      tutorial\
      spring -- all bean classes
      META-INF\
      jboss-spring.xml

      web.war
      WEB_INF\
      applicationContext.xml
      jboss-spring-servlet.xml
      jboss-web.xml
      web.xml

      application.xml
       <?xml version="1.0" encoding="UTF-8"?>
      <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
       <display-name>JBoss Spring</display-name>
       <description>J2EE Made Easy - JBoss + Spring</description>
      
       <module>
       <ejb>JBoss-Spring.spring</ejb>
       </module>
      
       <module>
       <ejb>business.ejb3</ejb>
       </module>
      
       <module>
       <web>
       <web-uri>web.war</web-uri>
       <context-root>jboss-spring</context-root>
       </web>
       </module>
      
      </application>






      jboss-spring.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
      
      <beans>
      
       <!-- File line readers -->
      
       <bean id="fileLineReader" class="org.jboss.tutorial.spring.FileLineReader" abstract="true"/>
      
       <bean id="randomFileLineReader"
       class="org.jboss.tutorial.spring.RandomFileWordsCreator"
       parent="fileLineReader"
       abstract="true">
       <property name="intCreator">
       <ref local="javaRandomIntCreator"/>
       </property>
       </bean>
      
       <!-- Randomizer beans -->
      
       <bean id="staticWordsCreator" class="org.jboss.tutorial.spring.StaticWordsCreator"/>
      
       <bean id="fileWordsCreator" parent="fileLineReader">
       <property name="resource">
       <value>classpath:words.properties</value>
       </property>
       </bean>
      
       <bean id="randomWordsCreator" parent="randomFileLineReader">
       <property name="resource">
       <value>classpath:words.properties</value>
       </property>
       </bean>
      
       <bean id="stateIntCreator" class="org.jboss.tutorial.spring.DummyStateIntCreator"/>
      
       <bean id="javaRandomIntCreator" class="org.jboss.tutorial.spring.JavaRandomIntCreator"/>
      
       <!-- Horoscope -->
      
       <bean id="horoscopeSentenceCreator" parent="fileLineReader">
       <property name="resource">
       <value>classpath:horoscope.properties</value>
       </property>
       </bean>
      
      </beans>



      applicationContext.xml

      <?xml version="1.0" encoding="UTF-8" ?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
      
      <beans>
      
       <bean id="randomizer" class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="jndiName">
       <value>JBoss-Spring/RandomizerBean/local</value>
       </property>
       </bean>
      
       <bean id="horoscope" class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="cache">
       <value>false</value>
       </property>
       <property name="proxyInterface">
       <value>org.jboss.tutorial.ee.service.Horoscope</value>
       </property>
       <property name="jndiName">
       <value>JBoss-Spring/HoroscopeBean/local</value>
       </property>
       </bean>
      
      </beans>



      jboss-spring-servlet.xml

      <?xml version="1.0" encoding="UTF-8" ?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
      
      <!--
       - DispatcherServlet application context for JBoss-Spring
       -->
      <beans>
      
       <bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
       <property name="basename">
       <value>views</value>
       </property>
       </bean>
      
       <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
       <property name="mappings">
       <props>
       <prop key="/number.htm">appController</prop>
       <prop key="/word.htm">appController</prop>
       <prop key="/horoscope.htm">appController</prop>
       </props>
       </property>
       </bean>
      
       <!-- ========================= CONTROLLER DEFINITIONS ========================= -->
      
       <bean id="appControllerResolver"
       class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
       <property name="mappings">
       <props>
       <prop key="/number.htm">numberHandler</prop>
       <prop key="/word.htm">wordHandler</prop>
       <prop key="/horoscope.htm">horoscopeHandler</prop>
       </props>
       </property>
       </bean>
      
       <bean id="appController" class="org.jboss.tutorial.web.AppController">
       <property name="methodNameResolver">
       <ref local="appControllerResolver"/>
       </property>
       <property name="randomizer">
       <ref bean="randomizer"/>
       </property>
       <property name="horoscope">
       <ref bean="horoscope"/>
       </property>
       </bean>
      
      </beans>


      jboss-web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
      
      <jboss-web>
      </jboss-web>


      web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
      
      <web-app>
      
       <display-name>JBoss-Spring-Example</display-name>
      
       <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
       </listener>
      
       <servlet>
       <servlet-name>jboss-spring</servlet-name>
       <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>jboss-spring</servlet-name>
       <url-pattern>*.htm</url-pattern>
       </servlet-mapping>
      
       <welcome-file-list>
       <welcome-file>index.jsp</welcome-file>
       </welcome-file-list>
      
      </web-app>


      Thanks in advance for help

        • 1. Re: Problem in spring integration
          Ales Justin Master

          You've got 2 different names for .spring archive:

          spring-pojo.spring/

           <module>
           <ejb>JBoss-Spring.spring</ejb>
           </module>
          


          Which one is it?

          • 2. Re: Problem in spring integration
            tahir bashir Newbie

            Thank you for your reply, Ales Justin

            sorry it was this one correct

            <module>
             <ejb>spring-pojo.spring</ejb>
             </module>
            


            i extracted the ear file and try to rename this JBoss-Spring.sping also changed in application.xml but it did not worked

            so i want from start i.e above one(spring-pojo.spring) is correct which was in the original example ear file

            thanks in adavnce







            • 3. Re: Problem in spring integration
              tahir bashir Newbie

              alesj thank you for ur reply

              I added ejb3 support to my jboss 4.0.5 ,sorry for this silly mistake as i am new to jboss.

              Now following error is coming

              15:46:28,531 WARN [ServiceController] Problem starting service jboss.j2ee:service=EJB3,
              module=business.ejb3
              java.lang.NoClassDefFoundError: Lorg/jboss/tutorial/spring/WordsCreator;
               at java.lang.Class.getDeclaredFields0(Native Method)
               at java.lang.Class.privateGetDeclaredFields(Class.java:2232)
               at java.lang.Class.getDeclaredFields(Class.java:1715)


              Looks like not able to find the spring beans declared in
              spring-pojo.spring/
              beans classes
              META-INF/
              jboss-spring.xml

              Thanks in advance

              I am new to spring and jboss thank you for understanding and I am converting my application to spring + ejb3 + hibernate in jboss as it will be an enterprise application and want to target 20 thousand + concurrent user ,so any suggestions /advice will be highly appreciated

              Thanks again for help in advance




              • 4. Re: Problem in spring integration
                Ales Justin Master

                You are probably missing Spring deployer.
                See example for instructions on how to install it.

                • 5. Re: Problem in spring integration
                  tahir bashir Newbie

                  thanks alesj

                  you were right spring deployer was missing

                  Now every thing is working fine kool