Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
8.0.15, 9.1.0
-
None
-
windows 11
tomEE 8.0.15 webprofile
jdk 8
hibernate 5.6.15
Description
When you define a data-source using_ @DataSourceDefinition_ or using <data-source> tag in standard descriptor, if the url property is not defined, the creation of the data-source fails.
Example of non-working DataSourceDefinition: (same result with DataSourceDefinition annotation or data-source tag)
@DataSourceDefinition ( name = "java:app/env/jdbc/MyDataSource", className = "org.postgresql.ds.PGPoolingDataSource", user = "myuser", password = "mypassword", serverName = "localhost", portNumber = 5432, databaseName = "mydb" )
<data-source> <name>java:app/env/jdbc/MyDataSource</name> <class-name>org.postgresql.ds.PGPoolingDataSource</class-name> <server-name>localhost</server-name> <port-number>5432</port-number> <database-name>mydb</database-name> <user>myuser</user> <password>mypassword</password> </data-source>
Example of working DataSourceDefinition
@DataSourceDefinition ( name = "java:app/env/jdbc/MyDataSource", className = "org.postgresql.ds.PGPoolingDataSource", user = "myuser", password = "mypassword", url = "jdbc:postgresql://localhost:5432/mydb" )
<data-source> <name>java:app/env/jdbc/MyDataSource</name> <class-name>org.postgresql.ds.PGPoolingDataSource</class-name> <url>jdbc:postgresql://localhost:5432/mydb</url> <user>myuser</user> <password>mypassword</password> </data-source>
TomEE error logs:
GRAVE: Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Thermometres] org.apache.xbean.recipe.ConstructionException: Error invoking factory method: public static javax.sql.CommonDataSource org.apache.openejb.resource.jdbc.DataSourceFactory.create(java.lang.String,boolean,java.lang.Class,java.lang.String,org.apache.openejb.util.Duration,org.apache.openejb.util.Duration,org.apache.openejb.util.Duration,boolean) throws java.lang.IllegalAccessException,java.lang.InstantiationException,java.io.IOException at org.apache.xbean.recipe.ReflectionUtil$StaticFactory.create(ReflectionUtil.java:1019) at org.apache.xbean.recipe.ObjectRecipe.internalCreate(ObjectRecipe.java:279) at org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:96) at org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:61) at org.apache.openejb.assembler.classic.Assembler.doCreateResource(Assembler.java:3178) at org.apache.openejb.assembler.classic.Assembler.createResource(Assembler.java:3013) at org.apache.openejb.config.ConfigurationFactory.doInstall(ConfigurationFactory.java:466) at org.apache.openejb.config.ConfigurationFactory.install(ConfigurationFactory.java:459) at org.apache.openejb.config.AutoConfig.installResource(AutoConfig.java:2215) at org.apache.openejb.config.AutoConfig.processApplicationResources(AutoConfig.java:1048) at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:192) at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420) at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1033) at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1318) at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1162) at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4852) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:871) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:795) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:871) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:249) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:428) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:917) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:772) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:347) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478) Caused by: org.apache.xbean.recipe.ConstructionException: Error setting property: public void org.postgresql.ds.common.BaseDataSource.setUrl(java.lang.String) at org.apache.xbean.recipe.ObjectRecipe.setProperty(ObjectRecipe.java:528) at org.apache.xbean.recipe.ObjectRecipe.setProperties(ObjectRecipe.java:378) at org.apache.xbean.recipe.ObjectRecipe.internalCreate(ObjectRecipe.java:289) at org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:96) at org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:61) at org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:49) at org.apache.openejb.resource.jdbc.DataSourceFactory.create(DataSourceFactory.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.xbean.recipe.ReflectionUtil$StaticFactory.create(ReflectionUtil.java:1009) ... 45 more Caused by: java.lang.IllegalArgumentException: URL invalid jdbc:hsqldb:file:C:\local\apache-tomee-webprofile-8.0.15\data\hsqldb\hsqldb at org.postgresql.ds.common.BaseDataSource.setUrl(BaseDataSource.java:1133) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.xbean.recipe.ObjectRecipe$MethodMember.setValue(ObjectRecipe.java:648) at org.apache.xbean.recipe.ObjectRecipe.setProperty(ObjectRecipe.java:519) ... 56 more
You can see that it try to create the Postgresql DataSource using TomEE default hsqldb datasource url instead of the of the correct one.
Attachments
Issue Links
- links to