|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Jetty Plus datasource configurationHi,
I'm trying to set up an Oracle DataSource in my jetty.xml: <Call name="addService"> <Arg> <New class="org.mortbay.jetty.plus.DefaultDataSourceService"> <Set name="Name">DataSourceService</Set> <Call name="addConnectionPoolDataSource"> <Arg>jdbc/dataSource</Arg> <!-- Configure the DataSource impl --> <Arg> <New class="oracle.jdbc.pool.OracleConnectionPoolDataSource"> <Set name="URL">jdbc:oracle:thin:@localhost:1521:mydb</Set> <Set name="User">xxx</Set> <Set name="Password">xxx</Set> </New> </Arg> </Call> </New> </Arg> </Call> OracleConnectionPoolDataSource implements javax.sql.ConnectionPoolDataSource I based my configuration on the docs at: http://jetty.mortbay.org/jetty/plus/datasources.html web.xml: <resource-ref> <description>Database connection pool datasource</description> <res-ref-name>jdbc/dataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> spring configuration: <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>jdbc/dataSource</value> </property> </bean> When I run I get the following exception: [java] org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.sql.DataSource] for property 'dataSource' Turning on debugging for org.mortbay.jndi seems to show that the lookup is working [java] [DEBUG,NamingContext,main] Looking up name="jdbc/dataSource" [java] [DEBUG,NamingContext,main] Looking up name="jdbc/dataSource" [java] [DEBUG,NamingContext,main] Looking up binding for jdbc for context=null [java] [DEBUG,NamingContext,main] Looking up binding for jdbc for context=null [java] [DEBUG,NamingContext,main] Looking up name="dataSource" [java] [DEBUG,NamingContext,main] Looking up name="dataSource" [java] [DEBUG,NamingContext,main] Looking up binding for dataSource for context=jdbc [java] [DEBUG,NamingContext,main] Looking up binding for dataSource for context=jdbc [java] [ERROR,ContextLoader,main] Context initialization failed My guess is that my jetty configuration is not correct, and that the datasource is not returned from the lookup but the Reference stored in the jndi context is. Does anyone have an Oracle datasource configured in the same way via Jetty Plus? Thanks, Mike Henderson ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar _______________________________________________ Jetty-support mailing list Jetty-support@... https://lists.sourceforge.net/lists/listinfo/jetty-support |
|
|
Re: Jetty Plus datasource configurationGreetings,
A javax.sql.ConnectionPoolDataSource is "a factory for pooled connections". PooledConnection[s] are, in turn, special variants of Connection designed for use in pooling implementations. Iow, it's a "datasource /for/ a connection pool", not [necessarily] a "datasource _with_ a connection pool". If OracleConnectionPoolDataSource does its own "internal pooling", then you want to set it up with 'addDataSource' and configure it appropriately. However, if it is not, in fact, a /pooling datasource/, then your configuration is "on the right track" but incomplete. Your [wrapping] pool configuration is not set (see comment "Configure the pool" in the referenced tutorial link)... Jetty uses StandardPoolDataSource from XAPool (Enhydra/ObjectWeb) for the pooling implementation. A "default" initialization of StandardPoolDataSource creates a pool of [2-50] objects with 'nulls' for username and password (i.e. cpds.getConnection( null, null ) ). However, your OracleConnectionPoolDataSource instance has an explicit user[name] and password set on it for the connections. So, it looks like your "connection pool" is trying to get a connection your "datasource" is not configured to give. My guess is that either the datasource is returning a 'null' connection (though, it shouldn't), or an exception is being missed. Either way, try configuring the pool as demonstrated in the tutorial. Regards, Anthony Michael Henderson wrote: > Hi, > > I'm trying to set up an Oracle DataSource in my jetty.xml: > > <Call name="addService"> > <Arg> > <New class="org.mortbay.jetty.plus.DefaultDataSourceService"> > <Set name="Name">DataSourceService</Set> > <Call name="addConnectionPoolDataSource"> > <Arg>jdbc/dataSource</Arg> > <!-- Configure the DataSource impl --> > <Arg> > <New class="oracle.jdbc.pool.OracleConnectionPoolDataSource"> > <Set name="URL">jdbc:oracle:thin:@localhost:1521:mydb</Set> > <Set name="User">xxx</Set> > <Set name="Password">xxx</Set> > </New> > </Arg> > </Call> > </New> > </Arg> > </Call> > > OracleConnectionPoolDataSource implements javax.sql.ConnectionPoolDataSource > > I based my configuration on the docs at: http://jetty.mortbay.org/jetty/plus/datasources.html > > web.xml: > > <resource-ref> > <description>Database connection pool datasource</description> > <res-ref-name>jdbc/dataSource</res-ref-name> > <res-type>javax.sql.DataSource</res-type> > <res-auth>Container</res-auth> > </resource-ref> > > spring configuration: > > > <bean id="dataSource" > class="org.springframework.jndi.JndiObjectFactoryBean"> > <property name="jndiName"> > <value>jdbc/dataSource</value> > </property> > </bean> > > When I run I get the following exception: > > [java] org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.sql.DataSource] for property 'dataSource' > > Turning on debugging for org.mortbay.jndi seems to show that the lookup is working > > [java] [DEBUG,NamingContext,main] Looking up name="jdbc/dataSource" > [java] [DEBUG,NamingContext,main] Looking up name="jdbc/dataSource" > [java] [DEBUG,NamingContext,main] Looking up binding for jdbc for context=null > [java] [DEBUG,NamingContext,main] Looking up binding for jdbc for context=null > [java] [DEBUG,NamingContext,main] Looking up name="dataSource" > [java] [DEBUG,NamingContext,main] Looking up name="dataSource" > [java] [DEBUG,NamingContext,main] Looking up binding for dataSource for context=jdbc > [java] [DEBUG,NamingContext,main] Looking up binding for dataSource for context=jdbc > [java] [ERROR,ContextLoader,main] Context initialization failed > > My guess is that my jetty configuration is not correct, and that the datasource is not returned from the lookup but the Reference stored in the jndi context is. > > Does anyone have an Oracle datasource configured in the same way via Jetty Plus? > > Thanks, > > > Mike Henderson > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening > July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual > core and dual graphics technology at this free one hour event hosted by HP, > AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar > _______________________________________________ > Jetty-support mailing list > Jetty-support@... > https://lists.sourceforge.net/lists/listinfo/jetty-support [vschade.vcf] begin:vcard fn:Anthony Cook n:Cook;Anthony org:Vee Schade Int'l adr:;;;Wilmington;North Carolina;;USA email;internet:vschade@... title:Web Development Consultant x-mozilla-html:FALSE version:2.1 end:vcard |
|
|
Re: Jetty Plus datasource configurationhi,
I want to create a jetty connection pool. So for that, i have created a new Java web app. In this, i created one jsp file to list the table content which is stored in derby database. code snippets of my index.jsp are: ====================== javax.naming.Context initContext = new javax.naming.InitialContext(); javax.naming.Context envContext = (Context) initContext.lookup("java:/comp/env"); javax.sql.DataSource ds = (DataSource) envContext.lookup("jdbc/TestDB"); java.sql.Connection conn = ds.getConnection(); java.sql.Statement stmt = conn.createStatement(); java.sql.ResultSet resultset = stmt.executeQuery("select * from tbl_user"); And my xml files under "web" package, of my project are: i) web.xml: ====== <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <session-config> <session-timeout>30</session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/TestDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> </web-app> ii) jetty-web.xml: =========== <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> <Configure class="org.mortbay.jetty.webapp.WebAppContext"> <New id="TestDB" class="org.mortbay.jetty.plus.naming.Resource"> <Arg>jdbc/TestDB</Arg> <Arg> <New class="org.apache.derby.jdbc.ClientBaseDataSource"> <Set name="driverClassName">org.apache.derby.jdbc.ClientDriver</Set> <Set name="url">jdbc:derby://localhost:1527/C:/DBs/EventsDB_NEW</Set> <Set name="username">sa</Set> <Set name="password">sa</Set> </New> </Arg> </New> <Array id="plusConfig" type="java.lang.String"> <Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item> <Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item> <Item>org.mortbay.jetty.plus.webapp.Configuration</Item> <Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item> <Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item> </Array> <Call class="org.mortbay.jetty.webapp.WebAppContext" name="addWebApplications"> <Arg><Ref id="Server"/></Arg> <Arg>./webapps</Arg> <Arg>org/mortbay/jetty/webapp/webdefault.xml</Arg> <Arg><Ref id="plusConfig"/></Arg> <Arg type="boolean">True</Arg> <!-- extract --> <Arg type="boolean">False</Arg> <!-- parent priority class loading --> </Call> </Configure> iii) jetty-env.xml: ========== <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> <Configure class="org.mortbay.jetty.webapp.WebAppContext"> <New id="TestDB" class="org.mortbay.jetty.plus.naming.Resource"> <Arg>jdbc/TestDB</Arg> <Arg> <!--<New class="org.apache.commons.dbcp.BasicDataSource">--> <New class="org.apache.derby.jdbc.ClientBaseDataSource"> <Set name="driverClassName">org.apache.derby.jdbc.ClientDriver</Set> <Set name="url">jdbc:derby://localhost:1527/C:/DBs/EventsDB_NEW</Set> <Set name="username">sa</Set> <Set name="password">sa</Set> </New> </Arg> </New> </configure> NOW, i compiled my web project, and make a war file of it. And i put this into jetty's webapp folder. Then i start jetty by, "java -jar start.jar etc/jetty.xml etc/jetty-plus.xml " I got the following ERROR..., 2009-08-29 15:03:46.687::WARN: Failed startup of context org.mortbay.jetty.weba pp.WebAppContext@110fe28{/JettyConnPoolTest,jar:file:/D:/JettyServer/jetty-6.1.3 /webapps/JettyConnPoolTest.war!/} java.lang.IllegalStateException: No object for id=Server at org.mortbay.xml.XmlConfiguration.refObj(XmlConfiguration.java:632) at org.mortbay.xml.XmlConfiguration.itemValue(XmlConfiguration.java:877) at org.mortbay.xml.XmlConfiguration.value(XmlConfiguration.java:798) at org.mortbay.xml.XmlConfiguration.call(XmlConfiguration.java:510) at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:241) at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:179) at org.mortbay.jetty.webapp.JettyWebXmlConfiguration.configureWebApp(Jet tyWebXmlConfiguration.java:109) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.jav a:1215) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java: 500) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448 ) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java: 40) at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection .java:147) at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHan dlerCollection.java:161) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java: 40) at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection .java:147) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java: 40) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java: 117) at org.mortbay.jetty.Server.doStart(Server.java:210) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java: 40) at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:929) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.mortbay.start.Main.invokeMain(Main.java:183) at org.mortbay.start.Main.start(Main.java:497) at org.mortbay.start.Main.main(Main.java:115) 2009-08-29 15:03:46.812::WARN: Unknown realm: Test JAAS Realm 2009-08-29 15:03:46.890::INFO: Started SelectChannelConnector @ 0.0.0.0:8080 So, anybody please help me to resolve the above error... Note, i am using Jetty-6.1.3 - this package downloaded from, " http://dist.codehaus.org/jetty/jetty-6.1.x/ " Please give me a solution to solve this problem.. Thanks in advance.noor@... |
| Free embeddable forum powered by Nabble | Forum Help |