11 Replies Latest reply: Oct 8, 2013 6:58 AM by 992970 RSS

    login  or creation of user from custom pipelineservlet.

    992970

      Hi,

       

      we have a requirement like user will be loggedin or created in one of custom request pipeline servlet.  In this pipeline we will invoke a webservice call. Using this response, user will be either loggedin or created if not exist already. To create user one method  createUser(String pProfileAsXML) is provided in OTTB profieservice component. But here the input parameter (pProfileAsXML) is how to construct. What is the xmlStructure to construct the string. And is there any other configurations required ?

       

      Please help me to resolve this.

       

      Thanks in Advance.

      Lakshmi.

        • 1. Re: login  or creation of user from custom pipelineservlet.
          Nitin Khare

          The createUser() method in ProfileServices will take an XML as string parameter which should conform to the schema used for ATG's Repository-to-XML binding. You can generate the XML schema (XSD) using an OOTB ATG utility "generateXMLSchema" by providing repository and item details for which you would like to generate your schema:

           

          generateXMLSchema -m YOUR_MODULE -repository /atg/userprofiling/ProfileAdapterRepository -itemDescriptor user -mappingFile profileMapping.xml

           

          In this command, the mappingFile specifies what properties of this particular item you want to include or exclude. ItemDescriptorMappingManager and SchemaMagaer are two components which we can configure as per our needs to specify the location of schema and mapping files.

           

          For more details on all this you can refer to documentation

          Oracle ATG Web Commerce - Repository to XML Data Binding

           

          So once you have generated the XSD, you can create your profile XML according to the schema and use it as string parameter to the createUser() method. Hope it helps.

          • 2. Re: login  or creation of user from custom pipelineservlet.
            992970

            ThankQ Nitin. I got idea from ur response.  But while executing i got the following error. Did I miss anything ?

             

            Error  Fri Sep 06 20:14:28 IST 20131378478668912   /atg/dynamo/service/jdbc/DirectJTDataSource Failed to resolve java:/SlXDS  javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
            1. Thanks
            2. Lakshmi
            • 3. Re: login  or creation of user from custom pipelineservlet.
              Nitin Khare

              Looks like that your datasource was not properly configured while running generateXMLSchema tool. When you use any of ATG's command based utility/tools, it runs in its own VM process and the ATG data-sources that you would have created in your app-server would not be available in this case.

              ATG uses XA data-source which provides you the ability to work with two or more databases or when you want to use distributed transactions with 2-phase commit. But these XA data-sources are available through JNDI only when running within the app-server context. To deal with the situations when JNDI is not available, ATG provides one OOTB FakeXaDatasource and you would need to change your DirectJTDataSource configuration so that it can use FakeXADataSource. Your current DirectJTDataSource configuration would be something like:

               

              $class=atg.nucleus.JNDIReference

              JNDIName=java:/SlXDS

               

              You can create following properties files under your <ATG>\home\localconfig for this:

               

              /atg/dynamo/service/jdbc/DirectJTDataSource:

              ===================================

              $class=atg.service.jdbc.MonitoredDataSource

              dataSource=/atg/dynamo/service/jdbc/FakeXADataSource

               

              /atg/dynamo/service/jdbc/FakeXADataSource:

              ===================================

              $class=atg.service.jdbc.FakeXADataSource

              URL=<JDBC URL for the DB having ATG schemas>

              user=<username>

              password=<password>

              driver=<jdbc-driver-class-name>

               

              You might need to add your JDBC driver in the classpath while running the command. Once you are done with the command line tool, you can revert these configurations and continue with your XA data-sources. You can also create a dynamo server for keeping these tools specific configurations under that and can specify it with the "-s" parameter to the ATG tools which will then pick the configurations from the specified server.

              • 4. Re: login  or creation of user from custom pipelineservlet.
                992970

                Hi Nitin,

                  I have followed the steps mentioned by you. But i am getting the following error. I am not able to understand what wrong i did in DirectJTDatasource.

                 

                JAVA_VM: C:\xxxx\Java\jdk1.6.0_37\bin\java

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /       Bad type for property "/atg/dynamo/service/jdbc/JTDataSource.dataSource" atg.nucleus.ConfigurationException: /atg/dynamo/service/jdbc/DirectJTDataSource        java.lang.IllegalArgumentException: argument type mismatch

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                 

                NameResolver.createFromName(NucleusNameResolver.java:928)

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /               at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:667)

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /               at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:648)

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /               at atg.nucleus.NucleusNameResolver.resolveName(NucleusNameResolver.java:493)

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /               at atg.nucleus.ConfigurationRef.getValue(ConfigurationRef.java:119)

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /               at atg.nucleus.SimpleComponentState.setBeanProperty(SimpleComponentState.java:403)

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /               at atg.nucleus.SimpleConfigurationState.saveToBean(SimpleConfigurationState.java:240)

                 

                atg.repository.xml.XMLSchemaGenerator.processCommandLineArgs(XMLSchemaGenerator.java:609)

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /               at atg.repository.xml.XMLSchemaGenerator.parseCommandLineArgs(XMLSchemaGenerator.java:511)

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /               at atg.repository.xml.XMLSchemaGenerator.main(XMLSchemaGenerator.java:405)

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068873   /

                 

                Error      Tue Sep 10 14:21:08 IST 2013    1378803068936   /       Unable to start service "/atg/dynamo/service/jdbc/JTDataSource": atg.nucleus.ServiceException: The suppplied DataSource JNDI name null did not resolve to a DataSource.

                 

                Error      Tue Sep 10 14:21:09 IST 2013    1378803069061   /atg/dynamo/service/IdGenerator ---     CONTAINER:atg.service.idgen.IdGeneratorException;

                 

                Thanks ,

                Lakshmi.

                • 5. Re: login  or creation of user from custom pipelineservlet.
                  user590668

                  Laxshmi,

                  You can add JTDataSource.properties,SwitchingDataSource.properties,FakeXADataSource.properties,FakeSwitchingDataSourceA.properties,FakeSwitchingDataSourceB.properties in the localconfig/atg/dynamo/service/jdbc/ path & run command, it will connect to database. kindly modify property file as per your configuration

                   

                  JTDataSource.properties

                  dataSource=/atg/dynamo/service/jdbc/FakeXADataSource

                   

                  FakeXADataSource.properties

                  $class=atg.service.jdbc.FakeXADataSource

                  driver=oracle.jdbc.xa.client.OracleXADataSource

                  URL=jdbc:oracle:thin:@localhost:1521:orcl

                  user=CORE

                  password=CORE

                   

                  SwitchingDataSource.properties

                  dataSources=\

                      DataSourceA=/atg/dynamo/service/jdbc/SwitchingDataSourceA,\

                      DataSourceB=/atg/dynamo/service/jdbc/SwitchingDataSourceA

                   

                  SwitchingDataSourceA.properties

                  dataSource=/atg/dynamo/service/jdbc/FakeSwitchingDataSourceA

                   

                  FakeSwitchingDataSourceA.properties

                  $class=atg.service.jdbc.FakeXADataSource

                  driver=oracle.jdbc.xa.client.OracleXADataSource

                  URL=jdbc:oracle:thin:@localhost:1521:orcl

                  user=CATA

                  password=CATA

                   

                  FakeSwitchingDataSourceB.properties

                  $class=atg.service.jdbc.FakeXADataSource

                  driver=oracle.jdbc.xa.client.OracleXADataSource

                  URL=jdbc:oracle:thin:@localhost:1521:orcl

                  user=CATB

                  password=CATB

                   

                   

                  Thanks

                  Shailesh Londhe

                  • 6. Re: login  or creation of user from custom pipelineservlet.
                    992970

                    Thank you Shailesh,

                    After creating all the components now i got the following error even i added ojdbc.jar in classpath

                     

                    . **** Error      Tue Sep 10 18:37:35 IST 2013    1378818455584  /atg/dynamo/service/jdbc/JTDataSource  an exception was encountered while trying to populate the pool with the starting number of resources: atg.service.resourcepool.ResourcePoolException: java.sql.SQLException: java.lang.ClassNotFoundException: oracle.jdbc.xa.client.OracleXADataSource **** Error      Tue Sep 10 18:37:35 IST 2013    1378818455599  /atg/dynamo/service/jdbc/JTDataSource  The connection pool failed to initialize propertly, i.e. the starting number of connections could not be created; check your database accessibility and JDBC driver configuration **** Error      Tue Sep 10 18:37:35 IST 2013    1378818455709  /atg/dynamo/service/IdGenerator ---    CONTAINER:atg.service.idgen.IdGeneratorException; SOURCE:CONTAINER:atg.service.idgen.IdGeneratorException; SOURCE:java.sql.SQLException: atg.service.resourcepool.ResourcePoolException: java.sql.SQLException: java.lang.ClassNotFoundException: oracle.jdbc.xa.client.OracleXADataSource **** Error      Tue Sep 10 18:37:35 IST 2013    1378818455709  /atg/dynamo/service/IdGenerator        at atg.service.idgen.PersistentIdGenerator.initialize(PersistentIdGenerator.java:389)

                     

                    Thanks,

                    Lakshmi.

                    • 7. Re: login  or creation of user from custom pipelineservlet.
                      user590668

                      Laxmi,

                      Please add ojdbc6.jar into CLASSPATH and PATH from environment variable . it will work

                       

                       

                      Thanks

                      Shailesh Londhe

                      • 8. Re: login  or creation of user from custom pipelineservlet.
                        992970

                        Hi Shailesh,

                         

                        Now the above error is resolved by adding ojdbc6.jar. Now i got the following error . Actually I want to generateXML schema for profileAdapterRepository.Is datasource for  catalog required?

                         

                        . **** info       Wed Sep 11 15:59:52 IST 2013    1378895392276   /atg/commerce/pricing/Promotions        Resolving reference to /atg/commerce/catalog/ProductCatalog **** info       Wed Sep 11 15:59:52 IST 2013    1378895392355   /atg/dynamo/service/jdbc/SDSRepository  SQL Repository startup complete **** Error      Wed Sep 11 15:59:52 IST 2013    1378895392370   /atg/dynamo/service/jdbc/SwitchingDataSourceA   Failed to resolve java:/xxxSwitchingA        javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial **** Error      Wed Sep 11 15:59:52 IST 2013    1378895392370   /atg/dynamo/service/jdbc/SwitchingDataSourceA           at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)

                         

                        Thanks

                        Lakshmi

                        • 9. Re: login  or creation of user from custom pipelineservlet.
                          user590668

                          Hi Lakshmi,

                          Please click on below link for createUser Webservice solution

                          Oracle ATG Web Commerce - Part III. Web Services for Personalization and Scenarios

                           

                           

                          Thanks

                          Shailesh

                          • 10. Re: login  or creation of user from custom pipelineservlet.
                            Nitin Khare

                            Don't know if you have already resolved the issues you were facing but you need not (and can't) use switching datasource configuration in this case when you are running a command tool. All you needed was to create a FakeXADataSource configuration as I mentioned earlier and point your JTDataSource also to use the same FakeXADataSource.

                             

                            /atg/dynamo/service/jdbc/JTDataSource:

                            =============================

                            $class=atg.service.jdbc.MonitoredDataSource

                            dataSource=/atg/dynamo/service/jdbc/FakeXADataSource

                            • 11. Re: login  or creation of user from custom pipelineservlet.
                              992970

                              Thanks Nitin.It is resolved.