Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization 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
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Eclipse error with first try of log4j2  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

This is my first attempt with log4j in eclipse-I am getting an error (attached) that access to the project folder is denied.
Any ideas on what I am doing wrong? I checked the access permissions up the directory tree for the project..in windows 10
they are all read only.

thanks..
error2.png
[Thumbnail for error2.png]
error3.png
[Thumbnail for error3.png]
 
Vibhav Parghi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also here is the code...
error4.png
[Thumbnail for error4.png]
 
Sheriff
Posts: 24369
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vibhav Parghi wrote:I checked the access permissions up the directory tree for the project..in windows 10 they are all read only.



Well, you know you can't update files in a folder which is read-only, or create new files there, right?
 
Vibhav Parghi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
correct...that means is log4j trying to write to the project folder? i tried removing the read only check box for the entire directory tree...that gave me a different error..."class not found exception" for all the code in the maven project! any clues?
 
Paul Clapham
Sheriff
Posts: 24369
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vibhav Parghi wrote:that means is log4j trying to write to the project folder?



It could mean that, yes.

i tried removing the read only check box for the entire directory tree



But you shouldn't have log4j writing logs into your project folder anyway. Your correct path would have been to configure log4j properly, and have it write logs to a folder in some other location.
 
Vibhav Parghi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
right...but I am only writing the logs to the console right now...attached is the config file...
Is log4j writing other stuff also? to the project directory? how can i solve that...thanks !
log4j-config.png
[Thumbnail for log4j-config.png]
 
Paul Clapham
Sheriff
Posts: 24369
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the stack trace that you posted, you can see that it's trying to open a FileInputStream which accesses a directory to which you don't have access. Unfortunately you didn't post the whole stack trace (and unfortunately you posted it as an image -- please don't do that, please copy and paste it). So we can't see the actual code which caused the exception.

At any rate you wouldn't be using a FileInputStream to write logs. So the problem must be something else. You could look at the actual stack trace and find out what.

I'd very much suggest you don't use folders which you don't have access to. That applies to your projects and anything else you install for them to use.
 
Saloon Keeper
Posts: 2504
321
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vibhav Parghi wrote:... Is log4j writing other stuff also? to the project directory? how can i solve that...thanks !


If you are using log4j2 version 2.9 or newer, you can set the log4j2.debug system property to get lots of detailed information.

For example:
C:\PMGR_b_pmgr_r100_support > java -Dlog4j2.debug -jar c:/path/to/MyApp.jar
DEBUG StatusLogger Using ShutdownCallbackRegistry class org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
DEBUG StatusLogger Not in a ServletContext environment, thus not loading WebLookup plugin.
DEBUG StatusLogger AsyncLogger.ThreadNameStrategy=UNCACHED (user specified null, default is UNCACHED)
TRACE StatusLogger Using default SystemClock for timestamps.
DEBUG StatusLogger Not in a ServletContext environment, thus not loading WebLookup plugin.
DEBUG StatusLogger Took 0.084696 seconds to load 203 plugins from sun.misc.Launcher$AppClassLoader@55f96302
DEBUG StatusLogger PluginManager 'Converter' found 42 plugins
DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
...
 
Vibhav Parghi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the input.
I have re installed the workspace and created a new project in E:\ drive, and given write permission.
but log4j2 code is still referring to the older path and saying access is denied...any idea why
the code is referring to the older path of the project? everything is newly installed.Thanks.

here is the stack trace :
ERROR StatusLogger Unable to access file:/C:/Users/HP/git/repository/Examples/first_project
java.io.FileNotFoundException: C:\Users\HP\git\repository\Examples\first_project (The system cannot find the path specified)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86)
at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:184)
at java.base/java.net.URL.openStream(URL.java:1117)
at org.apache.logging.log4j.core.config.ConfigurationSource.fromUri(ConfigurationSource.java:248)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:405)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:347)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:261)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:616)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:637)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:243)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:648)
at Advanced_Core_java.Advanced_core_java.log4j2Example.<clinit>(log4j2Example.java:7)
ERROR StatusLogger Reconfiguration failed: No configuration found for '277050dc' at 'null' in 'null'
11:58:36.882 [main] ERROR Advanced_Core_java.Advanced_core_java.log4j2Example - Error Message Logged !!!
java.lang.NullPointerException: NullError
at Advanced_Core_java.Advanced_core_java.log4j2Example.main(log4j2Example.java:13) [classes/:?]
 
Vibhav Parghi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved the previous error , access denied and path not found,
but now I am getting new error

Error: Could not find or load main class Advanced_Core_java.Advanced_core_java.log4j2Example
Caused by: java.lang.ClassNotFoundException: Advanced_Core_java.Advanced_core_java.log4j2Example

Advanced_Core_java is the name of my maven project. I think some path or classpath setting is missing?
thanks.
 
Sheriff
Posts: 5924
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you launching the app?
 
Vibhav Parghi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved the problem...I re cloned the repository from remote and It has fixed itself!!
Thanks!
 
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!