You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Yoav Shapira <yo...@apache.org> on 2006/05/18 23:34:34 UTC

Re: Creating a context and deploying a new application on the fly. I tried but haven`t succeed please help :-)

Hola,
Why not just set autoDeploy="false" on your Host in server.xml, put
your webapp in the appBase directory like you normally would, and use
the manager interface (JMX, HTML, ant, your choice) to send the deploy
command?  That way you don't have to write any code...

Yoav

On 5/18/06, David Gagnon <dg...@siunik.com> wrote:
> Hi,
>
>   I want my tomcat have war unpacked on the disk.  The application will
> only be deployed when it receives a message...
>
> I tried with the following code without success.  My biggest problem for
> now is how to specify info for the jdbc connection.
>
> StandardContext context = new StandardContext();
>
> context.setDocBase("F:\\projects\\applicationServer\\var\\deploy\\base");
>             context.setPath("/as2");
>             context.setCrossContext(true);
>             context.setReloadable(false);
>
>             ContextResource resource = new ContextResource();
>             resource.setName("jdbc/reference");
>             resource.setAuth("Container");
>             resource.setType("javax.sql.DataSource");
>             resource.setProperty("driverClassName",
> "org.postgresql.Driver");
>             resource.setProperty("url",
> "jdbc:postgresql://127.0.0.1:5432/unikommerce");
>             resource.setProperty("username", "admin");
>             resource.setProperty("password", "admin");
>             resource.setProperty("maxActive", "25");
>             resource.setProperty("maxIdle", "10");
>             resource.setProperty("maxWait", "-1");
>
>             //context.getApplicationLifecycleListeners().get
>
> //            resource.set;
>
> /*
>                     <Resource name="jdbc/unikommerce" auth="Container"
>                               type="javax.sql.DataSource"
> driverClassName="org.postgresql.Driver"
>
> url="jdbc:postgresql://127.0.0.1:5432/unikommerce"
>                               username="admin" password="admin"
> maxActive="25" maxIdle="10" maxWait="-1"/>
>
> */
>
>
>             ContextConfig contextConfig = new ContextConfig();
>             context.addLifecycleListener(contextConfig);
>
> //            NamingContextListener l = new NamingContextListener();
> //            l.addResource(resource);
> //            contextConfig.setDefaultContextXml();
>
> //            container.setManager();
>             container.addChild(context);
>
>
> So far the application get deployed but fail because the JDBC resource
> is not available.
>
> Any help on how to do this will be greatly appreciated !
>
> Thanks
> best regards
> /David
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>


-- 
Yoav Shapira
Nimalex LLC
1 Mifflin Place, Suite 310
Cambridge, MA, USA
yoavs@computer.org / www.yoavshapira.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: Creating a context and deploying a new application on the fly. I tried but haven`t succeed please help :-)

Posted by David Gagnon <dg...@siunik.com>.
Hi! :-)

    My problem it that I don`t know at boot time how much applications I 
will need.  I want a sample web app and deploy it on X different context 
(/as1, /as2).
So I would like to have a simple application (exploded war directory) 
and deploy it X time usinng each time a different Resource (to connect 
to a different database).

So I cannot write (or think I cannot) a context.xml file neither I can 
specify a context in server.xml.  ...

I will look again into JMX, HTML or ant interface to see if I cannot 
find any Idea.

Best Regards
/David



 Shapira wrote:

> Hola,
> Why not just set autoDeploy="false" on your Host in server.xml, put
> your webapp in the appBase directory like you normally would, and use
> the manager interface (JMX, HTML, ant, your choice) to send the deploy
> command?  That way you don't have to write any code...
>
> Yoav
>
> On 5/18/06, David Gagnon <dg...@siunik.com> wrote:
>
>> Hi,
>>
>>   I want my tomcat have war unpacked on the disk.  The application will
>> only be deployed when it receives a message...
>>
>> I tried with the following code without success.  My biggest problem for
>> now is how to specify info for the jdbc connection.
>>
>> StandardContext context = new StandardContext();
>>
>> context.setDocBase("F:\\projects\\applicationServer\\var\\deploy\\base"); 
>>
>>             context.setPath("/as2");
>>             context.setCrossContext(true);
>>             context.setReloadable(false);
>>
>>             ContextResource resource = new ContextResource();
>>             resource.setName("jdbc/reference");
>>             resource.setAuth("Container");
>>             resource.setType("javax.sql.DataSource");
>>             resource.setProperty("driverClassName",
>> "org.postgresql.Driver");
>>             resource.setProperty("url",
>> "jdbc:postgresql://127.0.0.1:5432/unikommerce");
>>             resource.setProperty("username", "admin");
>>             resource.setProperty("password", "admin");
>>             resource.setProperty("maxActive", "25");
>>             resource.setProperty("maxIdle", "10");
>>             resource.setProperty("maxWait", "-1");
>>
>>             //context.getApplicationLifecycleListeners().get
>>
>> //            resource.set;
>>
>> /*
>>                     <Resource name="jdbc/unikommerce" auth="Container"
>>                               type="javax.sql.DataSource"
>> driverClassName="org.postgresql.Driver"
>>
>> url="jdbc:postgresql://127.0.0.1:5432/unikommerce"
>>                               username="admin" password="admin"
>> maxActive="25" maxIdle="10" maxWait="-1"/>
>>
>> */
>>
>>
>>             ContextConfig contextConfig = new ContextConfig();
>>             context.addLifecycleListener(contextConfig);
>>
>> //            NamingContextListener l = new NamingContextListener();
>> //            l.addResource(resource);
>> //            contextConfig.setDefaultContextXml();
>>
>> //            container.setManager();
>>             container.addChild(context);
>>
>>
>> So far the application get deployed but fail because the JDBC resource
>> is not available.
>>
>> Any help on how to do this will be greatly appreciated !
>>
>> Thanks
>> best regards
>> /David
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org