1 2 Previous Next 22 Replies Latest reply: Dec 10, 2007 10:11 PM by Scott Stark RSS

DeploymentInfo/Template MCF

Weston M. Price Master

In working on this, I just want to make sure there is something I am not missing.

Currently what I consider to be a simple mapping from the DeploymentTemplateInfo to the ManagedConnectionFactoryDeploymentGroup (the group of JCA deployments) involves simply reading the available managed properties and mapping them onto the relevant JCA MetaData

Example:


 public ManagedConnectionFactoryDeploymentGroup buildDeploymentGroup(ManagedConnectionFactoryDeploymentGroup group, DeploymentTemplateInfo info)
 {

 Map<String, ManagedProperty> props = info.getProperties();
 ManagedConnectionFactoryDeploymentMetaData md = new ManagedConnectionFactoryDeploymentMetaData();

 Set<String> names = props.keySet();

 for (String string : names)
 {
 ManagedProperty prop = props.get(string);

 if(prop.getName().equals("jndi-name"))
 {
 md.setJndiName((String)prop.getValue());
 }
 }

 group.addManagedConnectionFactoryDeployment(md);
 return group;



What I am wondering is if this is something I should be doing, or are we working towards an automapping of the TemplateInfo to the relevant MetaData based on the annotation model. I am fine with doing this as described above and then refactoring later, but it would seem that this should be a core component that handles this for the deployer/metadata developer.


  • 1. Re: DeploymentInfo/Template MCF
    Scott Stark Master

    The ManagedPropertys of the template should already be wired to the ManagedConnectionFactoryDeploymentMetaData instance. The question is how are the ManagedPropertys of the template being created. It should be from the required properties of the ManagedObject for the root ManagedConnectionFactoryDeploymentGroup with a single ManagedConnectionFactoryDeploymentMetaData in its deployments property.

    If a template should include more than just required properties, then we should add a tempate=true/false field to the ManagementProperty annotation to identify these. In psuedo code, creating a ds should entail something like:

    // Create the deployment template from a template ManagedConnectionFactoryDeploymentGroup
    ManagedConnectionFactoryDeploymentGroup group = new ManagedConnectionFactoryDeploymentGroup();
    // Issue of what ManagedConnectionFactoryDeploymentMetaData subclass to create...
    // TODO: type should be input from admin client
    ManagedConnectionFactoryDeploymentMetaData ds = ...;
    group.getDeployments().add(ds);
    
    // Get the template from the ManagedObject
    // TODO: name and type should be input from admin client
    ManagedObject groupMO = AbstractManagedObjectFactory.initManagedObject(group, "DefaultDS", "LocalTx");
    // TODO:
    DeploymentTemplateInfo templateInfo = AbstractTemplateInfoFactory.createInfo(groupMO);
    
    // ... admin client updates template properties
    // Profileservice calls to the template with the updated properties
     public VirtualFile applyTemplate(VirtualFile root, String deploymentBaseName,
     DeploymentTemplateInfo values)
     throws Exception
    {
     // Need to apply the detached property values to ManagedPropertys bound to a ManagedObject/metadata instance
     // Create the ManagedObject as above, but this time the ds type, and name should be in the properties.
     ManagedConnectionFactoryDeploymentGroup group = ...;
     ManagedObject dsDeploymentMO = AbstractManagedObjectFactory.initManagedObject(group, ...);
     // Set the dsDeploymentMO ManagedProperty values
     for(ManagedProperty prop : values.getProperties().values())
     {
     ManagedProperty moProp = dsDeploymentMO.getProperty(prop.getName());
     moProp.setValue(prop.getValue());
     }
    
     // Create the template file from the ManagedConnectionFactoryDeploymentGroup
     Class[] classes = {ManagedConnectionFactoryDeploymentGroup.class};
     JAXBContext context = JAXBContext.newInstance(classes);
     Marshaller marshaller = context.createMarshaller();
     marshaller.marshal(group, fw);
    ...
    }
    




  • 2. Re: DeploymentInfo/Template MCF
    Weston M. Price Master

    Ok, thanks it's a bit clearer but I am still hung up on the first two portions in what layer should creating the ManagedConnectionFactoryDeploymentGroup and it's associated ManagedConnectionFactoryDeploymentMetaData reside? From your example, I am assuming that the admin client is passing enough contextual information to make this happen, but I am not quite clear on *where* it should happen.

    In other words, by the time applyTemplates is invoked quite a bit has already been done. It's more of a workflow issue that I am not getting at this point. The primary example provided in the few existing test cases simply call applyTemplates which obviously is not going to work directly.

  • 3. Re: DeploymentInfo/Template MCF
    Scott Stark Master

    Its needs to be done in applyTemplates. The initial creation to create the template properties is just a way to leverage the existing annotations and AbstractManagedObjectFactory. In reality that ManagedObject and group are unused. The AbstractTemplateInfoFactory.createInfo(...) call could just as easily take the ManagedConnectionFactoryDeploymentGroup.class and scan for the ManagedPropertys that should be part of the template. It gets away from the issue of knowing what ds type and name are at that point.

    One thing we have gotten confused about is that the ManagedPropertys are used in two different ways, as detached by value objects used by admin clients (similar to detached ejb3 entities), and as server side objects that are really proxies for properties on the underlying metadata. Step 1 and the DeploymentTemplateInfo represents the client side case, applyTemplates represents the server side case.

  • 4. Re: DeploymentInfo/Template MCF
    Vicky Kak Master

     

    // TODO: name and type should be input from admin client

    What are the admin clients we are targetting here ?
    If we have a jmx MBean as a admin client apart from the Jboss ON , will that be helpful?
    I have been looking at the profileservice implementation at trunk but it seems there are no tests cases there , Where are the test cases ?



  • 5. Re: DeploymentInfo/Template MCF
    Scott Stark Master

    There is no specific admin client, we just have a managment api which we support, similar to how jmx was the api in the past. The api is the ProfileService/ManagedObject apis. We will map the ManagedObjects onto jmx, but this will how show a portion of the management capability. You won't be able to create datasource deployments this way.

    The testcase is the org.jboss.test.profileservice.test.ProfileServiceUnitTestCase.

  • 6. Re: DeploymentInfo/Template MCF
    Vicky Kak Master

    I am trying to run the org.jboss.test.profileservice.test.ProfileServiceUnitTestCase which seems to be failing right now .
    I wanted to enable the debug tracing in the above test where to set it . I wanted to see the following log details in this method

    protected ManagementView getManagementView()
     throws Exception
     {
     if( activeView == null )
     {
     InitialContext ctx = getInitialContext();
     ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
     activeView = ps.getViewManager();
     ProfileKey defaultKey = new ProfileKey("default");
     activeView.loadProfile(defaultKey);
     log.info("Loaded profile: "+defaultKey);
     // Init the VFS to setup the vfs* protocol handlers
     VFS.init();
     }
     return activeView;
     }
    


    From the test report I could make the log4j.xml location , putting the TRACE logging for org.jboss.test did not give the info output

    Testsuite: org.jboss.test.profileservice.test.ProfileServiceUnitTestCase
    Tests run: 4, Failures: 0, Errors: 1, Time elapsed: 3.164 sec
    ------------- Standard Error -----------------
    Found log4j.xml: file:/home/vicky/workspace/jboss5/testsuite/output/resources/log4j.xml
    ------------- ---------------- ---------------

    Testcase: testProfileKeys took 1.241 sec
    Testcase: testDeploymentNames took 0.752 sec
    Testcase: testTemplateNames took 0.496 sec
    Testcase: testAddDataSource took 0.623 sec
    Caused an ERROR
    obj parameter must not be null
    java.lang.IllegalArgumentException: obj parameter must not be null
    at javax.xml.bind.helpers.AbstractMarshallerImpl.checkNotNull(AbstractMarshallerImpl.java:417)


    Where to enable log tracing ?

  • 7. Re: DeploymentInfo/Template MCF
    Vicky Kak Master

    After spending some more time analyzing the failure of testAddDataSource I could make that the org.jboss.resource.deployers.management.DsDataSourceTemplate.wrtieTemplate(..) is not implemented fully , the code should be something like

    if( group instanceof ManagedConnectionFactoryDeploymentGroup )
     {
     AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
     ManagedObject dsDeploymentMO = mof.initManagedObject((Serializable)group,"DataSource", "LocalTx");
     for(ManagedProperty moprop : values.getProperties().values())
     {
     ManagedProperty moProp = dsDeploymentMO.getProperty(moprop.getName());
     moProp.setValue((Serializable)moprop.getValue());
     }
     }
    

    This above code needs to be refactored , may be this could provide some help to Alexey who would be looking at this now .

    PS: This code is yet not working


  • 8. Re: DeploymentInfo/Template MCF
    Scott Stark Master

    Right, the DeploymentTemplateInfo property values are detached from the server side ManagedObject/ManagedPropertys and need to be mapped onto these in order to be able to create a valid xml representation by marshalling the populated ManagedConnectionFactoryDeploymentGroup.

  • 9. Re: DeploymentInfo/Template MCF
    Vicky Kak Master

    What does this error mean ?

    Testcase: testAddDataSource took 4.34 sec
     Caused an ERROR
    null
    javax.xml.bind.MarshalException
     - with linked exception:
    [com.sun.istack.SAXException2: unable to marshal type "org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup" as an element because it is missing an @XmlRootElement annotation]
     at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:320)
     at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:246)
     at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:96)
     at org.jboss.resource.deployers.management.DsDataSourceTemplate.writeTemplate(DsDataSourceTemplate.java:120)
     at org.jboss.resource.deployers.management.DsDataSourceTemplate.applyTemplate(DsDataSourceTemplate.java:61)
     at org.jboss.profileservice.management.ManagementViewImpl.applyTemplate(ManagementViewImpl.java:550)
     at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121)
     at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
     at org.jboss.profileservice.remoting.ProfileServiceInvocationHandler.invoke(ProfileServiceInvocationHandler.java:56)
     at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:771)
     at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
     at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
     at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
    Caused by: com.sun.istack.SAXException2: unable to marshal type "org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup" as an element because it is missing an @XmlRootElement annotation
     at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:242)
     at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:303)
     at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:488)
     at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:317)
     at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:246)
     at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:96)
     at org.jboss.resource.deployers.management.DsDataSourceTemplate.writeTemplate(DsDataSourceTemplate.java:120)
     at org.jboss.resource.deployers.management.DsDataSourceTemplate.applyTemplate(DsDataSourceTemplate.java:61)
     at org.jboss.profileservice.management.ManagementViewImpl.applyTemplate(ManagementViewImpl.java:550)
     at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121)
     at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
     at org.jboss.profileservice.remoting.ProfileServiceInvocationHandler.invoke(ProfileServiceInvocationHandler.java:56)
     at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:771)
     at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
     at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
     at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
     at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
     at org.jboss.remoting.Client.invoke(Client.java:1634)
     at org.jboss.remoting.Client.invoke(Client.java:548)
     at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at org.jboss.aspects.remoting.MergeMetaDataInterceptor.invoke(MergeMetaDataInterceptor.java:74)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at AOPProxy$1.applyTemplate(AOPProxy$1.java)
     at org.jboss.test.profileservice.test.ProfileServiceUnitTestCase.testAddDataSource(ProfileServiceUnitTestCase.java:404)
     at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:74)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at org.jboss.aspects.remoting.MergeMetaDataInterceptor.invoke(MergeMetaDataInterceptor.java:74)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at AOPProxy$1.applyTemplate(AOPProxy$1.java)
     at org.jboss.test.profileservice.test.ProfileServiceUnitTestCase.testAddDataSource(ProfileServiceUnitTestCase.java:404)


    I made the following changes
    1) In the start() of the org.jboss.resource.deployers.management.DsDataSourceTemplateInfo
    I added attachment by calling this code
     ManagedObjectImpl mo = new ManagedObjectImpl(attachmentName);
    
     //JBAS-4671
     log.debug("Going to start in DsDataSourceTemplate");
     Object attachment = loadClass(attachmentName);
     log.debug("Added attachment in loadClass"+attachment);
     Serializable serAttachment = (java.io.Serializable)attachment;
     mo.setAttachment(serAttachment);
     log.debug("Done with attaching .");
     //JBAS-4671

    2) In the writeTemplate of the DsDataSourceTemplate
    Object group = mo.getAttachment();
     log.debug("Getting the name "+mo.getName());
     log.debug("Getting the attachment which is added in the DsDataSourceTemplateInfo "+group);
     if( group instanceof ManagedConnectionFactoryDeploymentGroup )
     {
     //JBAS-4671
     log.debug("------------->"+group);
     AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
     ManagedObject dsDeploymentMO = mof.initManagedObject((Serializable)group,"DataSource", "NoTx");
     log.debug("------------->"+values.getProperties().values());
     try{
     for(ManagedProperty moprop : values.getProperties().values())
     {
     ManagedProperty moProp = dsDeploymentMO.getProperty(moprop.getName());
     if(moProp!=null)
     moProp.setValue((Serializable)moprop.getValue());
     log.debug("setting ManagedProperty "+moprop.getValue()+ "for "+moprop.getName());
     }
     }
     catch(Exception exp){
     log.debug("Eat up this "+exp);
     }
     //JBAS-4671
     }

    Earlier the group was coming as null as the attachment want not added to ManagedObject in Step 1 .

    Any clue what it is complaining about now ?

  • 10. Re: DeploymentInfo/Template MCF
    Alexey Loubyansky Master

    It's complaining because the class is missing JAXB annotations and the marshaller can't figure out how the object should be marshaled.

  • 11. Re: DeploymentInfo/Template MCF
    Vicky Kak Master

    Yes I figured out this and I added javax.xml.bind.annotation.XmlRootElement annotations in ManagedConnectionFactoryDeploymentGroup as

    */
    @XmlAccessorType(XmlAccessType.NONE)
    @ManagementObject
    @XmlRootElement
    public class ManagedConnectionFactoryDeploymentGroup implements Serializable


    After making the changes I am getting some different error
    Testcase: testAddDataSource took 3.002 sec
     Caused an ERROR
    Failed to map property: password to managed properties for deployment
    java.lang.IllegalArgumentException: Failed to map property: password to managed properties for deployment
     at org.jboss.profileservice.management.ManagementViewImpl.applyTemplate(ManagementViewImpl.java:588)
     at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121)
     at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
     at org.jboss.profileservice.remoting.ProfileServiceInvocationHandler.invoke(ProfileServiceInvocationHandler.java:56)
     at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:771)
     at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
     at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
     at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
     at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
     at org.jboss.remoting.Client.invoke(Client.java:1634)
     at org.jboss.remoting.Client.invoke(Client.java:548)
     at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at org.jboss.aspects.remoting.MergeMetaDataInterceptor.invoke(MergeMetaDataInterceptor.java:74)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at AOPProxy$1.applyTemplate(AOPProxy$1.java)
     at org.jboss.test.profileservice.test.ProfileServiceUnitTestCase.testAddDataSource(ProfileServiceUnitTestCase.java:406)
     at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:74)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at org.jboss.aspects.remoting.MergeMetaDataInterceptor.invoke(MergeMetaDataInterceptor.java:74)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
     at AOPProxy$1.applyTemplate(AOPProxy$1.java)
     at org.jboss.test.profileservice.test.ProfileServiceUnitTestCase.testAddDataSource(ProfileServiceUnitTestCase.java:406)
    


  • 12. Re: DeploymentInfo/Template MCF
    Ales Justin Master

     

    "vickyk" wrote:

    After making the changes I am getting some different error

    Is there a cause?
    Check the server side after client invocation for more details.

  • 13. Re: DeploymentInfo/Template MCF
    Alexey Loubyansky Master

    It seems like it's not reproducible on every test run. I mean sometime it fails to deploy and that's it but sometimes it keeps logging the error above.

  • 14. Re: DeploymentInfo/Template MCF
    Alexey Loubyansky Master

    Oh, that was supposed to be posted to a different forum, sorry.

1 2 Previous Next