title: Why I can't initialize a Mongo in Servlet
body: <p>I'm making java web project , and try to use mongodb.
  but I found a problem,</p>
  
  <pre><code>Mongo mongo = new Mongo("localhost", 27017)
  </code></pre>
  
  <p>when I use it in a main method, it is ok.
  but when I use it in Servlet init() or doGet, doPost
  it throws exceptions, it is like:</p>
  
  <pre><code>    Allocate exception for servlet RegServlet
  java.lang.ClassNotFoundException: com.mongodb.MongoException
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
      at java.lang.Class.getConstructor0(Class.java:2699)
      at java.lang.Class.newInstance0(Class.java:326)
      at java.lang.Class.newInstance(Class.java:308)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
      at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Thread.java:662)
  2011-5-19 20:44:39 org.apache.catalina.startup.HostConfig checkResources
  </code></pre>