This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 5687
147
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.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!