java - ClassPathXmlApplicationContext from a Runtime.getRuntime.exec -
I develop a web app in eclipse with spring to handle dependency injection & amp; To work, Maven I am trying to make this small code work:
Public class MainExternal {public static void throws exceptions {@SuppressWarnings ("resource ") ApplicationContext appContext = New ClassPathXmlApplicationContext (" ClassPath *: Web Configuration / App Contex. XML "); Projectbau Projectbau = (ProjectBoop) App Contact. Gatebin ("Projectbau"); System.out.println ("- & gt; IM" in "); *** List of & lt; User & gt; ListUser = (list & lt; user & gt;) for projectBo.findUsers (project); (User myUser: listUser) {System.out.println ("user:" + myUser.getFirstname ());}} When I run it inside the eclipse, that work
But when I call it from my web app, such that it does not work:
Public Zero Extraction Analysis () {System.out .println ("-> I call my work"); try {String [] Order = { "Java", "- CP", "/Users/JP/git/CleanOmicsTracer/target/CleanOmicsTracer.jar", "com.clb.genomic.lyon.external.MainExternal"}; process p = runtime.gettime ( ) Exec (command); for remote command ///////////////////////////////////// /// Test String Line; Buffettder BRI = New buffed reader (neweststream reader (PJet InputStream ()); Buffer Redder BR = New buffed reader (neweststream reader (P.FARRRstream ()); while ((line = BR.Redline ())! = Null) {System.out.println (line); } Bri.close (); While ((line = breadlines ())! = Null {} System.out.println (line);} Bre.close (); p.waitFor ();} hold (IOException e) {e.printStackTrace ();} Grip (interrupted e) e.printStackTrace ();} System.out.println ("end of program");} When I tried to execute the console: < / p>
java-cp / users / jp / git / CleanOmicsTracer / target / CleanOmicsTracer.jar com. clb.genomic.lyon.external.MainExternal
And does not work:
Exception in thread "main" java.lang.NoClassDefFoundError: org / springframework / reference applicationContext /: java.lang.ClassNotFoundException: org.springframework.context A. pplicationContext at java.net.URLClassLoader $ 1.run java.security.AccessController.doPrivileged at (URLClassLoader.java202) (native java.net.URLClassLoader.findClass (URLClassLoader.java:190) sun.misc.Launcher $ AppClassLoader java.lang.ClassLoader.loadClass (ClassLoader.javailers47) on java.lang.ClassLoader.loadClass (ClassLoader.java:306) (Launcher.java:301 on) at loadclass. < / Div>
add springs jar to your masterpiece files in your classpath file you can
Java -cp /path/to/CleanOmicsTracer.jar:spring-full-1.0.1.jar com.clb.genomic.lyon.external.MainExternal If you have more than one jar File So, you can use a classpath wildcard
java -cp /path/to/CleanOmicsTracer.jar:lib/* com .clb.genomic.lyon.external.MainExternal
Comments
Post a Comment