[jboss-as7-dev] problem creating datasources

Brian Stansberry brian.stansberry at redhat.com
Fri Apr 8 09:38:32 EDT 2011


On 4/8/11 4:58 AM, Stefano Maestri wrote:
> Answer below
> On 04/08/2011 09:32 AM, Heiko Braun wrote:
>> comments below
>>
>> On Apr 7, 2011, at 8:23 PM, Brian Stansberry wrote:
>>
>>>> [localhost:9999 /]
>>>> */profile=default/subsystem=datasources/jdbc-driver=hypersonic:add(driver="com.h2database.h2")*
>>>> {
>>>> "outcome" =>   "*failed*",
>>>> "result" =>   {"server-groups" =>   {"main-server-group" =>   {
>>>> "server-one" =>   {
>>>> "host" =>   "local",
>>>> "response" =>   {
>>>> "outcome" =>   "failed",
>>>> "failure-description" =>
>>>> "org.jboss.msc.service.DuplicateServiceException: Service
>>>> jboss.jdbc-driver.\"org.h2.Driver\".1.2 is already registered"
>>>> }
>>>> },
>>>> "server-two" =>   {
>>>> "host" =>   "local",
>>>> "response" =>   {
>>>> "outcome" =>   "failed",
>>>> "failure-description" =>
>>>> "org.jboss.msc.service.DuplicateServiceException: Service
>>>> jboss.jdbc-driver.\"org.h2.Driver\".1.2 is already registered"
>>>> }
>>>> }
>>>> }}},
>>>> "failure-description" =>   "Operation was not applied successfully to any
>>>> servers"
>>>> }
>>>>
>>> This I understand. There's already this installed:
>>>
>>> <driver module="com.h2database.h2"/>
>>>
>>> and that results in the driver service already being present. I'll let
>>> Jesper, Stefano or John Bailey comment on whether there's any reason to
>>> have the 'driver="com.h2database.h2"' parameter to that operation,
>>> rather than just requiring the name of the resource to be the name of
>>> the module:
>>>
>>> /profile=default/subsystem=datasources/jdbc-driver=com.h2database.h2:add
>>>
>>> You still wouldn't be able to add the module twice, but at least the
>>> reason why not would be clear.
>> Isn't it that "jdbc-driver=hypersonic:add(driver="com.h2database.h2")" means i am adding a new
>> jdbc driver "hypersonic" that references "com.h2database.h2" ?
>>
>> shouldn't this result in:
>> [localhost:9999 /] /profile=default/subsystem=datasources/jdbc-driver=hypersonic:read-resource
>> {
>>       "outcome" =>   "success",
>>       "result" =>   {
>>           "name" =>   "hypersonic",
>>           "driver" =>   "com.h2database.h2"
>>       },
>>       "compensating-operation" =>   undefined
>> }
>>
>> but maybe I am confused by the API
>>
> Well, what you are doing here is to add a new driver you call
> "hypersonic" that refer in fact on the same java.sql.Driver
> implementation (com.h2database.h2). The point is that the name is not
> important in the current implementation because we are creating a
> service for each Driver implementation and version and not for each
> name. What's happen here is that we are trying to create the same
> driver/version service 2 times, getting an MSC error of course.
> The question is: does it make sense to have 2 different name for the
> same driver? Or we just need to have a better message to the user saying
> he can't do that because the same driver is already installed with a
> different name?

If we are going to catch this and provide a better message to the user, 
it needs to happen outside the operation handler's RuntimeTask. The 
RuntimeTask only executes on a server, so any validation will not happen 
on the DomainController. Effect is the DC will allow an update and then 
pass it on the servers where it will fail. As much as possible we need 
to validate operations before applying them to the DC's model.

That's where the suggestion of using the value of the current DRIVER 
param as the resource name and then getting rid of the DRIVER param came 
from. If a user tries to do an "add" operation with a child name that 
already exists, the DC (or the ServerController in standalone mode) will 
catch this and report an error.

> I'm for the second option, but I'm open to the first one if there is a
> use case to do that.
>
> bye
> S.
> _______________________________________________
> jboss-as7-dev mailing list
> jboss-as7-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev


-- 
Brian Stansberry
Principal Software Engineer
JBoss by Red Hat



More information about the jboss-as7-dev mailing list