10 Replies Latest reply on Jun 27, 2009 9:17 AM by alesj

    JBoss5/Spring deployment problem

    herman06

      Hi,

      I'm using jboss-5.0.0.CR2, jdk1.6.

      I downloaded and copied jboss-spring-3.1.deployer into jboss-5.0.0.CR2\server\default\deployers directory;

      I made a my-app.spring jar like the following:

      my-app.spring/
      com/
      MyBean.class
      META-INF/
      jboss-spring.xml

      and copied the my-app.spring into jboss-5.0.0.CR2\server\default\deploy directory.

      After I started the Jboss server, I can find it in the end of the server log:

      DEBUG [org.jboss.deployers.plugins.deployers.DeployersImpl] (main) Fully Deployed vfsfile:/C:/jboss-5.0.0.CR2/server/default/deploy/my-app.spring

      However I couldn't find my-app in the jndiview page; and when I call the bean factory, I got javax.naming.NameNotFoundException: my-app not bound.

      It has worked brilliantly in Jboss4.0.5. Have I done something wrong in the Jboss 5 deployment?

      Any help greatly appreciated.

      Thanks.

      Herman

        • 1. Re: JBoss5/Spring deployment problem
          alesj

           

          "Herman06" wrote:
          Have I done something wrong in the Jboss 5 deployment?

          No. :-)
          I changed how the jndi name is constructed.
          See SpringParserDeployer:
           /**
           * Get default name from meta file.
           *
           * @param file the virtual file
           * @return default name
           */
           protected String getDefaultName(VirtualFile file)
           {
           String shortName = file.getName();
           int p = shortName.indexOf("-spring.xml");
           return shortName.substring(0, p);
           }
          
           /**
           * Get default name from unit.
           *
           * @param unit the deployment unit
           * @return default name
           */
           protected String getDefaultName(VFSDeploymentUnit unit)
           {
           String shortName = unit.getSimpleName();
           int p = shortName.lastIndexOf(".");
           return shortName.substring(0, p);
           }
          
           protected SpringMetaData parse(VFSDeploymentUnit unit, VirtualFile file, SpringMetaData metaData) throws Exception
           {
           String defaultName;
           if (isUseLegacyDefaultName())
           defaultName = getDefaultName(unit);
           else
           defaultName = getDefaultName(file);
          
           return new SpringMetaData(file.toURL(), defaultName);
           }
          

          By default we don't use deployment unit's name, but rather .xml file's.
          This way you can now have multiple -spring.xml files in the same deployment.

          But if you want the old behavior, turn on the 'useLegacyDefaultName' flag. ;-)

          • 2. Re: JBoss5/Spring deployment problem
            herman06

            Thanks Ales.

            I tried your suggestion but without luck.

            I changed the xml to myapp-spring.xml, and deployed the myapp.spring into the Jboss. I got the log:

            2008-10-13 17:50:10,906 DEBUG [org.jboss.deployers.plugins.main.MainDeployerImpl] (HDScanner) Add deployment: vfsfile:/C:/jboss-5.0.0.CR2/server/default/deploy/myapp.spring
            2008-10-13 17:50:10,906 DEBUG [org.jboss.deployers.plugins.main.MainDeployerImpl] (HDScanner) Scheduling deployment: vfsfile:/C:/jboss-5.0.0.CR2/server/default/deploy/myapp.spring parent=null
            2008-10-13 17:50:10,906 DEBUG [org.jboss.deployers.plugins.deployers.DeployersImpl] (HDScanner) Deploying vfsfile:/C:/jboss-5.0.0.CR2/server/default/deploy/myapp.spring
            2008-10-13 17:50:10,906 DEBUG [org.jboss.deployers.vfs.plugins.classloader.InMemoryClassesDeployer] (HDScanner) Dynamic class root for vfsfile:/C:/jboss-5.0.0.CR2/server/default/deploy/myapp.spring is vfsmemory://a11j-6s92mu-fm8qvqbj-1-fm8qwz8a-3b
            2008-10-13 17:50:10,906 DEBUG [org.jboss.classloading.spi.dependency.Domain] (HDScanner) org.jboss.classloading.spi.dependency.Domain@1ed5459{DefaultDomain} add module VFSDeploymentClassLoaderPolicyModule myapp.spring:0.0.0
            2008-10-13 17:50:10,906 DEBUG [org.jboss.classloader.spi.base.BaseClassLoader] (HDScanner) Created BaseClassLoader@9fbed8{vfsfile:/C:/jboss-5.0.0.CR2/server/default/deploy/myapp.spring} with policy VFSClassLoaderPolicy@1aa8563{name=vfsfile:/C:/jboss-5.0.0.CR2/server/default/deploy/myapp.spring domain=null roots=[MemoryContextHandler@1785345[path= context=vfsmemory://a11j-6s92mu-fm8qvqbj-1-fm8qwz8a-3b real=vfsmemory://a11j-6s92mu-fm8qvqbj-1-fm8qwz8a-3b]] delegates=null exported=[] <IMPORT-ALL>NON_EMPTY}
            2008-10-13 17:50:10,906 DEBUG [org.jboss.classloader.spi.base.BaseClassLoaderDomain] (HDScanner) ClassLoaderDomain@49cf9f{DefaultDomain} registerClassLoader BaseClassLoader@9fbed8{vfsfile:/C:/jboss-5.0.0.CR2/server/default/deploy/myapp.spring}
            2008-10-13 17:50:10,906 DEBUG [org.jboss.deployers.plugins.deployers.DeployersImpl] (HDScanner) Fully Deployed vfsfile:/C:/jboss-5.0.0.CR2/server/default/deploy/myapp.spring

            I still couldn't find the jndi binding. and as well as the system. (I even tried to change the xml file to myapp.xml, still same.)

            In Jboss 4/Spring, I can see the Spring bean has been binded to a jndi name in the log.

            Anything else I can try?

            Thanks.

            Herman

            • 3. Re: JBoss5/Spring deployment problem
              alesj

               

              "Herman06" wrote:

              Anything else I can try?

              Check the log to see if SpringDeployer was even added to MainDeployer.


              • 4. Re: JBoss5/Spring deployment problem
                herman06

                Hi, there are some logs about the springdeployer:

                2008-10-14 09:55:27,937 DEBUG [org.jboss.deployers.plugins.main.MainDeployerImpl] (main) Add deployment: vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer
                2008-10-14 09:55:27,984 DEBUG [org.jboss.deployers.plugins.main.MainDeployerImpl] (main) Scheduling deployment: vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer parent=null
                2008-10-14 09:55:27,984 DEBUG [org.jboss.deployers.plugins.main.MainDeployerImpl] (main) Scheduling deployment: vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer/jboss-spring.jar parent=AbstractVFSDeploymentContext@11547922{vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer}
                2008-10-14 09:55:27,984 DEBUG [org.jboss.deployers.plugins.main.MainDeployerImpl] (main) Scheduling deployment: vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer/spring-aop.jar parent=AbstractVFSDeploymentContext@11547922{vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer}
                2008-10-14 09:55:27,984 DEBUG [org.jboss.deployers.plugins.main.MainDeployerImpl] (main) Scheduling deployment: vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer/spring-beans.jar parent=AbstractVFSDeploymentContext@11547922{vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer}
                2008-10-14 09:55:27,984 DEBUG [org.jboss.deployers.plugins.main.MainDeployerImpl] (main) Scheduling deployment: vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer/spring-context.jar parent=AbstractVFSDeploymentContext@11547922{vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer}
                2008-10-14 09:55:27,984 DEBUG [org.jboss.deployers.plugins.main.MainDeployerImpl] (main) Scheduling deployment: vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer/spring-core.jar parent=AbstractVFSDeploymentContext@11547922{vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer}


                2008-10-14 09:55:28,000 DEBUG [org.jboss.deployers.plugins.deployers.DeployersImpl] (main) Deploying vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer

                2008-10-14 09:55:28,156 DEBUG [org.jboss.deployers.vfs.plugins.classloader.InMemoryClassesDeployer] (main) Dynamic class root for vfszip:/C:/jboss-5.0.0.CR2/server/default/deployers/jboss-spring-3.1.deployer is vfsmemory://a11j-ctizc1-fm9pe8y1-1-fm9pecgs-b
                2008-10-14 09:55:28,156 DEBUG [org.jboss.classloading.spi.dependency.Domain] (main) org.jboss.classloading.spi.dependency.Domain@1ed5459{DefaultDomain} add module VFSDeploymentClassLoaderPolicyModule jboss-spring-3.1.deployer:0.0.0

                2008-10-14 09:55:29,796 DEBUG [org.jboss.ejb3.deployers.Ejb3Deployer] (main) ********* Ejb3Deployer Begin Unit: jboss-spring-3.1.deployer jar: jboss-spring-3.1.deployer
                2008-10-14 09:55:29,796 DEBUG [org.jboss.ejb3.Ejb3Deployment] (main) EJB3 deployment time took: 0
                2008-10-14 09:55:29,796 DEBUG [org.jboss.ejb3.deployers.Ejb3Deployer] (main) ********* Ejb3Deployer Begin Unit: jboss-spring.jar jar: jboss-spring.jar
                2008-10-14 09:55:29,796 DEBUG [org.jboss.ejb3.Ejb3Deployment] (main) EJB3 deployment time took: 0
                2008-10-14 09:55:29,796 DEBUG [org.jboss.ejb3.deployers.Ejb3Deployer] (main) ********* Ejb3Deployer Begin Unit: spring-aop.jar jar: spring-aop.jar
                2008-10-14 09:55:29,875 DEBUG [org.jboss.ejb3.Ejb3Deployment] (main) EJB3 deployment time took: 79
                2008-10-14 09:55:29,875 DEBUG [org.jboss.ejb3.deployers.Ejb3Deployer] (main) ********* Ejb3Deployer Begin Unit: spring-beans.jar jar: spring-beans.jar
                2008-10-14 09:55:29,937 DEBUG [org.jboss.ejb3.Ejb3Deployment] (main) EJB3 deployment time took: 62
                2008-10-14 09:55:29,937 DEBUG [org.jboss.ejb3.deployers.Ejb3Deployer] (main) ********* Ejb3Deployer Begin Unit: spring-context.jar jar: spring-context.jar
                2008-10-14 09:55:30,000 DEBUG [org.jboss.ejb3.Ejb3Deployment] (main) EJB3 deployment time took: 63
                2008-10-14 09:55:30,000 DEBUG [org.jboss.ejb3.deployers.Ejb3Deployer] (main) ********* Ejb3Deployer Begin Unit: spring-core.jar jar: spring-core.jar
                2008-10-14 09:55:30,046 DEBUG [org.jboss.ejb3.Ejb3Deployment] (main) EJB3 deployment time took: 46

                Looks the spring deployer has been recoganized by the maindeployer.

                very strange there's no jndi binding for the application. should I change the myapp.spring to myapp.jar?

                btw how can I turn on the 'useLegacyDefaultName' flag?

                Thanks.

                Herman


                • 5. Re: JBoss5/Spring deployment problem
                  alesj

                   

                  "Herman06" wrote:

                  Looks the spring deployer has been recoganized by the maindeployer.

                  No, you should see something like this:
                  2008-10-14 11:18:00,578 DEBUG [org.jboss.deployers.plugins.deployers.DeployersImpl] (main) Added deployer org.jboss.spring.deployers.SpringParserDeployer@8c6f69 for stage Parse
                  

                  or/and
                  2008-10-14 11:17:57,328 DEBUG [org.jboss.deployers.vfs.spi.deployer.JBossXBDeployerHelper] (main) Parsing file: ZipEntryHandler@16639930[path=jboss-spring.deployer/META-INF/spring-deployers-jboss-beans.xml context=file:/C:/projects/jboss5/trunk/build/output/jboss-5.0.0.GA/server/springdeployer/deployers/ real=file:/C:/projects/jboss5/trunk/build/output/jboss-5.0.0.GA/server/springdeployer/deployers/jboss-spring.deployer/META-INF/spring-deployers-jboss-beans.xml] for type: interface org.jboss.kernel.spi.deployment.KernelDeployment
                  


                  "Herman06" wrote:

                  very strange there's no jndi binding for the application. should I change the myapp.spring to myapp.jar?

                  You can try, but I would be surprised if this was the issue.

                  "Herman06" wrote:

                  btw how can I turn on the 'useLegacyDefaultName' flag?

                  See this file: jboss-spring.deployer/META-INF/spring-deployers-jboss-beans.xml
                   <bean name="SpringParserDeployer" class="org.jboss.spring.deployers.SpringParserDeployer">
                   <property name="useLegacyDefaultName">true</property>
                   </bean>
                  


                  • 6. Re: JBoss5/Spring deployment problem
                    herman06

                    Hi Ales,

                    You are right. The springdeployer isn't picked up by jboss.

                    The deployer I downloaded has the xml file as spring-deployers-beans, and in your log file you have spring-deployers-jboss-beans. So I changed my xml name to yours. It's all working!

                    Thanks a lot.

                    Herman

                    • 7. Re: JBoss5/Spring deployment problem
                      alesj

                       

                      "Herman06" wrote:

                      The deployer I downloaded has the xml file as spring-deployers-beans, and in your log file you have spring-deployers-jboss-beans. So I changed my xml name to yours.

                      Ah, yes.
                      I totally forgot about this change. :-(
                      - https://jira.jboss.org/jira/browse/JBAS-5803
                      But I'm glad we worked it out. :-)


                      • 8. Re: JBoss5/Spring deployment problem
                        fs5

                         

                        "alesj" wrote:

                        Ah, yes.
                        I totally forgot about this change. :-(
                        - https://jira.jboss.org/jira/browse/JBAS-5803


                        Hi Ales,

                        could you please update the sourceforge downloads?

                        I also ran into this problem and only did find this post by luck. I could have spent days to figure that out.

                        Many thanks,
                        Frank

                        • 9. Re: JBoss5/Spring deployment problem
                          alesj

                           

                          "fs5@gmx.net" wrote:

                          could you please update the sourceforge downloads?

                          Sure, np.

                          I need to change some of the stuff anyway
                          since I extracted the spring-int code out of the jbossas project.

                          I'll let you know when the sf has been updated.

                          • 10. Re: JBoss5/Spring deployment problem
                            alesj

                             

                            "alesj" wrote:

                            I'll let you know when the sf has been updated.

                            Finally done:
                            - https://sourceforge.net/project/showfiles.php?group_id=22866&package_id=161914