last day (15 days later) » 

12:49
@RC. Hi !
user180100
13:01
hey
I am glad you are here :)
user180100
so I assume you did close the input
yeah ! let me show you the code
user180100
ok
package Beans;

import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.files.*;
import com.google.appengine.api.files.GSFileOptions.GSFileOptionsBuilder;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.Channels;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
uploaded it
user180100
13:03
writableFile,false
user180100
why false ?
why should it be true ?
user180100
because you want to lock the file as you are writting on it
Can you explain to me this point
I guess I don't understand this
user180100
if you don't lock the file can be locked by another thread
13:06
when should the lock be false ?
user180100
false = readonly
user180100
almost
So this fileService.openReadChannel(file, false); is alright ?
user180100
yes because you open for reading no need to reserve the file
user180100
13:07
what bothers me is that you should have a stacktrace
In the catch block I have exc.printStackTrace()
user180100
can you try this:
but I don't see anything inside the logs
what ?
user180100
AppEngineFile file = fileService.getBlobFile( new BlobKey( xmlKey ) );
user180100
optionsBuilder.setKey( xmlKey + "__out");
13:09
what is __out ?
user180100
nothing it's just a test to see what happens if IN != OUT
user180100
it should create a new blob
wait.. as I try it
user180100
ok
The remaining is alright
?
user180100
13:11
yep
user180100
just add the __out to the optionbuilder setKey
XML still is the same as I view it in the blobstore
user180100
do you have a new blob ?
user180100
(i.e. 2 xml)
no
but I have the image I uploaded
user180100
13:17
so still not working
user180100
can you try something else ?
I did this as you said
readChannel.close();

GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder();
optionsBuilder.setBucket("my-bucket");
optionsBuilder.setKey( xmlKey + "__out" );
optionsBuilder.setMimeType("text/html");
optionsBuilder.setAcl("public_read");
optionsBuilder.addUserMetadata("suhail", "gupta");

AppEngineFile writableFile = fileService.createNewGSFile(optionsBuilder.build());
FileWriteChannel writeChannel = fileService.openWriteChannel(writableFile,true);
was that ok ?
user180100
yes
user180100
add "throw exc" in the catch of UpdateXml
user180100
13:18
you need to add "throws Exception" to the method signature
I did this : writeChannel.closeFinally();

}catch(Exception exc) {
throw new RuntimeException("EXCEPTION !");
//exc.printStackTrace();
}
fine ?
user180100
no
user180100
throw exc;
user180100
the purpose is to have an idea of what's happening
ok wait..deploying it
user180100
13:21
ok
Hurray ! At least I could spot the exception which is "java.io.IOException"
user180100
nice
user180100
let me guess cannot open the input file ?
user180100
can you copy paste the stack?
13:26
I do not why but there are is no stack trace
in the logs
user180100
writer.println(exc); <=
user180100
you need to print the stack here
user180100
exc.printStackTrace(writer); // should do it
Should I add it in the bean or servlet ?
user180100
servlet
user180100
13:30
at the en of UploadImagesToAisle
user180100
}catch(Exception exc) {
user180100
exc.printStackTrace(writer); // should do it
I have already done that
user180100
wha'ts the output ?
nothing I don't see anything
This is my code of the servlet
package Servlets;

import com.google.appengine.api.files.AppEngineFile;
import com.google.appengine.api.files.FileService;
import com.google.appengine.api.files.FileServiceFactory;
import com.google.appengine.api.files.FileWriteChannel;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.*;
GAE logs don't display any error message or the trace
user180100
13:32
replace:
user180100
writer.println(exc);
user180100
by
user180100
exc.printStackTrace(writer);
user180100
the page should print the stacktrace
ok
Long trace :
wait..
ava.io.IOException at com.google.appengine.api.files.FileServiceImpl.translateException(FileServiceImp‌​l.java:661) at com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java‌​:634) at com.google.appengine.api.files.FileServiceImpl.create(FileServiceImpl.java:552) at
com.google.appengine.api.files.FileServiceImpl.createNewGSFile(FileServiceImpl.j‌​ava:165) at Beans.UpdateXml.appendKey(UpdateXml.java:54) at Servlets.UploadImagesToAisle.doPost(UploadImagesToAisle.java:88) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.jav‌​a:1166) at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUplo‌​adFilter.java:102) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.jav‌​a:1157) at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter‌​.java:35) at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.jav‌​a:1157) at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(Transactio‌​nCleanupFilter.java:43) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.jav‌​a:1157) at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandle‌​rMap.java:249) at org
user180100
13:38
UpdateXml.java:54 // whats here ?
user180100
(line 54)
It is inside the if block you mentioned at the start
user180100
yep
It is the statement that calls the bean method
user180100
means you cannot create the file with xmlKey
13:42
No ! neither any new file is created nor that XML is updated. Just the image is uploaded
user180100
Perhaps the problem is the bucket
It could be ! This is one thing I don't know what I have written
user180100
can you try :
user180100
optionsBuilder.setBucket(fileService.getDefaultGsBucketName())
ok wait..
getting exception trace :
java.lang.IllegalArgumentException: Must provide bucket at com.google.appengine.repackaged.com.google.common.base.Preconditions.checkArgume‌​nt(Preconditions.java:94) at com.google.appengine.api.files.GSFileOptions.(GSFileOptions.java:34) at com.google.appengine.api.files.GSFileOptions.(GSFileOptions.java:17) at
com.google.appengine.api.files.GSFileOptions$GSFileOptionsBuilder.build(GSFileOp‌​tions.java:157) at Beans.UpdateXml.appendKey(UpdateXml.java:54) at Servlets.UploadImagesToAisle.doPost(UploadImagesToAisle.java:88) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.jav‌​a:1166) at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUplo‌​adFilter.java:102) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.jav‌​a:1157) at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter‌​.java:35) at
user180100
13:49
ok this is now a configuration problem
user180100
did you authorize any bucket for your app ?
I don't remember doing so
user180100
I think that's the problem
can you make me understand what is the problem /
I know nothing about buckets
user180100
13:51
sorry I can't find a java reference
no problem I will search myself
first I just want to update the xml
user180100
you need to set up to write the file
how and what to set up ?
user180100
In the link I gave it's explained
let me check that
user180100
13:55
you need to create a bucket (I think you have already one) and authorize your app WRITE access to it
What makes you think I have one ?
user180100
because you read an existing xml file in your code
user180100
So once setup done, I think everything should work as expected, don't forget to remove the "__out" from your code
ok..I will give it a try
user180100
14:00
ok
user180100
have a nice day :)
thanks .. It was a nice debugging session :)
14:13
Is it necessary to enable billing to write to xml file in the blobstore ?
I have given the permission to the bucket by adding the service account name

last day (15 days later) »