Announcement Announcement Module
No announcement yet.
Getting applicationContext from a jar throws a FileNotFoundException Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    ok, then i'll work through this stuff first and if this works, whenever this is, i'll continue the documentation you posted before... :-)

    But actually its a pitty that a simple fileload throws me backward so much... (i think this is no correct english... :-))



    • #17
      By the way... As i read the document you posted before i changed my entire project, cause the stuff my friend build is old. He used a class called TransactionProxyFactoryBean. and in the documentation is written that this class isn't used anymore sind spring 2.0. I also changed the entire springDispatcher-servlet.xml to the new <tx:-Tags, that haven't been in before.

      But this code before worked.

      //BeanFactory bf= new XmlBeanFactory(new FileSystemResource(evt.getServletContext().getRealPath("WEB-INF/SpringDispatcher-servlet.xml")));


      • #18
        Another information
        if i make this, i get another exception... i read that i can load the file with a FileSystemXmlApplicationContext too.

        	String realPath = evt.getServletContext().getRealPath("WEB-INF/SpringDispatcher-servlet.xml");		
        	ApplicationContext ctx = new FileSystemXmlApplicationContext(realPath);

        org.springframework.beans.factory.BeanDefinitionSt oreException: Unexpected exception parsing XML document from file [C:\Dokumente und Einstellungen\Nico\workspace\sf\WEB-INF\SpringDispatcher-servlet.xml]; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/tools/PointcutPrimitive
        Caused by:
        java.lang.NoClassDefFoundError: org/aspectj/weaver/tools/PointcutPrimitive
        at org.springframework.aop.aspectj.AspectJExpressionP ointcut.<clinit>( )
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.springframework.aop.config.ConfigBeanDefinitio nParser.class$( )
        at org.springframework.aop.config.ConfigBeanDefinitio nParser.createPointcutDefinition(ConfigBeanDefinit
        at org.springframework.aop.config.ConfigBeanDefinitio nParser.parsePointcut(ConfigBeanDefinitionParser.j ava:448)
        at org.springframework.aop.config.ConfigBeanDefinitio nParser.parse(
        at org.springframework.beans.factory.xml.NamespaceHan dlerSupport.parse(
        at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition
        at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition
        at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseBeanDefinitions(Defau
        at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.registerBeanDefinitions(De
        at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions(XmlBeanDefinit
        at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio
        at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR
        at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR
        at BeanDefinitionReader.loadBeanDefinitions(AbstractB
        at BeanDefinitionReader.loadBeanDefinitions(AbstractB
        at BeanDefinitionReader.loadBeanDefinitions(AbstractB
        at licationContext.loadBeanDefinitions(AbstractXmlApp
        at licationContext.loadBeanDefinitions(AbstractXmlApp
        at hableApplicationContext.refreshBeanFactory(Abstrac
        at ationContext.refresh(AbstractApplicationContext.ja va:292)
        at pplicationContext.<init>(FileSystemXmlApplicationC
        at pplicationContext.<init>(FileSystemXmlApplicationC
        at de.hosp.sf.config.ContextListener.contextInitializ ed(
        at org.apache.catalina.core.StandardContext.listenerS tart(
        at org.apache.catalina.core.StandardContext.start(Sta
        at org.apache.catalina.core.ContainerBase.start(Conta
        at org.apache.catalina.core.StandardHost.start(Standa
        at org.apache.catalina.core.ContainerBase.start(Conta
        at org.apache.catalina.core.StandardEngine.start(Stan
        at org.apache.catalina.core.StandardService.start(Sta
        at org.apache.catalina.core.StandardServer.start(Stan
        at org.apache.catalina.startup.Catalina.start(Catalin
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.start(Bootst
        at org.apache.catalina.startup.Bootstrap.main(Bootstr


        • #19
          Your missing the aspectJ jar from the classpath. If you have downloaded Spring with dependencies then there is an aspectJ folder which contains the jar you need.

          BTW, you can still use the TransactionProxyFactoryBean its just that the tx:advice tags are supposed to be a shortcut and cut down the amount of XML.


          • #20
            Actually i prefer to cut down the amount of xml. cause hiow you saw is my xml-file big. if you have more ideas to cut down the amount of lines please tell me.

            i have already included the aspectjrt.jar and the aspectjweaver.jar. these files i found in the asp-folder in the lib-folder from spring.

            I found out an interesting thing. I always get a filenotfound-exception or a java.lang.NoClassDefFoundError: org/aspectj/weaver/tools/PointcutPrimitive-Exception. But if i cut out the entire code with all these tx:-Tags, it works...


            • #21
              Its quite hard to understand what your doing, but whatever you changed you must have removed the need for the aspectJ jar. Hence the exception goes away. As for the cutting down the XML, I would have a read of the reference manual, but there are various things you can do; templating, autowiring (I don't like to use this however), new namespaces, etc..


              • #22
                well, i'm a c# and basic developer sind many years. now i wanna learn new things and its hard for me to understand that things work just cause of writing a filename in a xml-file. next is that i cant imagine that i have three different ways to load the springdispatcher-file, like mdeinum wrote.

                now i'll repair the things mdeinum wrote and then i'll write down all my files. i agree with him that i wanna split al the stuff in many separate files. i will go forward step by step. i will set myself many little milestones and at the end of this year i wanna get my data loaded from the database.

                i write again when i have repaired my web.xml...

                after this the next milestone will be to separate the files. so i can show you guys better where are problems.. cause posting all the lines has nothing to do with overview anymore...