我希望有人能在我花费数小时试图解决之前回答这个问题!
我正在使用PoolingDataSource类来实例化我的事务管理器。但是,我没有取得多大成功。
MySQL是我的默认数据库。我正在使用:
PoolingDataSource ds = new PoolingDataSource();
ds.setUniqueName("java:jboss/datasources/jbpmDS");
ds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
ds.setMaxPoolSize(3);
ds.setAllowLocalTransactions(true);
ds.getDriverProperties().put("user", "root");
ds.getDriverProperties().put("password", "rootpass");
ds.getDriverProperties().put("URL", "jdbc:mysql://localhost:3306/jbpm6");
ds.getDriverProperties().put("driverClassName", "com.mysql.Driver");
ds.init();
PoolingDataSource ds = new PoolingDataSource();
ds.setUniqueName("java:jboss/datasources/jbpmDS");
ds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
ds.setMaxPoolSize(3);
ds.setAllowLocalTransactions(true);
ds.getDriverProperties().put("user", "root");
ds.getDriverProperties().put("password", "rootpass");
ds.getDriverProperties().put("URL", "jdbc:mysql://localhost:3306/jbpm6");
ds.getDriverProperties().put("driverClassName", "com.mysql.Driver");
ds.init();
我运行代码时得到这个:
bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC datasource named java:jboss/datasources/jbpmDS
at bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:92)
at com.sample.ProcessTest.testProcess(ProcessTest.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.@runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: bitronix.tm.utils.PropertyException: no writeable property 'URL' in class 'bitronix.tm.resource.jdbc.lrc.LrcXADataSource'
at bitronix.tm.utils.PropertyUtils.getSetter(PropertyUtils.java:318)
at bitronix.tm.utils.PropertyUtils.setDirectProperty(PropertyUtils.java:217)
at bitronix.tm.utils.PropertyUtils.setProperty(PropertyUtils.java:83)
at bitronix.tm.resource.common.XAPool.createXAFactory(XAPool.java:304)
at bitronix.tm.resource.common.XAPool.<init>(XAPool.java:63)
at bitronix.tm.resource.jdbc.PoolingDataSource.buildXAPool(PoolingDataSource.java:101)
at bitronix.tm.r esource.jdbc.PoolingDataSource.init(PoolingDataSource.java:88)
... 26 more
答案 0 :(得分:0)
引起:bitronix.tm.utils.PropertyException:没有可写属性 'URL'......
这是因为正确的属性名称是“url”(小写)