Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

unable to read the properties file in jar (property files are withing specific env folder)  RSS feed

 
Ranch Hand
Posts: 33
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am not able to read propert files while executing jar.
I am getting below exception. I have to put propery file under /lib/dev folder. (where dev is development environment).
I am reading property file as below.

Can anyone please help> placing property files directly under jar might resolve this but this is not feasible for me.

PropertyConfigurator.configure(filePath + logFileName);
prop.load(new FileInputStream(filePath + dbFileName));

DBProperties dbProps = DBProperties.INSTANCE;

dbProps.setOracleDriverclass(prop.getProperty("oracle.driverclass"));
dbProps.setOracleHost(prop.getProperty("oracle.host"));

Exception
************

log4j:ERROR Could not read configuration file [/int/rmd/apps/waiverManagement/waiverApplicability/lib/int/logger.properties].
java.io.FileNotFoundException: /int/rmd/apps/waiverManagement/waiverApplicability/lib/int/logger.properties (No such file or directory)
at java.io.FileInputStream.<init>(FileInputStream.java:137)
at java.io.FileInputStream.<init>(FileInputStream.java:96)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:372)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:403)
at com.delta.waivermgmt.util.ApplicationInitializer.initializeParams(ApplicationInitializer.java:29)
at com.delta.waivermgmt.admin.TktWaiverAppliedInvalidProcess.main(TktWaiverAppliedInvalidProcess.java:459)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
log4j:ERROR Ignoring configuration file [/int/rmd/apps/waiverManagement/waiverApplicability/lib/int/logger.properties].
log4j:WARN No appenders could be found for logger (com.delta.waivermgmt.util.ApplicationInitializer).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
java.io.FileNotFoundException: /int/rmd/apps/waiverManagement/waiverApplicability/lib/int/db.properties (No such file or directory)
at java.io.FileInputStream.<init>(FileInputStream.java:137)
at java.io.FileInputStream.<init>(FileInputStream.java:96)
at com.delta.waivermgmt.util.ApplicationInitializer.initializeParams(ApplicationInitializer.java:31)
at com.delta.waivermgmt.admin.TktWaiverAppliedInvalidProcess.main(TktWaiverAppliedInvalidProcess.java:459)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
java.lang.NullPointerException
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:177)
at com.delta.waivermgmt.database.OracleUtil.getOracleConnection(OracleUtil.java:32)
at com.delta.waivermgmt.database.OracleUtil.executeQuery(OracleUtil.java:114)
at com.delta.waivermgmt.admin.TicketWaiverSource.getETicketTableDataMap(TicketWaiverSource.java:45)
at com.delta.waivermgmt.admin.TktWaiverAppliedInvalidProcess.getWaiverTypeLstUpdateTimeStamp(TktWaiverAppliedInvalidProcess.java:36)
at com.delta.waivermgmt.admin.TktWaiverAppliedInvalidProcess.main(TktWaiverAppliedInvalidProcess.java:462)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
 
Jay B Shukla
Ranch Hand
Posts: 33
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating Runnable Jar as i am not able to load third party jar while running it from regular jar. Gwtting below with regular jar.

Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.log4j.Logger
at com.delta.waivermgmt.admin.TktWaiverAppliedInvalidProcess.<clinit>(TktWaiverAppliedInvalidProcess.java:25)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:237)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:703)
at java.lang.ClassLoader.loadClass(ClassLoader.java:682)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:665)
... 3 more
Could not find the main class: com.delta.waivermgmt.admin.TktWaiverAppliedInvalidProcess. Program will exit.
 
Sheriff
Posts: 5268
142
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using Maven to build? If so, have you tried putting the configuration file under /usr/main/resources?
 
Jay B Shukla
Ranch Hand
Posts: 33
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply.

This is very small module so I am not using Maven for this.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!