i couldn't understand what my problem is.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
i will check the java permissions
BufferedReader input = new BufferedReader(new
FileReader("blabla.txt"));
it works while developping with eclipse.
and i am trying to write whit the fallowing:
BufferedWriter out = new BufferedWriter(new FileWriter("blabla.txt"));
out.write(liste);
out.close();
both works fine on eclipse.
when i upload to server the first one gives a long error message
saying "file not found" in tomcat log file as i mentioned before.
second one gives onli on word in tomcat log "Exception".
while debugging the output in the browser is:
java.security.AccessControlException: access denied
(java.io.FilePermission ./vini.xml write)
if i don't set the fileXml.setWritable(true) it works fine! but not
when i deploy the app in tomcat6
where can i set the permissions?
i tried to add this
grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" {
permission java.security.AllPermission;
};
in /etc/tomcat6/policy.d/03catalina.policy but it doesn't work....
Give out new File("blabla.txt").getAbsolutePath() and
make sure that the location java.io.File thinks you
are meaning is actually the location you intend to
access.
Regards, Lothar
i could solve the reading problem with the fallowing code.
ServletContext sc = this.getServletConfig().getServletContext();
InputStream is = sc.getResourceAsStream("/blabla.txt");
BufferedReader input = new BufferedReader(new InputStreamReader(is));
when i use the lothar's way i saw that it's serching the file in "/usr/
share/tomcat5/" directory.
so if i use only the file name it doesn't search in the application
directory.
ServletContext sc = this.getServletConfig().getServletContext();
BufferedWriter out = new BufferedWriter(new
FileWriter(sc.getRealPath("/blabla.txt")));
with this code writing problem is also solved.
but there is one point to notice: tomcat user must have the write
permission on the file.
thank you everyone
thx
try {
String fileXml = new String();
String s = new String();
FileReader f = new FileReader("vini.xml");
BufferedReader br = new BufferedReader(f);
do {
s = br.readLine();
if (s!=null)
fileXml=s;
} while (s!=null);
it works while debugging.. but when i deploy:
java.io.FileNotFoundException: vini.xml (No such file or
directory)java.io.FileNotFoundException: vini.xml (No such file or
directory)[Ljava.lang.StackTraceElement;@115126e
the file is present in this dir /var/lib/tomcat6/webapps/rpcTest0..
and i can't get the absolute path of f because there is no method.. grr
i'm from italy.. near modena, im a student of computer science at
unibo, it's about 3 weeks that i try to learn gwt cause i will have a
project for the university that need it.. this is just an exercise to
make practice in preparation of... the whole exercise is to read an
xml file and write it in the browser.. but if i can't read it i can't
go ahead.. uff
and what about you? are u italian too? whats your occupation?
On Apr 7, 2:36 pm, Giovanni Gaglione <giovanni.gagli...@gmail.com>
wrote:
> It seems that application doesn't find the file.
> Where is your file?
> It's possible that you must specify the file path better.
>
> Where are you from?
> What are you doing with GWT?
> Who are you?
>
> regards
>
> 2010/4/7 andrew19881123 <andrew19881...@gmail.com>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsubs cr...@googlegroups.com>
avevo provato anche io a creare un file.. cosi' da vedere dv cavolo lo
mette e d conseguenza c piazzo il mio xml.. l'avevo fatto cosi':
File file = new File("test.txt");
if (file.exists()) {
file.delete();
}
try {
file.createNewFile();
} catch (IOException e1) {
e1.printStackTrace();
}
System.out.println("Before. canWrite?" + file.canWrite());
// set to read-only, atau canWrite = false
file.setWritable(false);
System.out.println("After. canWrite?" + file.canWrite());
il problema e' che sempre x colpa dei permessi java nn puo scrivere
nella cartella..
oltretutto ho provato anche un altro metodo x leggere un file, solo
che in seguito al metodo canWrite() scatta l'eccezione e nn capisco il
motivo dato che dovrebbe essere solo un si o un no.. vedi se riesci a
creare il file con quel codice e poi fammi sapere
ciao
On Apr 7, 3:52 pm, Giovanni Gaglione <giovanni.gagli...@gmail.com>
wrote:
> auhauha
> Io pure sono italiano!!!!
> di roma però.
> sto facendo la tesi per la laurea triennale in informatica...e utilizzo gwt
> da un mesetto o di più.
>
> Hai settato i permessi per il filesystem come ti avevo suggerito?
> Se il file non ha il permesso di essere letto, tomcat non lo trova.
>
> Che io sappia, ci stanno anche i permessi di tomcat sui file, magari
> potrebbe dipendere da questo.
> Se sgoogli un pochino, potresti vedere se è il caso tuo, vedendo come si
> settano i permessi di tomcat.
>
> Usi firebug? ti può convenire usarlo per vedere nel codice se è tutto
> aposto, se c'è qualche errore javascript, non so se mi spiego.
>
> Ma cosa ci stai facendo con gwt?
> Sai per caso come creare un file lato server? ti è capitato di fare un
> operazione simile con gwt?
>
> saluti
>
> 2010/4/7 andrew19881123 <andrew19881...@gmail.com>
> > > > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsubs cr...@googlegroups.com><google-web-toolkit%2Bunsubs
non so come altro aiutarti
saluti
then you can acces your file correctly.
while wrting the file:
ServletContext sc = this.getServletConfig().getServletContext();
BufferedWriter out = new BufferedWriter(new
FileWriter(sc.getRealPath("/blabla.txt")));
if you are using linux, tomcat user must have read and write rights of
the file.
good luck
Brad
[...]
import java.io.FileWriter;
[...]
private void postFile(String fileXml) {
try {
ServletContext sc = this.getServletConfig().getServletContext();
BufferedWriter out = new BufferedWriter(new
FileWriter(sc.getRealPath("/blabla.xml")));
} catch (Exception e) {
e.getStackTrace();
}
}
i have the following error: in FileWriter: java.io.FileWriter is not
supported by GAE's JRE. Why?
i need to complete this method for writing in the file a String
fileXml.. how can i do?
http://code.google.com/appengine/kb/java.html#writefile