I have been successfully using C3P0 0.9.1.2 with Jetty 8.1.13.v20130916. In my Jetty server instance, using a Jetty XML configuration file, I bind a C3P0-backed DataSource to JNDI. Then my web application looks up this DataSource by name. This has always worked.
I'm currently migrating to C3P0 0.9.5-pre6 and to Jetty 9.1.0.v20131115.
Since this migration, C3P0 connection pooling doesn't work anymore. I have tried different unpooled and pooled strategies.
Since the migration, the following two unpooled binding strategies work:
<Configure id="Server" class="org.eclipse.jetty.server.Server">
....
<!-- raw mysql connection without C3P0 - THIS WORKS! -->
<New id="jdbc-myds" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/myds</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://localhost:3306/myds?useUnicode=true&characterEncoding=UTF-8</Set>
<Set name="User">user</Set>
<Set name="Password">pass</Set>
</New>
</Arg>
</New>
</Configure>
<Configure id="Server" class="org.eclipse.jetty.server.Server">
....
<!-- UNPOOLED c3p0 factory - THIS WORKS! -->
<New id="jdbc-myds" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/myds</Arg>
<Arg>
<Call class="com.mchange.v2.c3p0.DataSources" name="unpooledDataSource">
<Arg>jdbc:mysql://localhost:3306/myds?useUnicode=true&characterEncoding=UTF-8</Arg>
<Arg>user</Arg>
<Arg>pass</Arg>
</Call>
</Arg>
</New>
</Configure>
Since the migration, the following two pooled binding strategies don't work:
<Configure id="Server" class="org.eclipse.jetty.server.Server">
....
<!-- typical C3P0 pool configuration - THIS DOESN'T WORK FOR ME SINCE MIGRATION -->
<New id="jdbc-myds" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/myds</Arg>
<Arg>
<New class="com.mchange.v2.c3p0.ComboPooledDataSource">
<Set name="DriverClass">com.mysql.jdbc.Driver</Set>
<Set name="JdbcUrl">jdbc:mysql://localhost:3306/myds?useUnicode=true&characterEncoding=UTF-8</Set>
<Set name="User">user</Set>
<Set name="Password">password</Set>
</New>
</Arg>
</New>
</Configure>
<Configure id="Server" class="org.eclipse.jetty.server.Server">
....
<!-- wrapping the successfully working C3P0 unpooled DataSource in a pooled DataSource - THIS DOESN'T WORK -->
<New id="jdbc-myds" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/myds</Arg>
<Arg>
<Call class="com.mchange.v2.c3p0.DataSources" name="pooledDataSource">
<Arg>
<Call class="com.mchange.v2.c3p0.DataSources" name="unpooledDataSource">
<Arg>jdbc:mysql://localhost:3306/myds?useUnicode=true&characterEncoding=UTF-8</Arg>
<Arg>user</Arg>
<Arg>pass</Arg>
</Call>
</Arg>
</Call>
</Arg>
</New>
</Configure>
In the unsuccessful cases, when visiting the server, the server's HTTP response is a Jetty-served HTTP ERROR: 503, Service Unavailable.
Even though the server-startup logs say that the JNDI resource has been successfully registered, at the moment I am trying to access that JNDI resource by name inside my web application, it doesn't exist anymore: Calling
DataSource myds = new InitialContext().lookup("java:comp/env/jdbc/myds");
throws an InvalidClassException and a NamingException:
17:08:33.907 [main] WARN jndi -
java.io.InvalidClassException: com.mchange.v2.c3p0.WrapperConnectionPoolDataSource; local class incompatible: stream classdesc serialVersionUID = -7086951306718003710, local class serialVersionUID = 7806429541739165290
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:617) ~[na:1.7.0_45]
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1622) ~[na:1.7.0_45]
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517) ~[na:1.7.0_45]
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771) ~[na:1.7.0_45]
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350) ~[na:1.7.0_45]
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370) ~[na:1.7.0_45]
at com.mchange.v2.ser.SerializableUtils.deserializeFromByteArray(SerializableUtils.java:132) ~[mchange-commons-java-0.2.6.3.jar:0.2.6.3]
at com.mchange.v2.ser.SerializableUtils.fromByteArray(SerializableUtils.java:111) ~[mchange-commons-java-0.2.6.3.jar:0.2.6.3]
at com.mchange.v2.naming.JavaBeanObjectFactory.createPropertyMap(JavaBeanObjectFactory.java:98) ~[mchange-commons-java-0.2.6.3.jar:0.2.6.3]
at com.mchange.v2.naming.JavaBeanObjectFactory.getObjectInstance(JavaBeanObjectFactory.java:59) ~[mchange-commons-java-0.2.6.3.jar:0.2.6.3]
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321) ~[na:1.7.0_45]
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:476) [jetty-jndi-9.1.0.v20131115.jar:9.1.0.v20131115]
at org.eclipse.jetty.jndi.local.localContextRoot.lookup(localContextRoot.java:518) [jetty-jndi-9.1.0.v20131115.jar:9.1.0.v20131115]
at org.eclipse.jetty.jndi.local.localContextRoot.lookup(localContextRoot.java:533) [jetty-jndi-9.1.0.v20131115.jar:9.1.0.v20131115]
at javax.naming.InitialContext.lookup(InitialContext.java:411) [na:1.7.0_45]
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:468) [jetty-jndi-9.1.0.v20131115.jar:9.1.0.v20131115]
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:536) [jetty-jndi-9.1.0.v20131115.jar:9.1.0.v20131115]
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:536) [jetty-jndi-9.1.0.v20131115.jar:9.1.0.v20131115]
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:536) [jetty-jndi-9.1.0.v20131115.jar:9.1.0.v20131115]
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:551) [jetty-jndi-9.1.0.v20131115.jar:9.1.0.v20131115]
at org.eclipse.jetty.jndi.java.javaRootURLContext.lookup(javaRootURLContext.java:117) [jetty-jndi-9.1.0.v20131115.jar:9.1.0.v20131115]
at javax.naming.InitialContext.lookup(InitialContext.java:411) [na:1.7.0_45]
at com.example.spring.config.MainConfig.dataSource(MainConfig.java:65) [classes/:na]
at com.example.spring.config.MainConfig$$EnhancerByCGLIB$$8673699d.CGLIB$dataSource$0(<generated>) [cglib-nodep-2.2.2.jar:na]
at com.example.spring.config.MainConfig$$EnhancerByCGLIB$$8673699d$$FastClassByCGLIB$$554d588d.invoke(<generated>) [cglib-nodep-2.2.2.jar:na]
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [cglib-nodep-2.2.2.jar:na]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:280) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at com.example.spring.config.MainConfig$$EnhancerByCGLIB$$8673699d.dataSource(<generated>) [cglib-nodep-2.2.2.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_45]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_45]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:149) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1015) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at .............(shortened for brevity)
17:08:33.908 [main] ERROR c.example.spring.config.MainConfig - Couldn't either create InitialContext or couldn't lookup jdbc/myds
javax.naming.NamingException: com.mchange.v2.c3p0.WrapperConnectionPoolDataSource; local class incompatible: stream classdesc serialVersionUID = -7086951306718003710, local class serialVersionUID = 7806429541739165290
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:485)
at org.eclipse.jetty.jndi.local.localContextRoot.lookup(localContextRoot.java:518)
at org.eclipse.jetty.jndi.local.localContextRoot.lookup(localContextRoot.java:533)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:468)
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:536)
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:536)
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:536)
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:551)
at org.eclipse.jetty.jndi.java.javaRootURLContext.lookup(javaRootURLContext.java:117)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at com.example.spring.config.MainConfig.dataSource(MainConfig.java:65)
at com.example.spring.config.MainConfig$$EnhancerByCGLIB$$8673699d.CGLIB$dataSource$0(<generated>)
at com.example.spring.config.MainConfig$$EnhancerByCGLIB$$8673699d$$FastClassByCGLIB$$554d588d.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:280)
at com.example.spring.config.MainConfig$$EnhancerByCGLIB$$8673699d.dataSource(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at .............(shortened for brevity)
Can anyone see any misconfiguration on my side?
#Joakim's suggestion helped me locate the problem's source and find a solution. The problem's source didn't have anything to do with Jetty 9.1, instead it stemmed from a Maven dependency library having a transitive dependency on an older C3P0 version 0.9.1.1:
My web application uses the Quartz scheduler, so my application's pom.xml included
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.0</version>
</dependency>
org.quartz-scheduler:quartz:2.2.0 has a dependency on c3p0:c3p0:0.9.1.1.
That old version of C3P0 got into conflict with the newer com.mchange:c3p0:0.9.5-pre6 that I have in my Jetty server instance's lib/etc/ directory.
The solution to my problem is to explicitly exclude Quartz' dependency on that old C3P0 artifact:
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.0</version>
<exclusions>
<exclusion>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
</exclusion>
</exclusions>
</dependency>
At least for my specific Quartz usage, Quartz still works well.
Related
I am using log4j2 with this 2 dependencies:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.6.2</version>
</dependency>
When I try to log for example an error with a throwable like:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.annotations.Test;
public class Test {
private static final Logger logger = LogManager.getLogger(Test.class);
#Test
public void testSendMessage() throws Exception {
Exception exception = new Exception("some exception");
logger.error("error with exception", exception);
}
}
using patternlayout:
<Configuration>
<properties>
<property name="filters">org.testng,org.apache.maven,sun.reflect,java.lang.reflect</property>
</properties>
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT" direct="true">
<PatternLayout pattern="%maxLen{%d{DEFAULT} [%p] %c{-3}:%L - %enc{%m} %xEx{filters(${filters})}%n}{200}"/>
</Console>
</Appenders>
<Loggers>
<logger name="my.test.class.path" level="trace" additivity="false">
<AppenderRef ref="ConsoleAppender" />
</logger>
</Loggers>
</Configuration>
Then the filtered packages won't disappear from the stacktrace, I can't even manipulate the stacktrace in any way like maximizing the lines:
%xEx{5}
Highlightning also don't work in eclipse nor in Kibana(ELK environment).
Can anybody help?
Could it be that the %xEx PatternLayout converter doesn't support property substitution in its options?
What if you put the packages you want to filter directly in the filters list?
It may be worth raising a Jira ticket on the Log4j 2 issue tracker for this.
try to remove the ending{200}. i think there is an issue using more sub parameters.
here is a snippet which works. please note if you add additional things like separator(|) it will stop working [tested in version 2.8.1 and 2.9.1]
<Properties>
<Property name="exfilters">org.jboss,java.lang.reflect,sun.reflect</Property>
<Property name="log-pattern">%d %-5p %m%n%xEx{filters(${exfilters})}/Property>
</Properties>
...
<PatternLayout pattern="${sys:log-pattern}"/>
Works for me on Log4j2 v 2.17 (and also for rThrowable):
<Properties>
<Property name="PACKAGE_FILTER">org.jboss,java.lang.reflect,sun.reflect</Property>
<Property name="LOG_PATTERN">%xThrowable{filters(${PACKAGE_FILTER})}</Property>
</Properties>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="${LOG_PATTERN}"/>
</Console>
</Appenders>
I'm trying to use MySQL with JBoss 7.0. I've changed the standalone.xml and added the driver and the dataresources inside of it, i've also added the module.xml file in the modules/com/mysql/main folder.
This is a part of standalone.xml:
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="H2DS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
</connection-url>
<driver>
h2
</driver>
<pool>
<prefill>
false
</prefill>
<use-strict-min>
false
</use-strict-min>
<flush-strategy>
FailingConnectionOnly
</flush-strategy>
</pool>
<security>
<user-name>
sa
</user-name>
<password>
sa
</password>
</security>
</datasource>
<datasource jndi-name="java:/mydb" pool-name="my_pool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:mysql://localhost:3306/mydb
</connection-url>
<driver>
mysql
</driver>
<security>
<user-name>
root
</user-name>
<password>
</password>
</security>
<statement>
<prepared-statement-cache-size>
100
</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>
org.h2.jdbcx.JdbcDataSource
</xa-datasource-class>
</driver>
<driver name="mysql" module="com.mysql">
<driver-class>
com.mysql.jdbc.Driver
</driver-class>
<xa-datasource-class>
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
and the module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.39-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
And when i deploy (using eclipse) i get this error:
14:36:28,108 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
14:36:28,109 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
14:36:28,110 WARN [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) Unable to instantiate driver class "com.mysql.fabric.jdbc.FabricMySQLDriver": org.jboss.msc.service.DuplicateServiceException: Service jboss.jdbc-driver.web-adwords-project_war is already registered
14:36:28,132 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
14:36:28,133 WARN [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) Unable to instantiate driver class "oracle.jdbc.OracleDriver": org.jboss.msc.service.DuplicateServiceException: Service jboss.jdbc-driver.web-adwords-project_war is already registered
can anyone help me ?
I am getting the following error while try to publish artifact into the remote repository.
BUILD FAILED
/home/kannan/.jenkins/workspace/projectA/build.xml:87: impossible to publish artifacts for com.mycompany#projectA;1.0: java.io.IOException: PUT operation to URL http://myserver.com/repository/com.mycompany/projectA/1.0/ivy-1.0.xml failed with status code 405: Method Not Allowed
at org.apache.ivy.util.url.AbstractURLHandler.validatePutStatusCode(AbstractURLHandler.java:82)
at org.apache.ivy.util.url.BasicURLHandler.upload(BasicURLHandler.java:264)
at org.apache.ivy.util.url.URLHandlerDispatcher.upload(URLHandlerDispatcher.java:82)
at org.apache.ivy.util.FileUtil.copy(FileUtil.java:150)
at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:84)
at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
at org.apache.ivy.plugins.resolver.RepositoryResolver.put(RepositoryResolver.java:234)
at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:216)
at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:275)
at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:254)
at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:166)
at org.apache.ivy.Ivy.publish(Ivy.java:615)
at org.apache.ivy.ant.IvyPublish.doExecute(IvyPublish.java:312)
at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:277)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:809)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
impossible to publish artifacts;
PUT operation to URL http://myserver.com/repository/com.mycompany/projectA/1.0/ivy-1.0.xml failed with status code 405: Method Not Allowed
ivy.xml
<ivy-module version="2.0">
<info organisation="com.mycompany" module="projectA" revision="${version}">
<description>
This project provides interface to projectA.
</description>
</info>
<publications>
<artifact />
</publications>
<dependencies defaultconfmapping="*->*,!sources,!javadoc">
<dependency org="com.hazelcast" name="hazelcast-client" rev="2.5" transitive="false"/>
<dependency org="com.hazelcast" name="hazelcast" rev="3.1.5" transitive="false"/>
<dependency org="log4j" name="log4j" rev="1.2.16" transitive="false"/>
</dependencies>
</ivy-module>
ivysettings.xml
<ivysettings>
<settings defaultResolver="defaultresolver" />
<property name="ibiblio-maven2-root" value="http://repo1.maven.org/maven2/" />
<property name="build-server" value="http://myserver.com/repository" />
<resolvers>
<chain name="defaultresolver">
<ibiblio name="local" m2compatible="true" root="${build-server}" />
<url name="repository">
<ivy pattern="${build-server}/[organisation]/[module]/[revision]/ivy-[revision].xml" />
<artifact pattern="${build-server}/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
</chain>
</resolvers>
</ivysettings>
build.xml
<ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
resolver="repository" organisation="com.mycompany"
module="projectA" pubrevision="${version}" status="release" conf="java" />
I had the same error message trying to publish to Artifactory. It turned out I forgot to include the port 8081 in the URL.
what is your HTTP Server? Did you use Something like Artifactory?
If you are using Apache, the PUT operation is disabled by default (maybe the same for most Web servers). You'll have to enable it and associate a backend script to handle the query as expected (retrieving artifacts from query and saving them on file system).
I enable it using PHP, you can see how from my GitHub repository: https://github.com/opatry/ivy-frontend
if you are using Artifactory as your repository, check this out:
http://www.jfrog.com/confluence/display/RTF2X/Working+with+Ivy
The ivy settings should change the build-server property
<ivysettings>
<settings defaultResolver="defaultresolver" />
<property name="ibiblio-maven2-root" value="http://repo1.maven.org/maven2/" />
<property name="build-server" value="http://myserver.com/repository/libs-snapshot-local/" />
<resolvers>
<chain name="defaultresolver">
<ibiblio name="local" m2compatible="true" root="${build-server}" />
<url name="repository">
<ivy pattern="${build-server}/[organisation]/[module]/[revision]/ivy-[revision].xml" />
<artifact pattern="${build-server}/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
</chain>
</resolvers>
</ivysettings>
I have been gathering many helpful answers from this site in the last few weeks. I joined so that I could +1 to some of the answers I found most help, but couldn't do that just yet. But Thanks!
My problem is a JBoss 7 AS deployment error that I can't seem to track down any information about. It started out a a tutorial about Spring, Hibernation, and MySql using C3P0.
This is the log from the server showing the error that I'm trying to correct.
11:50:30,062 WARN [org.jboss.as.ee] (MSC service thread 1-3) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Could not find default constructor for class org.springframework.web.context.request.async.StandardServletAsyncWebRequest
at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.java:607) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:80) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
11:50:30,828 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
11:50:32,000 INFO [org.jboss.web] (ServerService Thread Pool -- 63) JBAS018210: Register web context: /S4Me-0.0.1-SNAPSHOT
11:50:32,421 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/S4Me-0.0.1-SNAPSHOT]] (ServerService Thread Pool -- 63) No Spring WebApplicationInitializer types detected on classpath
11:50:32,500 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/S4Me-0.0.1-SNAPSHOT]] (ServerService Thread Pool -- 63) Initializing Spring root WebApplicationContext
11:50:39,125 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/S4Me-0.0.1-SNAPSHOT]] (ServerService Thread Pool -- 63) JBWEB000287: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'addressService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/hibernate-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.mchange.v2.c3p0.jboss.C3P0PooledDataSource' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.mchange.v2.c3p0.jboss.C3P0PooledDataSource] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_25]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_25]
at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_25]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'addressService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/hibernate-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.mchange.v2.c3p0.jboss.C3P0PooledDataSource' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.mchange.v2.c3p0.jboss.C3P0PooledDataSource] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:442) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:416) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:550) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
... 25 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/hibernate-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.mchange.v2.c3p0.jboss.C3P0PooledDataSource' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.mchange.v2.c3p0.jboss.C3P0PooledDataSource] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:442) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:416) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:550) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
... 38 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.mchange.v2.c3p0.jboss.C3P0PooledDataSource' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.mchange.v2.c3p0.jboss.C3P0PooledDataSource] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:463) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:494) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:488) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1433) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1392) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
... 49 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [com.mchange.v2.c3p0.jboss.C3P0PooledDataSource] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:264) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:448) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
... 55 more
11:50:39,765 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 63) Initializing Mojarra 2.1.19-jbossorg-1 20130304-0420 for context '/S4Me-0.0.1-SNAPSHOT'
11:50:55,984 INFO [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 63) HV000001: Hibernate Validator 4.3.1.Final-redhat-1
11:50:57,828 ERROR [org.apache.catalina.core] (ServerService Thread Pool -- 63) JBWEB001103: Error detected during context /S4Me-0.0.1-SNAPSHOT start, will stop it
11:50:57,828 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/S4Me-0.0.1-SNAPSHOT]] (ServerService Thread Pool -- 63) Closing Spring root WebApplicationContext
11:50:57,875 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 63) MSC000001: Failed to start service jboss.web.deployment.default-host."/S4Me-0.0.1-SNAPSHOT": org.jboss.msc.service.StartException in service jboss.web.deployment.default-host."/S4Me-0.0.1-SNAPSHOT": org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_25]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_25]
at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_25]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:161)
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60)
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93)
... 7 more
11:50:58,203 ERROR [org.jboss.as.server] (HttpManagementService-threads - 3) JBAS015870: Deploy of deployment "S4Me-0.0.1-SNAPSHOT.war" was rolled back with the following failure message:
{"JBAS014671: Failed services" => {"jboss.web.deployment.default-host.\"/S4Me-0.0.1-SNAPSHOT\"" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host.\"/S4Me-0.0.1-SNAPSHOT\": org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context
Caused by: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context"}}
11:50:59,171 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment S4Me-0.0.1-SNAPSHOT.war (runtime-name: S4Me-0.0.1-SNAPSHOT.war) in 940ms
A copy of my hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="">
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.connection.autocommit">true</property>
</session-factory>
</hibernate-configuration>
My applicationContent.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"
>
<!-- Activates various annotations to be detected in bean classes -->
<context:annotation-config />
<!-- Scans the classpath for annotated components that will be auto-registered
as Spring beans. For example #Controller and #Service. Make sure to set the
correct base-package -->
<context:component-scan
base-package="org.S2Me.MyHealth.client,org.S2Me.MyHealth.controller,org.S2Me.MyHealth.model,org.S2Me.MyHealth.server,org.S2Me.MyHealth.service" />
<!-- Configures the annotation-driven Spring MVC Controller programming
model. Note that, with Spring 3.0, this tag works in Servlet MVC only! -->
<mvc:annotation-driven />
<!-- Load Hibernate related configuration -->
<import resource="hibernate-context.xml" />
</beans>
hibernate-content.xml the one causing the problem
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
"
>
<!-- <context:property-placeholder location="/WEB-INF/spring.properties"
/> -->
<!-- Enable annotation style of managing transactions -->
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- Declare the Hibernate SessionFactory for retrieving Hibernate sessions -->
<!-- See http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.html -->
<!-- See http://docs.jboss.org/hibernate/stable/core/api/index.html?org/hibernate/SessionFactory.html -->
<!-- See http://docs.jboss.org/hibernate/stable/core/api/index.html?org/hibernate/Session.html -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
<property name="dataSource" ref="dataSource" />
<!-- <property name="configLocation" value="classpath:hibernate.cfg.xml" /> -->
<property name="packagesToScan" value="org.S2Me.MyHealth**.*" />
</bean>
<!-- Declare a datasource that has pooling capabilities -->
<bean id="dataSource" class="com.mchange.v2.c3p0.jboss.C3P0PooledDataSource"
destroy-method="close"
>
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/s2me" />
<property name="user" value="root" />
<property name="password" value="LexoR" />
<property name="acquireIncrement" value="5" />
<property name="idleConnectionTestPeriod" value="60" />
<property name="maxPoolSize" value="100" />
<property name="maxStatements" value="50" />
<property name="minPoolSize" value="10" />
</bean>
<!-- Declare a transaction manager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager"
>
<property name="sessionFactory" value="sessionFactory" />
</bean>
</beans>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_ID" version="3.1">
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
</web-app>
I'm using Eclipse 4.3.0, Maven 3.1, Spring 3.2.4.RELEASE, Hibernate 4.1.0.Final, JBoss EAP 6.1 in standalone configuration.
Sorry for the length of this question, but I wanted to supply the information to get the help.
Any ideas? What am I doing wrong? Thanks.
The class C3P0PooledDataSource does not implement javax.sql.DataSource. It is used for something completely different, JMX notifications.
Use ComboPooledDataSource instead.
I'm using Hibernate 4.1.5.SP1, Hibernate Validator 4.3.0.Final and JUnit 4.8.1. When I run my JUnit tests, I'm getting the exception "java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/myproject" when trying to setup my transaction.
#Before
public void setUpDAOTest() {
final Configuration configuration = new Configuration();
configuration.configure("junit_hibernate.cfg.xml")
.setProperty("javax.persistence.validation.mode", "none")
.setProperty("hibernate.show_sql", "false");
final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
session = sessionFactory.openSession();
ThreadLocalSessionContext.bind(session);
tx = session.beginTransaction(); // exception thrown here
The exception suggests my URL is malformed, but it seems right to me. Also, I have verified the database is running and I can connect to it on a command line. My Hibernate config file is
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/myproject</property>
<property name="hibernate.connection.username">myproject</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="javax.persistence.validation.mode">none</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<mapping class="com.follett.fdr.myproject.model.UserRole" />
<mapping class="com.follett.fdr.myproject.model.Organization" />
<mapping class="com.follett.fdr.myproject.model.Product" />
<mapping class="com.follett.fdr.myproject.model.State" />
<mapping class="com.follett.fdr.myproject.model.Country" />
<mapping class="com.follett.fdr.myproject.model.AccessCode" />
<mapping class="com.follett.fdr.myproject.model.Contract" />
<mapping class="com.follett.fdr.myproject.model.TrainingLink" />
</session-factory>
</hibernate-configuration>
So I'm stumped. What else could I be doing wrong? Here is the full stack trace …
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/myproject
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:281)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1396)
at org.mainco.subco.orgsclient.dao.AbstractDaoTest.setUpDAOTest(AbstractDaoTest.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
you should have the mysql driver jar in your classpath, so download it and include it in your classpath
if you are using maven to build take the definition from here