Problems deploying WAR file from Netbeans to Tomcat - netbeans

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.

Related

Prevent Eclipse (RAD) from generating code automaticly

I am working on a project, I have imported a jar file with the class files needed to connect to a web service, then added the wsdl to my project. The problem now is eclipse(rad) is generating java files, that I don't need and causing issues as the object already exist in the jar file. How to I prevent Eclipse(RAD) from auto generating java files from the wsdl, as I have wasted 2 days trying to force Eclipse(RAD) from generating these files, as they are unneeded and causing compile problems.
This is the solution I came up with. The issue is that it is not Maven causing this, this is Eclipse(RAD) my objects were in a package such as com.thispackage.servicename.v2 (upgrading from v1 to v2) but the name space in the wsdl was http://servicename.thispackage.com/v2 . as Mavin is not running the wsdl2java, there is no problem, I changed the name space to http://v2.servicename.thispackage.com When Eclipse compiles the wsdl2java fails as the objects already exist in a jar file (so it can not overwrite them) But Eclipse(RAD) will continue on with the compilation and deployment to local server. I just have to click OK to acknowledge the error but everything works as intended.
Not a great solution, and I will have to document it in the README.md (or find a real solution later) but this lets me do the real work I need to do, before I deal with this detail.

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.

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

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.

Expand WAR or EAR files in jBoss AS 7

I'm deploying a WebService project into a jBoss AS7, and everything goes OK except that jBoss doesn't expand my WAR or EAR file.
Already tried copying the file to the "jboss-as-7.1.0.Final\standalone\deployments" folder and using the WebConsole, but in both cases the result was the same.
If I deploy from within Eclipse everything runs OK.
I need it to expand my file because in the application initialization I scan the class
directories looking for the correct class to instantiate using reflection.
EDIT : Don't know if this a particular situation with jBoss AS 7 or with the jBoss AS family, because I already used WebSphere and jBoss Web and both of them expanded the files.
EDIT2 : Added a System.out with the execution path
MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath();
and it returns the following path
C:\jboss-as-7.1.0.Final\bin\content\ServerEAR.ear\Server.war\WEB-INF\classes
witch doesn't exist. So I did a search for the class name and fount it at
C:\jboss-as-7.1.0.Final\standalone\tmp\vfs\deployment5a9e98d5c43716c3\Server.war-e31a657d2bc3bd0f\WEB-INF\classes\r30
Isn't it possible to force JBoss to extract the files to the deployment folder? Or how can I get the previous path at run time.
Had forgotten about this question, so this is the way that I solved it:
public String getRealFilePath(String aFilePath) throws Exception
{
org.jboss.vfs.VirtualFile vFile = org.jboss.vfs.VFS.getChild(aFilePath);
URI fileNameDecodedTmp = org.jboss.vfs.VFSUtils.getPhysicalURI(vFile);
path = fileNameDecodedTmp.getPath();
System.out.println(path);
return path;
}
So at runtime I just need to call getRealFilePath() with the original question values, and problem solved ;)
I believe that you cannot force Jboss7 to auto expand the war file when deploying.
You can, however, copy the already expanded war and you shouldn't have any problems.
Actually, if you look closely at the Eclipse deployment, you will notice that it copies the whole directory to the deployment directory, not the war file itself.
Why do you need to deploy exploded, by the way? If you need to access and read some files as resources, you can have a look at classpath resources
Please check you classpath setting. I faced the same problem recently, and solved it by added system environment variables:
CLASSPATH=.;
C:\Program Files\Java\jdk1.6.0_10\lib;
C:\Program Files\Java\jdk1.6.0_10\lib\tools.jar;
C:\Program Files\Java\jdk1.6.0_10\lib\dt.jar; `

Tomcat reporting IncompatibleClassChangeError - classpath problem?

I'm trying to deploy an application to Tomcat 7 on a Windows server. I have a local copy set up and have tested with Eclipse without any trouble, but on the production server I get IncompatibleClassChangeError messages.
This had been a problem on the local server when there were problems with the classpath, but I configured the correct classpath in the server properties inside Eclipse and everything ran fine.
I'm new to Tomcat and from what I understand it should be reading jar files from my my WEB_INFO/classes directory, but when my jars are there the app doesn't want to load at all. When I move them to the $CATALINA_HOME/lib (I realize that's not where they should go) the app loads fine but reports the IncompatibleClassChangeError.
Why aren't my jars being read from WEB-INF/classes? Is there some configuration I should look at to fix this?
Webapp-specific JAR files should go in Webapp/WEB-INF/lib, not in Webapp/WEB-INF/classes. The Tomcat/lib should only be used for appserver specific libraries and optionally also JAR files which should be shared among the deployed webapplications.
There might be more into the IncompatibleClassChangeError, this can have an entirely different cause. But first try getting the JAR's in the right place. If in vain, then please update your question to include the detail message. This at least smells that you're putting JAR files of a different appserver make/version in the classpath.