Showing posts with label FileNotFoundException. Show all posts
Showing posts with label FileNotFoundException. Show all posts

Wednesday, December 18, 2013

keytool error: java.io.FileNotFoundException: cacerts (Permission denied)

I got the error when trying to install a certificate into my keystore

Command -
keytool -import -alias aliasName -file fileName.cer -keystore cacerts
keytool -list -keystore cacerts

Solutions

Windows -
This could happen if you are not running the command prompt in administrator mode. Login with the user who has administrator privilege.

For Windows 7 and above - Go to run, type cmd and hit Ctrl+Shift+enter. This will open the command prompt in administrator mode.

For others windows -  Go to start -> all programs -> accessories -> right click command prompt and say run as administrator.

Linux -
First check the write permissions on the keystore. Also if needed login with root user and try the command.

Thursday, July 4, 2013

Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

Exception in thread "main" java.lang.Exception: Error Initializing Context: oracle.jdbc.driver.OracleDriver
at com.hewitt.appinv.sdc.db.LocalContextFactory.createLocalContext(LocalContextFactory.java:28)
at com.hewitt.appinv.sdc.db.TestJNDI.main(TestJNDI.java:14)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.hewitt.appinv.sdc.db.LocalContextFactory.createLocalContext(LocalContextFactory.java:23)
... 1 more

If you see above error, Please add classes12.jar  in your applications classpath. Download it from here. classes12.jar  

Thursday, January 10, 2013

Java program to read a text file

Below java program can be used to read a text (.txt) file or any other text based file like .xml, .properties etc


Wednesday, December 7, 2011

java.io.FileNotFoundException: log4j.xml (No such file or directory)

If you get below mentioned error

log4j:ERROR Could not parse url [file:log4j.xml].
java.io.FileNotFoundException: log4j.xml (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.(FileInputStream.java:106)
        at java.io.FileInputStream.(FileInputStream.java:66)
        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
        at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:180)
        at org.apache.log4j.xml.DOMConfigurator$2.parse(DOMConfigurator.java:612)
        at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:711)
        at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:618)
        at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470)
        at org.apache.log4j.LogManager.(LogManager.java:122)
        at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:254)
        at org.quartz.impl.StdSchedulerFactory.(StdSchedulerFactory.java:274)

Possible reason could be JVM is not able to find the provided file log4j.xml. Make sure the file is present in the location and You could pass the file in command line as shown below.

java -Dlog4j.configuration=file:/home/log4j.xml com.TestJava

OR add directly in your Java code.

System.setProperty("log4j.configuration", "/home/log4j.xml");

If you are using Eclipe IDE you can pass through VM arguments by steps shown below

Right click on Java -> Run As -> Run Configurations.. -> Arguments tab -> VM arguments

add the below code

-Dlog4j.configuration=file:/home/log4j.xml

Apply -> Run

Thursday, November 10, 2011

keytool error: java.io.FileNotFoundException

If you get below mentioned error

keytool error: java.io.FileNotFoundException: keystore (Permission denied)

This may occur because you don't have access to the folder in which you are trying to create keystore.
Make sure you have access to that folder, OR Create keystore in the folder where you have access.