project working in tomcat but not working from eclipse. error :cant find log4j.properties - eclipse

I have a struts project which, I have imported to eclipse from a war file.
This is working perfectly by deploying it in tomcat. But the same after importing is showing up the error :
log4j:ERROR Could not read configuration file from URL [file:/D:/xxxfolder/xxxworkspace/xxxproject/WebContent/WEB-INF/classes/log4j.properties].
java.io.FileNotFoundException: D:xxx\xxx\xxx\WebContent\WEB-INF\classes\log4j.properties (The system cannot find the path specified)
I have the log4j.property in src folder.
Please help with proper solution to get rid of it !
Let me know if needed more info
EDIT!
I got the root of problem but cant find the solution
Bu default the ouput build path for src in eclipse is :build/classess. but the tomcat is searching the file at webContent/web_inf/ Classess/ Can you suggest how to do it . how to change the output file of only log4j to the specific it is tomcat is searching in.

In the comments above, the conclusion is that, the path is incorrect. After modifying the path, the issue is resolved.

Related

i got a eclipse neon EE ver. and made a spring project, but it's o stuck like those, 2 errors

2 errors : like this (follow the pict)
enter image description here
in a detail.. it's said
1.
Description Resource Path Location Type
Archive for required library: 'C:/Users/Administrator/.m2/repository/org/hibernate/hibernate-core/4.2.1.Final/hibernate-core-4.2.1.Final.jar' in project 'spring' cannot be read or is not a valid ZIP file spring Build path Build Path Problem
2.
Description Resource Path Location Type
The project cannot be built until build path errors are resolved spring Unknown Java Problem
i think it's cuz of a wrong path or no jar file
yeah but so what?
could you advice me some steps to solve it? plz...
Check the jar file written in the error message:
C:/Users/Administrator/.m2/repository/org/hibernate/hibernate-core/4.2.1.Final/hibernate-core-4.2.1.Final.jar
Is it there? Can you open it manually as a zip?
Occasionally it happens that the jar file is not correctly downloaded from the artifactory (when it happens it usually has 0kb size).
Delete the jar file, and let Maven redownload it again, it usually does the trick.
If it does not solve it, there may be a permission problem (does Eclipse has right to write under that path?), or an artifactory problem (are you using the central repository?) or even antivirus could block the download.

Hibernate configuration with tomcat and eclipse

I'm creating a webApp in eclipse using tomcat & hibernate (for mysql). Ive unit tested by code and I am able to connect to the db and pull data, but I'm running into issues when trying it from the web app.
From the exception it looks like it isnt able to get to the hibernate.cfg.xml, but I've tried placing the file in the src folder, WEB-INF/lib & WEB-INF/classes but I still get the same error.
The line of code that it's failing on is:
Configuration configuration = new Configuration();
I would really really appreciate any help!
ClassPath References:
Project References:
Stacktrace:
java.lang.ExceptionInInitializerError
org.hibernate.cfg.Configuration.reset(Configuration.java:324)
org.hibernate.cfg.Configuration.<init>(Configuration.java:289)
org.hibernate.cfg.Configuration.<init>(Configuration.java:293)
root cause
java.lang.NullPointerException
org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)
org.hibernate.cfg.Environment.<clinit>(Environment.java:221)
org.hibernate.cfg.Configuration.reset(Configuration.java:324)
org.hibernate.cfg.Configuration.<init>(Configuration.java:289)
org.hibernate.cfg.Configuration.<init>(Configuration.java:293)
SOLUTION
Thanks to #Engineer, I was able to solve this by removing the jars from WEF-INF/lib & from the class path of the run configuration. Then I added them back using the "Deployment Assembly" menu in eclipse. I also have my project references here.
From Ranga Reddy:
Problem: Because of adding the jars in user library class path.
Solution: Instead of adding the jar files using User Library add the jars using classpath.

Spring STS can't find META-INF/spring.schemas

Trying to set up a new project, and running into a weird issue. I made a new app context file named backend-context.xml, I've added spring-context as a dependency, and am trying to add namespaces through the bean config file, but it's showing as 1 error, with no explaination.
If I browse into problem explorer, it states the following error:
'Unable to load schema mappings from location [META-INF/spring.schemas]'
If I browse through the Maven Dependencies I can see this file located under the spring-beans jar.
If anyone has ideas on how to fix this, that'd be awesome!
Thanks!
Ended up being caused by a local maven jar being corrupt. Found this out by uploading the code to github and trying on a different computer which worked like a charm. So, cleaned out my local repository from all spring jars and redownloaded.

Problems deploying WAR file from Netbeans to Tomcat

I'm trying to configure build.xml files for build forge, but it seems like I am having trouble with the libraries required for the java servlet pages. I am actually trying to use OWASP's AntiSamy library but I keep getting a Policy Exception followed by a file not found
org.owasp.validator.html.PolicyException: java.io.FileNotFoundException: C:\Program%20Files \Apache%20Software%20Foundation\apache-tomcat-6.0.29\webapps\XSSDemo\WEB-INF\classes\...\antisamy.xml (The system cannot find the path specified)
The antisamy.xml file is definitely in this location, however.
So I tried using Netbeans to clean and build a WAR file that I would have expected to work, since the web app works fine when I run it through Netbeans. However, I get the same problem. Is there possible some reference that Netbeans is creating when I run the app through the ide that is not occurring in the WAR deployment? Could the URL Encoding in the antisamy.xml location be causing problems?
Thanks for the help.
Edit: I compressed the long class path into the three dots here. The actual response has the actual class path. I am not getting any kind of security errors.
The problem I had was not actually with the deployment--it was the file reference itself in my java servlet. The encoding in the path '%20' in the Program Files folder caused a FileNotFoundException. The reason this did not occur in netbeans is because the deployed files are in a c:\users... folder and there are no spaces to be encoded. The also explained why the application ran well on other computers with their tomcat folders directly on the root directory. This is the actual solution to my problem. Thanks for all your help.

Error when deploying WAR file

I have a war file and when deploying it thro the admin console in websphere i am getting the following error after specifying the war file location and the context-root.
The EAR file might be corrupt or incomplete.
org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException: WEB-INF/web.xml
Any suggesstions to resolve this issue?
I also unpacked the war file and checked that the web.xml file is present in the web-inf folder.
Cheers,
Deena
I had the same problem and after much searching (and even posting a bounty for this problem), I found the issue was comments in web.xml.
I was lucky enough to have a source branch that didn't have the comments and worked and this other branch that did have the comments and broke.
Removing the comments allowed WebSphere's validator to get past that error... fun stuff..