Hi All,
I have a swing application using spring framework and just it's core components. I'm able to run my app from Eclipce environment or the command line, but now I have to integrate this application with a application that was built in c++ and load the jvm.
As I mentioned before my app is running fine if I try to execute it from my command line, here is the class code that I'm using to to run my application.
public class EditModeStartup {
public static void main(String[] args) {
logger.info("Starting main method");
(new EditModeStartup()).startEditModeTool( args[0] );
logger.info("End of main method");
}
public void startEditModeTool( String editModeDir ) {
try {
SwingUtilities.invokeAndWait( (this).new LibrariesDesktopStartup() );
} catch (InterruptedException e) {
logger.log(Priority.ERROR, e, e.getCause());
} catch (InvocationTargetException e) {
logger.log(Priority.ERROR, e, e.getCause());
}
logger.info("End of startEditModeTool method");
}
class LibrariesDesktopStartup implements Runnable {
GenericApplicationContext appContext = null;
XmlBeanDefinitionReader reader = null;
ClassPathResource res = null;
File dirToMonitor = null;
File deployConfCopyDir = null;
LoginDesktop loginDesktop = null;
public void run() {
logger.debug("Starting Run() method");
appContext = new GenericApplicationContext();
logger.debug("GenericApplicationContext Display Name: " + appContext.getDisplayName());
//logger.debug("GenericApplicationContext.getClassLo ader(): " + appContext.getClassLoader().toString());
reader = new XmlBeanDefinitionReader(appContext);
logger.debug("reader.getResourceLoader(): " + reader.getResourceLoader().toString());
//logger.debug("reader.getBeanClassLoader()): " + reader.getBeanClassLoader().toString());
res = new ClassPathResource("applicationContext-Login.xml");
logger.debug("res: " + res);
logger.debug("res.getDescription(): " + res.getDescription());
logger.debug("res.getFilename(): " + res.getFilename());
logger.debug("BEFORE loadBeanDefinitions() method");
//This reader.loadBeanDefinitions(res) is the line number 193
reader.loadBeanDefinitions(res);
logger.debug("After loadBeanDefinitions() method");
logger.debug("GETTING LoginDesktop bean");
loginDesktop = (LoginDesktop) appContext.getBean("loginDesktop");
logger.debug("LoginDesktop bean gotten");
if( loginDesktop.login() ) {
logger.info( " Login Successfull ");
res = new ClassPathResource("monitor.xml");
reader.loadBeanDefinitions(res);
res = new ClassPathResource("MsgBox.xml");
reader.loadBeanDefinitions(res);
appContext.refresh();
createLocalCopyDirectory();
createConfCopyDirectory();
createXmlCopyDirectory();
createLibDesktopVersionFile();
} else {
logger.info( " Login Unsuccessfull ");
System.exit(0);
}
logger.debug("Leaving Run() method");
}
and this is the log contents of my log file:
2006-10-25 11:44:39,826 DEBUG com.ge.libraries.desktop.login.EditModeStartup - Starting Run() method
2006-10-25 11:44:39,951 DEBUG com.ge.libraries.desktop.login.EditModeStartup - GenericApplicationContext Display Name: org.springframework.context.support.GenericApplica tionContext;hashCode=3341135
2006-10-25 11:44:39,982 DEBUG com.ge.libraries.desktop.login.EditModeStartup - reader.getResourceLoader(): org.springframework.core.io.DefaultResourceLoader@ 1f630dc
2006-10-25 11:44:39,998 DEBUG com.ge.libraries.desktop.login.EditModeStartup - res: class path resource [applicationContext-Login.xml]
2006-10-25 11:44:39,998 DEBUG com.ge.libraries.desktop.login.EditModeStartup - res.getDescription(): class path resource [applicationContext-Login.xml]
2006-10-25 11:44:40,029 DEBUG com.ge.libraries.desktop.login.EditModeStartup - res.getFilename(): applicationContext-Login.xml
2006-10-25 11:44:40,029 DEBUG com.ge.libraries.desktop.login.EditModeStartup - BEFORE loadBeanDefinitions() method
2006-10-25 11:44:40,029 INFO org.springframework.beans.factory.xml.XmlBeanDefin itionReader - Loading XML bean definitions from class path resource [applicationContext-Login.xml]
2006-10-25 11:44:40,029 DEBUG org.springframework.beans.factory.xml.XmlBeanDefin itionReader - Using JAXP implementation [com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderFactoryImpl@1787038]
2006-10-25 11:44:40,123 DEBUG org.springframework.beans.factory.xml.BeansDtdReso lver - Trying to resolve XML entity with public ID [-//SPRING//DTD BEAN//EN] and system ID [http://www.spring.framework.org/dtd/spring-beans.dtd]
2006-10-25 11:44:40,123 DEBUG org.springframework.beans.factory.xml.BeansDtdReso lver - Trying to locate [spring-beans.dtd] under [/org/springframework/beans/factory/xml/]
2006-10-25 11:44:40,123 DEBUG org.springframework.beans.factory.xml.BeansDtdReso lver - Found beans DTD [http://www.spring.framework.org/dtd/spring-beans.dtd] in classpath
2006-10-25 11:44:40,185 DEBUG org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser - Loading bean definitions
2006-10-25 11:44:40,201 DEBUG org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser - Default lazy init 'false'
2006-10-25 11:44:40,201 DEBUG org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser - Default dependency check 'none'
2006-10-25 11:44:40,201 DEBUG org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser - Default autowire 'no'
2006-10-25 11:44:40,263 DEBUG org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser - Found 2 <bean> elements defining beans
2006-10-25 11:44:40,279 DEBUG com.ge.libraries.desktop.login.EditModeStartup - After loadBeanDefinitions() method
2006-10-25 11:44:40,279 DEBUG com.ge.libraries.desktop.login.EditModeStartup - GETTING LoginDesktop bean
2006-10-25 11:44:40,279 INFO org.springframework.beans.factory.support.DefaultL istableBeanFactory - Creating shared instance of singleton bean 'loginDesktop'
2006-10-25 11:44:40,279 DEBUG org.springframework.beans.factory.support.DefaultL istableBeanFactory - Creating instance of bean 'loginDesktop' with merged definition [Root bean with class [com.ge.libraries.desktop.login.LoginDesktop] defined in class path resource [applicationContext-Login.xml]]
As you can see this is fine. It is running properly. My problem is that when I'm trying to execute this class from JNI springframework throw a NullPointerException,
Here is the log entries when I run the class from jni code.
2006-10-25 14:04:34,048 DEBUG com.ge.libraries.desktop.login.EditModeStartup - Starting Run() method
2006-10-25 14:04:34,158 DEBUG com.ge.libraries.desktop.login.EditModeStartup - GenericApplicationContext Display Name: org.springframework.context.support.GenericApplica tionContext;hashCode=9042915
2006-10-25 14:04:34,189 DEBUG com.ge.libraries.desktop.login.EditModeStartup - reader.getResourceLoader(): org.springframework.core.io.DefaultResourceLoader@ 16897b2
2006-10-25 14:04:34,189 DEBUG com.ge.libraries.desktop.login.EditModeStartup - res: class path resource [applicationContext-Login.xml]
2006-10-25 14:04:34,189 DEBUG com.ge.libraries.desktop.login.EditModeStartup - res.getDescription(): class path resource [applicationContext-Login.xml]
2006-10-25 14:04:34,189 DEBUG com.ge.libraries.desktop.login.EditModeStartup - res.getFilename(): applicationContext-Login.xml
2006-10-25 14:04:34,189 DEBUG com.ge.libraries.desktop.login.EditModeStartup - BEFORE loadBeanDefinitions() method
2006-10-25 14:04:34,189 INFO org.springframework.beans.factory.xml.XmlBeanDefin itionReader - Loading XML bean definitions from class path resource [applicationContext-Login.xml]
2006-10-25 14:04:34,204 DEBUG org.springframework.beans.factory.xml.XmlBeanDefin itionReader - Using JAXP implementation [com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderFactoryImpl@85af80]
2006-10-25 14:04:34,298 ERROR com.ge.libraries.desktop.login.EditModeStartup - java.lang.reflect.InvocationTargetException
java.lang.NullPointerException
at org.springframework.core.io.ClassPathResource.getI nputStream(ClassPathResource.java:124)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:131)
at com.ge.libraries.desktop.login.EditModeStartup$Lib rariesDesktopStartup.run(EditModeStartup.java:193)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
2006-10-25 14:04:34,298 INFO com.ge.libraries.desktop.login.EditModeStartup - End of startEditModeTool method
I hope you guys can help me, all of my code and applicationContext-Login.xml is withing a jar file. The .xml file is in the root of the directory structure.


Reply With Quote