-
1. Re: Upgrading from Deployment Service to Profile Service
emuckenhuber Dec 2, 2010 9:56 AM (in response to sergiu_pienar)There is a way to create new datasources using the ProfileService management API using deployment templates: http://community.jboss.org/wiki/ProfileServiceDeploymentTemplates. However you can also use the ProfileService DeploymentManager to deploy a *-ds.xml deployment directly.
-
2. Re: Upgrading from Deployment Service to Profile Service
sergiu_pienar Dec 6, 2010 4:58 AM (in response to emuckenhuber)Do you know in which .jar are located these ones :
org.jboss.deployers.spi.management.deploy.DeploymentManager;
org.jboss.deployers.spi.management.deploy.DeploymentProgress;
org.jboss.deployers.spi.management.deploy.DeploymentStatus;Thx.
Later edit : It's in client/jboss-integration.jar.
-
3. Re: Upgrading from Deployment Service to Profile Service
emuckenhuber Dec 6, 2010 5:19 AM (in response to sergiu_pienar)1 of 1 people found this helpfulSergiu Pienar wrote:
Later edit : It's in client/jboss-integration.jar.
Correct. In case you want to use remoting you will most likely need the jbossall-client.jar as well.
-
4. Re: Upgrading from Deployment Service to Profile Service
sergiu_pienar Dec 7, 2010 5:30 AM (in response to emuckenhuber)For adding some properties in the *-ds.xml should I create a managed object ?
Basically the properties that I set here :
private HashMap<String, Object> generateMap(final Datasource ds) {
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put("jndi-name", this.getDSName(ds));
properties.put("connection-url", ds.getUrl());
properties.put("user-name", ds.getUsername());
properties.put("password", ds.getPassword());
if (Datasource.SERVER_TYPE.ORACLE.toString().equalsIgnoreCase(ds.getServerType())) {
properties.put("driver-class", "oracle.jdbc.driver.OracleDriver");
properties.put("exception-sorter-class-name",
"org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter");
properties.put("min-pool-size", 5);
properties.put("max-pool-size", 100);} else if (Datasource.SERVER_TYPE.MYSQL.toString().equalsIgnoreCase(ds.getServerType())) {
properties.put("driver-class", "com.mysql.jdbc.Driver");
properties.put("exception-sorter-class-name",
"org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter");
properties.put("min-pool-size", 20);
properties.put("max-pool-size", 250);
properties.put("blocking-timeout-millis", 30000);}
return properties;
}}
will have to go into the *-ds.xml that is the DataSource.
I get the following error when I try to create a datasource :
ERROR [AbstractKernelController] Error installing to Parse: name=vfsfile:/D:/opts/jboss-5.1.0.GA/server/autoid/deploy/mysql-test2-ds.xml state=Not Installed mode=Manual requiredState=Parse
loyers.spi.DeploymentException: Error creating managed object for vfsfile:/D:/opt_head_sergiu/jboss-5.1.0.GA/server/autoid/deploy/mysql-test2-ds.xml
org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)What am I doing wrong?
Thank you.
Later edit :
I'm trying to do the following :
DeploymentTemplateInfo info = mgtView.getTemplate("LocalTxDataSourceTemplate");
// Update the template values
info.getProperties().get("min-pool-size").setValue(SimpleValueSupport.wrap(13));// Create the deployment
mgtView.applyTemplate(jndiName, info);// Get the created managed component
ComponentType type = KnownComponentTypes.DataSourceTypes.LocalTx.getType();
ManagedComponent dataSource = mgtView.getComponent(jndiName, type);
dataSource.update();Is it correct ?
-
5. Re: Upgrading from Deployment Service to Profile Service
emuckenhuber Dec 7, 2010 5:36 AM (in response to sergiu_pienar)1 of 1 people found this helpfulYes, the latter seems to be the right direction. There is also a test in our testsuite creating a local datasource. Maybe the "testTemplateDS" helps:
-
6. Re: Upgrading from Deployment Service to Profile Service
sergiu_pienar Dec 8, 2010 9:26 AM (in response to emuckenhuber)I've managed to create the dataSource and Register it , and it works.Thank you Emanuel for the help.
One last question : When I unbind the dataSource I also have to delete it physically(i.e. from the server/deploy/ folder).How can this be done.
Thx.
-
7. Re: Upgrading from Deployment Service to Profile Service
emuckenhuber Dec 8, 2010 10:03 AM (in response to sergiu_pienar)As you mentioned, the DeploymentTemplate creates a physical deployment - so you would need to use the DeploymentManager to stop/remove it. One way to get the deployment name is using the ManagedComponent (like in the fragment you posted) - dataSource.getDeployment().getName() and pass the name into the DeploymentManager.stop() and remove().
-
8. Re: Upgrading from Deployment Service to Profile Service
sergiu_pienar Dec 8, 2010 10:26 AM (in response to emuckenhuber)Thank you very much for your assistence through out the entire post.
Sergiu.
-
9. Re: Upgrading from Deployment Service to Profile Service
sergiu_pienar Dec 10, 2010 8:41 AM (in response to emuckenhuber)When I try to create a XA DataSource I notice that there are some differences between the Template that I get using the ManagementView and the template that really works.
So , in the template that I get with the mgtView I would like to add this field:
<xa-datasource-property name="URL">jdbc:mysql://localhost:3306/example</xa-datasource-property>
The <xa-datasource-property> exists in the template , however I want to add the name="URL" part in it.
How can I add it to the template ?
If I don't add it the dataSource will not work properly(it won't be able to acquire a connection to the DB).
Thx a lot.
-
10. Re: Upgrading from Deployment Service to Profile Service
emuckenhuber Dec 13, 2010 5:13 AM (in response to sergiu_pienar)The DeploymentTemplateInfo for XA DataSources should contain a "xa-datasource-properties" ManagedProperty - the value of the this property is: MapCompositeValueSupport. So you should be able to add properties using something like: dataSourceProperties.put("URL", SimpleValueSupport.wrap("jdbc:mysql://localhost:3306/exampl");
-
11. Re: Upgrading from Deployment Service to Profile Service
sergiu_pienar Dec 13, 2010 7:54 AM (in response to emuckenhuber)I noticed that there was a property xa-datasource-properties in the XADeploymentTemplate , just that I don't know how to populate it with the URL section.
I've tried the following :
private HashMap<String, MetaValue> generateMap(final Datasource ds) {
HashMap<String, MetaValue> properties = new HashMap<String, MetaValue>();
properties.put("jndi-name", SimpleValueSupport.wrap(this.getDSName(ds)));
properties.put("connection-url", SimpleValueSupport.wrap(ds.getUrl()));
properties.put("user-name", SimpleValueSupport.wrap(ds.getUsername()));
properties.put("password", SimpleValueSupport.wrap(ds.getPassword()));
properties.put("URL", SimpleValueSupport.wrap(ds.getUrl()));return properties;
}
public void createAndRegister(final Datasource ds){
DeploymentTemplateInfo info = mgtView.getTemplate("XADataSourceTemplate");
// Insert template values
for (ManagedProperty property : info.getProperties().values()) {MetaValue v = properties.get(property.getName());
if (v != null) {
property.setValue(v);
property.setField(Fields.META_TYPE, v.getMetaType());
}
}// Create the deployment
mgtView.applyTemplate(deploymentName, info);}
But it does not insert the URL part .
Thx.
Later edit : Currently trying http://community.jboss.org/message/294681#294681
-
12. Re: Upgrading from Deployment Service to Profile Service
emuckenhuber Dec 13, 2010 9:43 AM (in response to sergiu_pienar)Sergiu Pienar wrote:
Later edit : Currently trying http://community.jboss.org/message/294681#294681
Yes, you would need to use MapCompositeValueSupport in order to make this work:
MapCompositeValueSupport properties = new MapCompositeValueSupport(SimpleMetaType.STRING);
properties.put("jndi-name", SimpleValueSupport.wrap(this.getDSName(ds)));
properties.put("connection-url", SimpleValueSupport.wrap(ds.getUrl()));
properties.put("user-name", SimpleValueSupport.wrap(ds.getUsername()));
properties.put("password", SimpleValueSupport.wrap(ds.getPassword()));
properties.put("URL", SimpleValueSupport.wrap(ds.getUrl()));And then set this as the value of the "xa-datasource-properties" ManagedProperty.
-
13. Re: Upgrading from Deployment Service to Profile Service
sergiu_pienar Dec 14, 2010 3:01 AM (in response to emuckenhuber)It finally worked.
Thank you very much Emanuel.
Cheers,
Sergiu.
-
14. Re: Upgrading from Deployment Service to Profile Service
sergiu_pienar Dec 15, 2010 4:40 AM (in response to sergiu_pienar)I noticed something strange...I have the list of DS's in my application.As long as I don't restart the server I can delete them and it works.
But after I restart the server i can't delete them.This is the method I use for deleting the DataSources
public boolean unRegister(final Datasource ds)
throws Exception {
try {DeploymentManager deployMgr = this.getDeploymentManager();
// Get the ViewManager
ManagementView mgtView = this.getManagementView();
ComponentType type = KnownComponentTypes.DataSourceTypes.XA.getType();
// Get the component to be removed
ManagedComponent dataSourceComponent = mgtView.getComponent(this.getDSName(ds), type);
String dataSourceComponentName = dataSourceComponent.getDeployment().getName();
// Remove the component
mgtView.removeComponent(dataSourceComponent);
// Stop the deployment
DeploymentProgress stop = deployMgr.stop(dataSourceComponentName);
// Run
stop.run();
// Remove the deployment
DeploymentProgress remove = deployMgr.remove(dataSourceComponentName);
// Run
remove.run();return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}}
And the point where it fails is here :ManagedComponent dataSourceComponent = mgtView.getComponent(this.getDSName(ds), type);
The strange fact is that this very same dataSourceComponent gets populated when the server is not restarted.
Do you have any idea why ?
Thx.