Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Thursday, March 7, 2013

File not found issue with tomcat: URL Encoding

I have to admit, today was lot better than yesterday. My struggle started when I was asked to quickly ( I mean it, in 10 minutes or so..) deploy a POC application on amazon ec2 instance. It is a windows 2008 server, so installed tomcat as service under "Program Files" and installed java 7. Hoping my 5 pages application will fly in no time that's when I noticed an error stack on the tomcat console :(. Main root cause was:

"Caused by: java.io.FileNotFoundException: File 'C:\Program%20Files\apache-tomcat-7.0.29\webapps\xyz\WEB-INF\classes\createData.sql' does not exist"

I could see the file under WEB-INF\classes and that's when I realized that my URL is getting encoded, hence all spaces are getting replaced with %20.

I had below line of code which was causing the issues since there is no folder with name "Program%20Files" in the system.

String path = FileUtils.class.getClassLoader().getResource("createData.sql").getPath();
List readLines = FileUtils.readLines(new File(path));
I wrapped it using URI and BOOM problem went away.

String path = FileUtils.class.getClassLoader().getResource("createData.sql").getPath();
List readLines = FileUtils.readLines(new File(new URI(path).getPath()));

as usual I happy soul again.
Manisha                

Wednesday, February 6, 2013

Install applications without admin permission on windows machine


Off late I am living under processes and restriction world. Got confused correct? I am consulting at a place where I don't have any permission on my own laptop. I am not complaining about installing stuff but coping under certain directory and changing the environment varibales are restricted too.
Being a developer I live in code and wants full access to environment where I am living.  I found out that if you don't have Admin access to your machine you can still do things like administrator.
Create a "Temp" directory under c:\ drive. create a wintv directory under it and copy the cmd.exe underneath it. Boom now you can do anything on your machine. Copy any exe here and you can run them, install them. To change the environment variable just open the command prompt from c:\Temp\wintv directory and open Windows\System32\sysdm.cpl file. BOOM BOOM!!
You are unstoppable again :) Manisha

"." to open the home directory in windowns


Yesterday I was tweaking with my setting.xml which resides under ~\.m2\conf directory.

I was opening my explorer and then was making hundreds of click to reach there :O. A friend (Sachin) who was standing next to me showed me a nice shortcut to open home directory with one click.
Start -> Run -> Type just "." and hit enter.. Tadaaaa it will open your home directory. Thank you for showing Sachin.   I will remember, it now. Manisha