1 2 3 4 Previous Next 59 Replies Latest reply: Nov 24, 2009 12:23 AM by Marius Bogoevici Go to original post RSS
  • 15. Re: Spring Component Auto Detection
    Ales Justin Master

    Can you post the whole config?
    And describing your app structure a bit.
    I'll try to reproduce it, eventually fixing it. :-)

  • 16. Re: Spring Component Auto Detection
    Ales Justin Master

     

    "zithuba" wrote:

    Caused by: java.lang.IllegalArgumentException: Cannot find entry: java.io.FileInputStream@37f44d, za/ac/wits/batch/aop
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.findEntry(ZipEntryContext.java:338)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.createZipSource(ZipEntryContext.java:284)

    btw: what's the VFS version?
    I know I fixed something similar,
    I just don't know in which version.
    But it should be fixed in latest VFS 2.0.0.Beta21.
    Can you try it:
    - http://repository.jboss.org/maven2/org/jboss/jboss-vfs/2.0.0.Beta21/

  • 17. Re: Spring Component Auto Detection
    Zithulele Shange Newbie

    Thanks

    I have the old installation version. I will try it.

  • 18. Re: Spring Component Auto Detection
    Zithulele Shange Newbie

    Hi,

    The jboss-spring.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    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">
    BeanFactory=(core-simple-batch-job)




    and a-status-mailer-context.xml:
    <?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:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <context:annotation-config/>
    <aop:aspectj-autoproxy/>
    <context:component-scan base-package="za.ac.batch.aop"/>
    <!--tx:jta-transaction-manager / -->
    <tx:annotation-driven/>

    <context:property-placeholder location="classpath:conf/mail.properties"/>





    <!-- this is a template message that we can pre-load with default state -->












    The application have couple of beans (2 to be exact, entity and session not useful) and then classes that are AOP advice and that are being auto detected.

    I hope this is fine.

  • 19. Re: Spring Component Auto Detection
    Ales Justin Master

    Did you try if it might work with VFS 2.0.0.Beta21?

  • 20. Re: Spring Component Auto Detection
    Zithulele Shange Newbie

    in jboss-spring.xml I import the two files I use, the first being the a-email*.xml.

  • 21. Re: Spring Component Auto Detection
    Zithulele Shange Newbie

    I did try it with the new version of VFS, but still it is giving me errors. I will try to update other files as well and see what happens.

  • 22. Re: Spring Component Auto Detection
    Ales Justin Master

    I doubt updating other files will help,
    since it definitely looks to me as a VFS issue.

    I'll try to recreate error, mocking your config.
    Just can't promise when will that be - busy integrating Seam with JBoss5.

    But you're welcome to give it a crack yourself, at VFS. ;-)
    Since I think the part that fails was a quick hack from my side,
    never really fully tested.
    - http://anonsvn.jboss.org/repos/jbossas/projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java
    See that match hack/crap in findEntry. :-(

  • 23. Re: Spring Component Auto Detection
    Ales Justin Master

    I've added the following test to VFS

     public void testDirectoryFind() throws Throwable
     {
     URL url = getResource("/vfs/test/outer.jar");
     String urlString = url.toExternalForm();
     int p = urlString.indexOf(":");
     URL rootURL = new URL("vfszip" + urlString.substring(p) + "/org/jboss/test/vfs");
     VirtualFile root = VFS.getRoot(rootURL);
     assertNotNull(root);
     }
    

    which should somehow resemble your case.
    And it passes for me locally.

    Send me the debug log from VFSResourcePatternResolver
     protected List<Resource> getVFSResources(URL rootURL, String subPattern) throws IOException
     {
     log.debug("Scanning url: " + rootURL + ", sub-pattern: " + subPattern);
     VirtualFile root = VFS.getRoot(rootURL);
     PatternVirtualFileVisitor visitor = new PatternVirtualFileVisitor(subPattern);
     root.visit(visitor);
     if (log.isTraceEnabled())
     log.trace("Found resources: " + visitor);
     return visitor.getResources();
     }
    


  • 24. Re: Spring Component Auto Detection
    Ratheesh Ravindran Nair Newbie


    Hi,

    I am wondering whether this fix is released, I ran into similar problem with RichFaces 3.2.2, Jboss Portal 2.7.0 GA and Spring 2.5 version (pls dont ask y not Seam :) ).

    <context:component-scan.../> tags are not processed and I had to change the entire annotations in my beans to context XML files.
    It was unfortunate that I found this talk only after spending lot of time on this.

    thanks for keeping this in the forum :)

    thanks
    Ratheesh.R.Nair

  • 25. Re: Spring Component Auto Detection
    Ales Justin Master

     

    "ratheesh.nair" wrote:

    I am wondering whether this fix is released, I ran into similar problem with RichFaces 3.2.2, Jboss Portal 2.7.0 GA and Spring 2.5 version (pls dont ask y not Seam :) ).

    I didn't work on this any further since I don't know how to reproduce it.
    Like I posted previously, if someone can post that failing debug info,
    I'll have another look.

    Perhaps try it out on the AS_trunk,
    as it has all the latest MC code.

  • 26. Re: Spring Component Auto Detection
    Kai Newbie

    Hi,

    the issue remains with JBoss 5.0.1.GA and Spring 2.5.6. No problem with JBoss 4.x.

    We have a web application and initialize the spring context with a ContextLoaderListener (referenced in web.xml). The spring-beans-config (in the classpath) uses "context:component-scan".

    For a spring DispatcherServlet, an extra config-file must be provided in the /WEB-INF/ directory.

    Depending on the type of deployment (exploded vs. war), the stack trace is

    java.io.FileNotFoundException: URL [vfsfile:/C:/dev/jboss-5.0.1.GA/server/default/deploy/exportmanager-server.war/WEB-INF/classes/de/bafa/] cannot be resolved to absolute file path because it does not reside in the file system: vfsfile:/C:/dev/jboss-5.0.1.GA/server/default/deploy/exportmanager-server.war/WEB-INF/classes/de/bafa/
    at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:201)
    at org.springframework.core.io.UrlResource.getFile(UrlResource.java:156)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:517)
    at org.springframework.web.context.support.ServletContextResourcePatternResolver.doFindPathMatchingFileResources(ServletContextResourcePatternResolver.java:80)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:342)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:263)
    at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1018)
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:182)
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:201)
    at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
    ...

    or

    2009-02-26 14:09:45,578 DEBUG [org.springframework.core.io.support.PathMatchingResourcePatternResolver] (HDScanner) Cannot search for matching files underneath URL [vfszip:/C:/dev/jboss-5.0.1.GA/server/default/deploy/exportmanager-server.war/WEB-INF/classes/de/bafa/] because it does not correspond to a directory in the file system
    java.io.FileNotFoundException: URL [vfszip:/C:/dev/jboss-5.0.1.GA/server/default/deploy/exportmanager-server.war/WEB-INF/classes/de/bafa/] cannot be resolved to absolute file path because it does not reside in the file system: vfszip:/C:/dev/jboss-5.0.1.GA/server/default/deploy/exportmanager-server.war/WEB-INF/classes/de/bafa/
    at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:198)
    at org.springframework.core.io.UrlResource.getFile(UrlResource.java:156)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:517)
    at org.springframework.web.context.support.ServletContextResourcePatternResolver.doFindPathMatchingFileResources(ServletContextResourcePatternResolver.java:80)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:342)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:263)
    at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1019)
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:177)
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:201)
    at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:85)

    The fix provided in Spring 2.5.6 had no effect (see http://jira.springframework.org/browse/SPR-5120).

    The code provided in http://anonsvn.jboss.org/repos/jbossas/trunk/spring-int/src/main/org/jboss/spring/io/ solved the problem for the spring-beans-config in the classpath, but then the config-file in /WEB-INF/ was not found anymore.

    Temporary fix for our issue:
    1. Overwrite the spring-class "XmlWebApplicationContext":

     protected ResourcePatternResolver getResourcePatternResolver() {
     return new VFSResourcePatternResolver(this);
     }
    
     public Resource getResource(String location) {
     Assert.notNull(location, "Location must not be null");
     if (location.startsWith(CLASSPATH_URL_PREFIX)) {
     return new ClassPathResource(location
     .substring(CLASSPATH_URL_PREFIX.length()), getClassLoader());
     } else {
     try {
     // Try to parse the location as a URL...
     URL url = new URL(location);
     VirtualFile file = VFS.getRoot(url);
     return new VFSResource(file);
     } catch (Exception ex) {
     return new ServletContextResource(getServletContext(), location);
     }
     }
     }
    


    2. Check out the files from http://anonsvn.jboss.org/repos/jbossas/trunk/spring-int/src/main/org/jboss/spring/io/ and modify class "VFSResourcePatternResolver" in the following way:
     public VFSResourcePatternResolver(ResourceLoader resourceLoader)
     {
     super(resourceLoader);
     }
    


    The point here is to use VFSResourcePatternResolver but wrap the path for the /WEB-INF/-file as a ServletContextResource.

    In my opinion, such issues should be fixed in JBoss or Spring, but not by customers using these two wide-spread frameworks! - I'd rather use another application sever than fixing these kind of things for production use, making version upgrades a potential problem.

    Would it be possible to talk to the people developing Spring directly, so that these issues can be solved in on of the next releases (of either JBoss or Spring)?



  • 27. Re: Spring Component Auto Detection
    Ales Justin Master

     

    "khoerder" wrote:

    In my opinion, such issues should be fixed in JBoss or Spring, but not by customers using these two wide-spread frameworks! - I'd rather use another application sever than fixing these kind of things for production use, making version upgrades a potential problem.

    Sure, I completely agree with you.
    It's just that I'm not aware of all things you can do.
    I definitely need to update the tests a bit.

    btw: WEB-INF is really not by the spec for cl resources ;-)

    "khoerder" wrote:

    Would it be possible to talk to the people developing Spring directly, so that these issues can be solved in on of the next releases (of either JBoss or Spring)?

    There was/is a JIRA, so they know about the issue.
    But as you can see, it's been Deferred, what ever that means for them ...

  • 29. Re: Spring Component Auto Detection
    David Ward Newbie

    At Alfresco we also struggled getting our Spring-based framework working on JBoss 5. We have lots of bean definition files using classpath-based pattern matching. E.g.:

    <import resource="classpath*:alfresco/patch/*-context.xml"/>


    We think we now have a solution and your feedback is welcome. I eventually created a subclass of XmlWebApplicationContext that used a generalized version of VFSResourcePatternResolver that subclassed ServletContextResourcePatternResolver. FYI I had to fix the logic to deal with relative path matching and matching of directories. I also made the resolver behave as normal on other app servers when not dealing with vfs URLs.

    See http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/core/source/java/org/alfresco/config/JBossEnabledWebApplicationContext.java and associated classes.