[jetty-user] Tomcat context -> Jetty

Stephan Beutel <[email protected]>
Newsgroups gmane.comp.java.jetty.support
Message-ID <[email protected]>
  Hello,

I've a problem porting a working tomcat context to jetty.

My context.xml in Tomcat looks like this:
--------------
<?xml version='1.0' encoding='utf-8'?>
<Context>

<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>

<!-- Uncomment this to disable session persistence across Tomcat 
restarts -->
<!--
<Manager pathname="" />
     -->

<!-- Uncomment this to enable Comet connection tacking (provides events
          on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
     -->

<Resource name="jdbc/first" auth="Container" type="javax.sql.DataSource"
                maxActive="100" maxIdle="30" maxWait="10000"
                username="sa" password="" driverClassName="org.sqlite.JDBC"
                url="jdbc:sqlite:C:\firstDB.db"/>

<Resource name="jdbc/second" auth="Container" type="javax.sql.DataSource"
                maxActive="100" maxIdle="30" maxWait="10000"
                username="sa" password="" driverClassName="org.sqlite.JDBC"
                url="jdbc:sqlite:C:\secondDB.db"/>

<Resource name="jdbc/third" auth="Container" type="javax.sql.DataSource"
                maxActive="100" maxIdle="30" maxWait="10000"
                username="sa" password="" driverClassName="org.sqlite.JDBC"
                url="jdbc:sqlite:C:\thirdDB.db"/>

<Environment name="dataSourceNames" value="first, second, third" 
type="java.lang.String"
                 override="false"/>

<Environment name="dataSourceList" value="jdbc/first, jdbc/second, 
jdbc/third" type="java.lang.String"
                 override="false"/>

</Context>
---------------

In Spring I do the lookup for the Environment beans:

<jee:jndi-lookup id="dataSources" jndi-name="dataSourceList" />
<jee:jndi-lookup id="dataSourceNames" jndi-name="dataSourceNames" />


Putting the datasources in Jetty is no Problem and working:

<Configure id='axivion' class="org.mortbay.jetty.webapp.WebAppContext">
---
<New id="oss" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/first</Arg>
<Arg>
<New class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<Set name="driverClassName">org.sqlite.JDBC</Set>
<Set name="url">jdbc:sqlite:C:\firstDB.db</Set>
<Set name="username"></Set>
<Set name="password"></Set>
</New>
</Arg>
</New>
...
</Configure>


But how is it possible to set the put my two String vars 
(dataSourceNames, dataSourceList) to Jetty context?
I tried it in that was:

<New id="dataSourceList" class="org.mortbay.jetty.plus.naming.EnvEntry">
<Arg>dataSourceList</Arg>
<Arg type="java.lang.String">jdbc/first, jdbc/second</Arg>
<Arg type="boolean">true</Arg>
</New>

<New id="dataSourceNames" class="org.mortbay.jetty.plus.naming.EnvEntry">
<Arg>dataSourceNames</Arg>
<Arg type="java.lang.String">first, second</Arg>
<Arg type="boolean">true</Arg>
</New>

Starting the server causes an exception when initializing the context:

Caused by: javax.naming.NameNotFoundException; remaining name 
'dataSourceList'
     at org.mortbay.naming.NamingContext.lookup(NamingContext.java:578)
     at org.mortbay.naming.NamingContext.lookup(NamingContext.java:680)
     at 
org.mortbay.naming.local.localContextRoot.lookup(localContextRoot.java:164)
     at javax.naming.InitialContext.lookup(InitialContext.java:392)
     at 
org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
     at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
     at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
     at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
     at 
org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
     at 
org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
     at 
org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
     at 
org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
     at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
     at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
     ... 40 more

Any ideas how I could solve this?

Regards
Stephan

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.