java - Spring, Hibernate, C3P0 and Jetty -
i inherited project , trying run via jetty:run no avail. works fine using run-war or run-exploded, cant seem nail down issue plain old run. giving me following stack:
2012-06-28 15:02:32.247:info:/:initializing spring root webapplicationcontext warn [main] jdbcexceptionreporter.logexceptions(233) | sql error: 0, sqlstate: null error [main] jdbcexceptionreporter.logexceptions(234) | cannot create poolableconnectionfactory (access denied user 'root'@'localhost' (using password: no)) warn [main] settingsfactory.buildsettings(147) | not obtain connection query metadata org.apache.commons.dbcp.sqlnestedexception: cannot create poolableconnectionfactory (access denied user 'root'@'localhost' (using password: no)) @ org.apache.commons.dbcp.basicdatasource.createdatasource(basicdatasource.java:855) @ org.apache.commons.dbcp.basicdatasource.getconnection(basicdatasource.java:540) @ org.springframework.orm.hibernate3.localdatasourceconnectionprovider.getconnection(localdatasourceconnectionprovider.java:82) @ org.hibernate.cfg.settingsfactory.buildsettings(settingsfactory.java:114) @ org.hibernate.cfg.configuration.buildsettingsinternal(configuration.java:2833) @ org.hibernate.cfg.configuration.buildsettings(configuration.java:2829) @ org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:1840) @ org.springframework.orm.hibernate3.localsessionfactorybean.newsessionfactory(localsessionfactorybean.java:814) /src/main/resources/applicationcontext-resources.xml
<bean id="propertyconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="locations"> <list> <value>classpath:jdbc.properties</value> <value>classpath:mail.properties</value> </list> </property> </bean> <bean id="datasource" class="com.mchange.v2.c3p0.combopooleddatasource" > <property name="driverclass" value="${jdbc.driverclassname}"/> <property name="jdbcurl" value="${jdbc.url}"/> <property name="user" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> <property name="initialpoolsize" value="8"/> <property name="minpoolsize" value="8"/> <property name="maxpoolsize" value="32"/> <property name="idleconnectiontestperiod" value="600"/> <property name="maxidletime" value="0"/> <property name="maxstatements" value="0"/> <property name="maxstatementsperconnection" value="0"/> <property name="acquireincrement" value="3"/> <property name="acquireretryattempts" value="3"/> <property name="acquireretrydelay" value="1000"/> <property name="autocommitonclose" value="false"/> <property name="maxconnectionage" value="14400"/> <property name="forceignoreunresolvedtransactions" value="false"/> <property name="numhelperthreads" value="20"/> <property name="testconnectiononcheckin" value="false"/> <property name="testconnectiononcheckout" value="false"/> <property name="preferredtestquery" value="select id xtcirc101themes rownum = 1"/> <property name="maxadministrativetasktime" value="0"/> <property name="debugunreturnedconnectionstacktraces" value="false"/> <property name="maxidletimeexcessconnections" value="0"/> <property name="breakafteracquirefailure" value="false"/> <property name="checkouttimeout" value="0"/> <property name="unreturnedconnectiontimeout" value="0"/> <property name="usestraditionalreflectiveproxies" value="false"/> </bean> /src/main/resources/applicationcontext.xml
<bean id="sessionfactory" class="org.springframework.orm.hibernate3.annotation.annotationsessionfactorybean"> <property name="datasource" ref="datasource" /> <property name="annotatedclasses"> <list> . . . </list> </property> </bean> context configurations in /web-inf/web.xml
<context-param> <param-name>contextconfiglocation</param-name> <param-value> classpath:/applicationcontext-resources.xml classpath:/applicationcontext-dao.xml classpath:/applicationcontext-service.xml classpath*:/applicationcontext.xml /web-inf/applicationcontext*.xml /web-inf/classes/applicationcontext*.xml /web-inf/classes/tbmjobs*.xml /web-inf/xfire-servlet.xml /web-inf/security.xml </param-value> </context-param> /src/main/resources/jdbc.properties
jdbc.driverclassname=${jdbc.driverclassname} jdbc.url=${jdbc.url} jdbc.username=${jdbc.username} jdbc.password=${jdbc.password} hibernate.dialect=${hibernate.dialect} # needed hibernate3 maven plugin defined in pom.xml hibernate.connection.username=${jdbc.username} hibernate.connection.password=${jdbc.password} hibernate.connection.url=${jdbc.url} hibernate.connection.driver_class=${jdbc.driverclassname} properties configured in pom.xml
<properties> <dbunit.datatypefactoryname>org.dbunit.ext.oracle.oracledatatypefactory</dbunit.datatypefactoryname> <dbunit.schema>system</dbunit.schema> <hibernate.dialect>org.hibernate.dialect.oracle10gdialect</hibernate.dialect> <jdbc.groupid>com.oracle</jdbc.groupid> <jdbc.artifactid>ojdbc14</jdbc.artifactid> <jdbc.version>10.2.0.3.0</jdbc.version> <jdbc.driverclassname>oracle.jdbc.oracledriver</jdbc.driverclassname> <jdbc.url>jdbc:oracle:thin:@${oracle.host}:1521:${oracle.sid}</jdbc.url> <jdbc.username>*******</jdbc.username> <jdbc.password>*******</jdbc.password> </properties>
so, after research , lot of trial , error, looks culprit jetty-maven-plugin. project using version 6.1.9 , promptly changed 6.1.26 when realized didn't allow war-overlays when doing jetty:run. resulted in above error.
through trial , error, able determine there issue datasource bean , applicationcontext-resources.xml file. commenting out bean definition in xml file should have resulted in beancreationexception when trying create sessionfactory datasource not defined. this, however, proved untrue , resulted in same error, meaning referring different datasource, presumable configured default in spring? not sure @ point. renaming datasource datasource2 resolved issue, didn't solution.
reading more jetty plugin, decided migrate latest version of jetty 7. had decided stay 6 cause didn't want many changes @ once, moving 7 proved wise decision. issues datasource files went away. lead next set of issues, struts. seems overriding , reusing package names default , admin in our struts.xml. this, again, works fine run-war or run-exploded, run causes struts errors. using appfuse version 2.0.2, thinking updating well.
once able around struts issue, presented problems web.xml. we've been using resource filtering dynamically set values in our web.xml , couple jsp's. issue jetty:run assumes webapp files static , not apply resource filtering. using tag able tell jetty , war plugin use resource filtered version of web.xml. jsp's issue though.
a little googling , found . using properties file, able apply resource filtering , using spring, read values properties file when accessing jsp. finally, able jetty:run fire app. however, seems getting permgen space errors when tries hot-swap code. looks goes through multiple attmepts of restarting , results in permgen errors. i'm setting permgen size -xx:permsize=64m -xx:maxpermsize=128m. guess more trial , error time.
Comments
Post a Comment