Looks like libprotobuf.jar is missing.  The code generated by protoc depends
on this library.

On Fri, Nov 27, 2009 at 5:06 AM, Hershiv Haria <darkmaste...@gmail.com>wrote:

> I am trying out protocol buffers for the first time, and have written
> a simple client and servlet to send and receive the PB. It will run on
> App Engine. However every time I try it hits a NoClassDefFoundError
> for GeneratedMessages.
>
> The error is:
>
> ov 27, 2009 12:54:38 PM com.google.apphosting.utils.jetty.JettyLogger
> warn
> WARNING: Error for /testfileupload
> java.lang.NoClassDefFoundError: com/google/protobuf/GeneratedMessage
>        at java.lang.ClassLoader.defineClass1(Native Method)
>        at java.lang.ClassLoader.defineClass(ClassLoader.java:700)
>        at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
> 124)
>        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
>        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
>        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
>        at
> com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass
> (IsolatedAppClassLoader.java:151)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:254)
>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:399)
>        at my.testfiletransfer.TestFileUploadServlet.doGet
> (TestFileUploadServlet.java:28)
>        at my.testfiletransfer.TestFileUploadServlet.doPost
> (TestFileUploadServlet.java:20)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
>        at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
> 487)
>        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
> (ServletHandler.java:1093)
>        at
> com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter
> (TransactionCleanupFilter.java:43)
>        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
> (ServletHandler.java:1084)
>        at com.google.appengine.tools.development.StaticFileFilter.doFilter
> (StaticFileFilter.java:121)
>        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
> (ServletHandler.java:1084)
>        at org.mortbay.jetty.servlet.ServletHandler.handle
> (ServletHandler.java:360)
>        at org.mortbay.jetty.security.SecurityHandler.handle
> (SecurityHandler.java:216)
>        at org.mortbay.jetty.servlet.SessionHandler.handle
> (SessionHandler.java:181)
>        at org.mortbay.jetty.handler.ContextHandler.handle
> (ContextHandler.java:712)
>        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
> 405)
>        at
> com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle
> (DevAppEngineWebAppContext.java:54)
>        at org.mortbay.jetty.handler.HandlerWrapper.handle
> (HandlerWrapper.java:139)
>        at com.google.appengine.tools.development.JettyContainerService
> $ApiProxyHandler.handle(JettyContainerService.java:342)
>        at org.mortbay.jetty.handler.HandlerWrapper.handle
> (HandlerWrapper.java:139)
>        at org.mortbay.jetty.Server.handle(Server.java:313)
>        at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
> 506)
>        at org.mortbay.jetty.HttpConnection$RequestHandler.content
> (HttpConnection.java:844)
>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
>        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
>        at org.mortbay.io.nio.SelectChannelEndPoint.run
> (SelectChannelEndPoint.java:396)
>        at org.mortbay.thread.BoundedThreadPool$PoolThread.run
> (BoundedThreadPool.java:442)
> Caused by: java.lang.ClassNotFoundException:
> com.google.protobuf.GeneratedMessage
>        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
>        at
> com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass
> (IsolatedAppClassLoader.java:151)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:254)
>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:399)
>        ... 39 more
>
>
>
>
>
> ------------------------------------------------------------------------------------------------------
>
> The client is:
>
> package my.testfiletransfer;
>
> import java.io.BufferedReader;
> import java.io.File;
> import java.io.FileReader;
> import java.io.IOException;
> import java.io.InputStreamReader;
> import java.net.URL;
> import java.net.URLConnection;
>
> import my.tft.protos.RandomMessageProtos.Note;
> import my.tft.protos.RandomMessageProtos.RandomMessage;
>
> public class TestFileUploadClient {
>
>        public static void main(String[] args) {
>
>                BufferedReader in = null;
>                try {
>                        System.out.println("starting client");
>                        File source = new
> File("/Users/darkmaster108/Documents/blarg.txt");
>                        URL url = new URL("
> http://localhost:8080/testfileupload";);
>                        URLConnection urlc = url.openConnection();
>                        urlc.setDoOutput(true);
>                        urlc.connect();
>
>                        RandomMessage.Builder randomMessage =
> RandomMessage.newBuilder();
>                        Note.Builder note = Note.newBuilder();
>                        note.setName(source.getName());
>                        StringBuffer sb = new StringBuffer();
>
>                        in = new BufferedReader(new FileReader(source));
>
>                        String line;
>                        while ((line = in.readLine()) != null)
>                                sb.append(line);
>
>                        note.setMessage(sb.toString());
>
>                        randomMessage.addNote(note);
>
>  randomMessage.build().writeTo(urlc.getOutputStream());
>                        urlc.getOutputStream().close();
>
>                        BufferedReader rd = new BufferedReader(new
> InputStreamReader(urlc
>                                        .getInputStream()));
>
>                        System.out.println("Respose is:");
>                        while ((line = rd.readLine()) != null) {
>                                System.out.println(line);
>                        }
>                        rd.close();
>
>                } catch (Exception e) {
>                        e.printStackTrace();
>                } finally {
>                        if (in != null) {
>                                try {
>                                        in.close();
>                                } catch (IOException e) {
>                                        e.printStackTrace();
>                                }
>                        }
>                } // finally
>        }
> }
>
>
>
> ------------------------------------------------------------------------------------------------------
> The server is:
>
> package my.testfiletransfer;
>
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.PrintWriter;
>
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
>
> import my.tft.protos.RandomMessageProtos.RandomMessage;
>
> @SuppressWarnings("serial")
> public class TestFileUploadServlet extends HttpServlet {
>
>        public void doPost(HttpServletRequest req, HttpServletResponse resp)
>        throws IOException {
>                doGet(req, resp);
>        }
>
>        public void doGet(HttpServletRequest req, HttpServletResponse resp)
>                        throws IOException {
>
>                try {
>                        InputStream is = req.getInputStream();
>                        RandomMessage randomMessage =
> RandomMessage.parseFrom(is);
>                        is.close();
>
>                        System.err.println("Name: " +
> randomMessage.getNote(1).getName());
>                        System.err.println("Message: " +
> randomMessage.getNote(1).getMessage
> ());
>
>                        PrintWriter out = resp.getWriter();
>                        out.println("ok");
>                        out.close();
>                } catch(Exception e) {
>                        System.err.println(e.getMessage());
>                }
>        }
> }
>
> Any help would be much appreciated, I'm sure I'm making a silly little
> mistake.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.


Reply via email to