Announcement Announcement Module
Collapse
No announcement yet.
with File.separator not work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • with File.separator not work

    Code:
    public static void main( String[] args ) {
            logger.info("Showcase application starting up");
            String rootContextDirectoryClassPath = "/org/springframework/richclient/samples/showcase/ctx";
    
            String startupContextPath = rootContextDirectoryClassPath + "/richclient-startup-context.xml";
    
            String richclientApplicationContextPath = rootContextDirectoryClassPath
                    + "/richclient-application-context.xml";
    
            try {
                new ApplicationLauncher(startupContextPath, new String[] { richclientApplicationContextPath });
            } catch (RuntimeException e) {
                logger.error("RuntimeException during startup", e);
            }
        }
    and appliction success start. OK. But when I replace "/" with File.separator
    Code:
    import java.io.File;
    
      public static void main(String[] args) {
    	logger.info("Showcase application starting up");
    
    	String rootContextDirectoryClassPath = File.separator + "org"
    		+ File.separator + "springframework" + File.separator
    		+ "richclient" + File.separator + "samples" + File.separator
    		+ "showcase" + File.separator + "ctx";
    
    	String startupContextPath = rootContextDirectoryClassPath
    		+ "/richclient-startup-context.xml";
    
    	String richclientApplicationContextPath = rootContextDirectoryClassPath
    		+ "/richclient-application-context.xml";
    	try {
    	    new ApplicationLauncher(startupContextPath,
    		    new String[] { richclientApplicationContextPath });
    	} catch (RuntimeException e) {
    	    logger.error("RuntimeException during startup", e);
    	}
        }
    I get the next error:

    org.springframework.beans.factory.BeanDefinitionSt oreException: IOException parsing XML document from class path resource [/org/springframework/richclient/samples/showcase/ctx/richclient-startup-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [/org/springframework/richclient/samples/showcase/ctx/richclient-startup-context.xml] cannot be opened because it does not exist


    Stack trace
    Code:
    [INFO,ShowcaseMain,main] Showcase application starting up
    [INFO,ApplicationLauncher,main] Loading startup context from classpath resource [\org\springframework\richclient\samples\showcase\ctx/richclient-startup-context.xml]
    [INFO,ClassPathXmlApplicationContext,main] Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1813fac: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1813fac]; startup date [Sun Mar 14 16:48:55 EET 2010]; root of context hierarchy
    [INFO,XmlBeanDefinitionReader,main] Loading XML bean definitions from class path resource [/org/springframework/richclient/samples/showcase/ctx/richclient-startup-context.xml]
    [ERROR,ShowcaseMain,main] RuntimeException during startup
    org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [/org/springframework/richclient/samples/showcase/ctx/richclient-startup-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [/org/springframework/richclient/samples/showcase/ctx/richclient-startup-context.xml] cannot be opened because it does not exist
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:349)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
    	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
    	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    	at org.springframework.richclient.application.ApplicationLauncher.loadStartupContext(ApplicationLauncher.java:226)
    	at org.springframework.richclient.application.ApplicationLauncher.<init>(ApplicationLauncher.java:154)
    	at org.springframework.richclient.samples.showcase.ShowcaseMain.main(ShowcaseMain.java:80)
    Caused by: java.io.FileNotFoundException: class path resource [/org/springframework/richclient/samples/showcase/ctx/richclient-startup-context.xml] cannot be opened because it does not exist
    	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:142)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
    	... 15 more

  • #2
    You're probably running Windows? The context path you need to pass to RCP is a classpath path, not a file path. Classpath paths are always formed with forward slashes. On windows, the File.separator is a backslash.

    If you look at the second line of your stack trace, you'll see what I mean.

    Comment


    • #3
      Originally posted by LievenDoclo View Post
      You're probably running Windows? The context path you need to pass to RCP is a classpath path, not a file path. Classpath paths are always formed with forward slashes. On windows, the File.separator is a backslash.

      If you look at the second line of your stack trace, you'll see what I mean.
      thanks for answer

      Comment

      Working...
      X