I was trying to embed Tomcat in my application only to discover that 
Embedded.createContext relies on ProxyDirContext from 
org.apache.naming.resources.  I can't seem to find the jar that contains this 
class, though I can find references to JavaDocs for it.  I'm running Tomcat 
4.1 and am a little confused.  Any help here would be appreciated.  :)

Here is the stack trace:

Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/naming/resources/ProxyDirContext
        at org.apache.catalina.startup.Embedded.createContext(Embedded.java:588)
        at com.look.core.EmbeddedTomcat.startTomcat(EmbeddedTomcat.java:58)
        at com.look.core.Main.main(Main.java:24)

And the class is a modified version of an example from an OnJava article, and 
is included here.

import org.apache.catalina.*;
import org.apache.catalina.logger.*;
import org.apache.catalina.startup.*;


/**
 * @author etriaph
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class EmbeddedTomcat
{
        private String   m_path     = null;
        private Embedded m_embedded = null;
        private Host     m_host     = null;

        public EmbeddedTomcat()
        {
                
        }
        
        public EmbeddedTomcat(String path)
        {
                setPath(path);
        }
        
        public void setPath(String path)
        {
                m_path = path;
        }
        
        public void startTomcat() throws Exception
        {
                Engine engine = null;
                
                System.setProperty("catalina.path", getPath());
                
                m_embedded = new Embedded();
                
                m_embedded.setDebug(0);
                m_embedded.setLogger(new SystemOutLogger());
                
                engine = m_embedded.createEngine();
                engine.setDefaultHost("localhost");
                
                m_host = m_embedded.createHost("localhost", getPath() + "/webapps");
                engine.addChild(m_host);
                
                Context context = m_embedded.createContext("", getPath() + 
"/webapps/ROOT");
                m_host.addChild(context);
                
                m_embedded.addEngine(engine);
                
                Connector connector = m_embedded.createConnector(null, 8080, false);
                m_embedded.addConnector(connector);
                
                m_embedded.start();
        }
        
        public String getPath()
        {
                return( m_path );
        }
        
        public void stopTomcat() throws Exception
        {
                m_embedded.stop();
        }
}

Again, I would love to get an opinion on this, or perhaps a URL to a jar that 
contains the classes needed.

Thanks in advance!

--
Robert Charbonneau
[EMAIL PROTECTED]
--


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to