share/install same datasource/ear with different schema in Weblogic 10.1

Create 2 Admin Server(one in each separate domain ) ,After that start the Admin Server which will   default run in ports 8860 and 8850.then either open the component atg/dynamo/Configuration in ACC,modify the rmiPort and DrpPort to 8861 and 8851 

OR

create a component(Configuration.properties)in  the path C:\ATG\ATGXXX\home\localconfig\atg\dynamo,set the properties rmiPort=8861,drpPort=8851,now start the second Admin Server(testServer),configure your datasources  and deploy the EAR.
But in this method , if the Admin/test  Server is shutdown or stopped,you need to do the whole process again,also you need to make sure there is no component present at the initial server start up time.

Pros :Easy and fast  to configure.
Cons :There  is a chance of Port conflicts,if we are not deleting the
      component from the path each/first time 

      When we start/restart the Servers.Chances of typo,because we
      need to change the values of ports frequently compare to the
      earlier approach.

Recommended Approach

Configure multiple Admin Servers in different domains simultaneously

Create an Admin Server as usual(Admin Server - > localhost:7001) in base_domain with default port.For Configuring the second Admin Server follow the instructions below.

Weblogic Changes -> Go to the Domain Configuration Wizard.

1. From Start Menu,select Programs->BEA Products >
   Tools >ConfigurationWizard

2. Select "Create a new Weblogic domain".

3. Select "Generate a domain configured automatically...." and
   click “Next”.

4. Select the username,password and the appropriate JDK(eg:
   C:\jdk1.5.0_18).

5. After that you will get a screen to customize,answer yes to that
   and change the port  to 7003 and leave the rest to default.

6. Give the name for the domain as “test_domain” and click “create”.

7. Create the new domain.

8. Start the Admin Server(testServer),Configure the required
   datasources and deploy EAR.

9. Modify your weblogic startup   script
   (C:\bea\user_projects\domains\test_domain\bin\startWebLogic.cmd).
   set the  server name in the  JAVA_OPTIONS variable.


10. set JAVA_OPTIONS=-Datg.dynamo.server.name=testServer %
    JAVA_OPTIONS%,before the line set SAVE_JAVA_OPTIONS=% 
    JAVA_OPTIONS%.

ATG Changes

ATG by  default set the RMI Port and Drp Port  as 8860 and 8850 for the Admin Server irrespectieve of domain.so you need to create new  ports  for the newly created testServer.

1.From Start Menu, select Run > type cmd > Go to C:\ATG\ATG9.1
  \home\bin
2.run the command   makeDynamoServer testServer 8861 8851.

Note: 
    
You will get rmiInitialisation Exception(JVM_BIND port already in use),if you fail to configure the DynamoServer.

After this you can deploy EAR's and start Running your application in both Admin Servers.

There is also another easy way to configure the  same with minimal changes -> Alternate Approach

remote debug in eclipse with both Admin and Managed Servers running

For configuring Remote Debug in Managed Weblogic Server,the very first golden rule is,you should not specify any port number of  weblogic admin or  managed server which is running ,it has to be a free port(use this link to find the appropriate ports List of Ports).

How to create managed weblogic server and run multiple EAR's can be found in this link -> Run Multiple Ear in Managed Server Mode

How to run remote debug in Admin server can be found in the link
->Remote Debugging Weblogic Admin Server


The configuration  for remote debug is specified in the startup script 'setDomainEnv.cmd'.



First Approach

Here we need to  create three scripts corresponding to the orignial scritps,'startManagedWeblogic.cmd', 'startWeblogic.cmd' and 'setDomainEnv.cmd.


For Eg:

Create the scripts  startManagedATGProductionWeblogic.cmd,startWeblogicATGProduction.cmd,
setDomainEnvATGProduction.cmd by copying from the original script.Modify the call to each of this scripts as per the new naming convention.

Then for the degbug to work  in the setDomainEnvATGProduction.cmd file

1. Set the debgug flag as true in the first line of the script.(set
   debugFlag=true)

2. Add the line to append JAVA_OPTIONS variable,if the debug options is not already there.Now all recent weblogic versions comes with the debug option.

set JAVA_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8002,server=y,suspend=n %JAVA_OPTIONS%

In the address property you need to specify the debug port which i used as 8002 here.

Save the file and restart your managed weblogic server.
At the startup of managed weblogic server you can see this message
'Listening for transport dt_socket at address: 8002' you are done !!! . For Your Admin Server specify a port  eg:8004 in
setDomainEnv.cmd.Hope you know how to configure remote debug in eclipse.

Second Approach (Updated as per the new CIM settings)

Run CIM which will create instances for ATG Production,ATGPublishing and other Servers based on your Product Selection,you need a simple modification in the auto generated script generated by CIM for your Managed Servers. Copied the scripts generated by ATG10.2 CIM configurations below for your reference.The Bold part is the modification you need to do for remote debug to work.

C:\ATG\ATG10.2\home\servers\ATGProduction\startServerOnWeblogic.bat

setlocal
title ATGProduction

REM  -- Update USER_MEM_ARGS - added by CIM

set debugFlag=true

if "%DEBUG_PORT%"=="" (
    set DEBUG_PORT=8446
)


if "%JAVA_USE_64BIT%"=="true" (
  set USER_MEM_ARGS=-Xms512m -Xmx1024m -XX:NewSize=128m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=512m
) else (
  set USER_MEM_ARGS=-Xms512m -Xmx1024m -XX:NewSize=128m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=512m
)

REM  -- End USER_MEM_ARGS block - added by CIM
call "C:/Oracle/Middleware/user_projects/domains/base_domain//bin/startManagedWebLogic.cmd" ATGProduction t3://localhost:7001/ %*

endlocal


The script setDomainEnv.cmd will check whether the DEBUG_PORT is set,we are overriding this in the above script from our Managed Server and setting it to 8446.Similiarly if we call Admin Server Startup script it will default to port 8686.

setDomainEnv.cmd

if "%DEBUG_PORT%"=="" (
    set DEBUG_PORT=8686
)


This apporach will help to simultaneously run Admin and Managed Server with different EARS with Debugging enabled,This will be useful for Eg: We have a ATGProduction and ATGFullfillment Applications running in Admin and Managed or in multiple Managed Servers,We can run a live debug between applications,so that First Application create an Order and Second Applications start Processing the Order.

configure jadclipse in eclipse platform

download the zip file jad158.zip,This can  be downloaded from the following link.

Java Decompiler

extract the zipfile to verify the files 'net.sf.jadclipse_3.3.0.jar' and 'jad.exe' are present.

copy the net.sf.hadclipse_3.3.0.jar to the working copy of your eclipse plugin folder.

open your eclipse goto  Window->Preferences,Expand the Java Tab,now you will see the JadClipse option.

click on the 'JadClipse' option tab,you may find two fields.set the values as below.

1. Path to decompiler to your jad executable location
   (eg D:\workspace\setup\JAD\jad158.exe).
2. Directory for temporary files to  any desired folder(eg
   D:\workspace\setup\JAD).

Click Apply,Ok and Restart your Eclipse,done !!!

Now press F3 button on the class to view the source for that class.



Configure JUnit

Download the junit-4.10.jar file from the location  and add this file in the java build path on the Eclipse Project where we want to configure the Junit.



After you configured the build path,restart your workspace and you will see an option like below to run the JUnit test cases.



For Creating method stubs you need to right click on the respective Java File ,New-JUnit Test Case.Give a name with a suffix 'test' preferably,click 'Next' , you can see a list of methods in the actual class select the checkbox for corresponding methods you want to create stubs and click 'Finish'.

download,copy jad158.zip file for JadClipse

click on the link jad158.zip



download the jar file.

let me know if you are finding any difficulty in downloading this  file ,i have already downloaded this and its working,if you have faced some issue in downloading this file,i can upload the file in some free ware site,or i can send the zip file via email since the file size is not big.Please leave your email id in the comments section in that case.

Junit Download

Navigate to the link
http://sourceforge.net/projects/junit/files/junit/4.10/.Click on the link junit4.10.jar.


 

Unversioned and Versioned Repositories in ATG Content Administration

Unversioned

1.Resides in CA Environment.
2.Instance of GSA 

3.No modifications are required in  Unversioned Repository 
  Definitions.                                                   
4.No Extra properties are required.                   
5.'this' attribute is not applicable here    
                                        
Versioned


1.Resides in Production Environment.
2.Instance of Version Repository
3.Needs modifications in Versioned Repository Definition,eg: Remove

  Foreign key relationships,Remove unique attribute if   used.
4.Other versioning properties,such as asset_version,is_head etc.are

  automatically added to Item definition  by CA server.
5.Set versionable attribute to specify which assets

  needsVersioning.By default all asset are versionable.
 

Note: In both scenarios you need to follow the repository best practices, Repository Best Practices

Significance of ATG Content Administration in Ecommerce

There are other CA products available which support file asset versioning but Repository assets versioning is only possible with ATG CA.

ATG provides different deployment methods, all of which are useful  based on what the scenario is,

One-Off Deployment
Switch Deployment
Staging Deployment

One-Off Deployment

In some instances you might need to verify project content prior to the workflow deployment,like you can evaluate the performance of the project content or its gui elements before submitting review for that project,This scenario you can deploy the project to a site defined as one-off target.

Switch Deployment
Basically Repository Assets and File Assets can be deployed uisng Switch Deployment.This requires multiple Databases one an active database and other one Inactive.Repository assets are deployed to the inactive database first and once the deployment to this database completes ,the SwithcingDataSource switches the DataSource to this updated Database and the Inactive becomes Active.After this the deployment will takes place to the Active database(Active before Switching ie:now inactive database) in similiar manner.

File assets are also deployed in a similiar manner,Here instead of active and inactive databases we have live directory and inactive directory.

ATG  provides different preview facilities

Local preview [From CA server]
Remote preview [From other server]

As this is an ATG product, it goes well with ATG commerce Applications.

Samsung Galaxy Pro(B7510) restarting often/problems

I purchased Galaxy Pro B7510 5 months back(Running in Fro yo -Android 2.2),but last 2 days it started rebooting every 5 or 10 minutes.I checked the possible solutions in internet.I tried few methods  but finally i solved the issue.Following are the steps i tried.

I have cleared the cache to check whether any possible depletion
of memory.This will solve the issue  if the memory is depleted.

While starting the phone hold the power key and 'T' key of Qwerty
Keypad until you are  shown a system recovery screen.'System
Reboot' will be default option selected,if not navigate using   
your 'volume key' to scroll down to  'System Reboot' and press
'Home key' from your keypad to  Reboot the System.Verify your
issue is solved.

Switch Off your mobile phone,take out your Sim card and battery
and place it back,now switch on and see if it solved the issue.

samsung galaxy















If the issue is still persisting,from your phone menu click the
icon 'Market',search for Gingerbread,This will give a list of
applications,from the list select ,Android 2.3 Launcher (Home)'
from Steven Lin,Install this application and reboot the
system.This worked for me !!

Phone Not Charging

I faced another issue recently,my phone shows full battery whenever connected to the charger,whereas actually
its not getting charged ,then the moment i unplug,it will immediately shutdown/off.This happen intermittently
2 or 3 days in a week.


Here are few tips that might be helpful for you to decide on what steps need to take in this situation.

Inspect your battery first,check the battery is swollen,if its change your battery immediately and see the problem happening again or not,many cases the issue happens because of the damaged battery,my case the battery was swollen and i changed it and it worked for another 2 or 3 days without any issues,again faced with the same issue.so i thought of showing it to nearby Samsung authorized service center,the moment i gave the phone they told, its a charger pin issue and within two hours they replaced the pin and gave back my phone,i paid around 650rs,whereas the pin will cost exactly Rs300 and another Rs300 + Rs50 for the service charges including VAT.The phone is now working smoothly without any issues.This was kind of huge relief for me,so thought of sharing this which might be helpful.

If you have trust in some local shop,you can get it replaced with  less cost,but i always prefer  Samsung authorized service center.

Content Administration in Ecommerce- Asset Types

    Types of Assets

Repository assets
Promotions, price lists, catalogs, etc.

File assets    
  ATG-specific [ ConfigFileSystem ]
    ATG Scenarios, targeters, slots, segments
  Generic [ WWWFileSystem ]
    Jpg, pdf, etc.

JSPs can be considered as content if managed by business users
e.g. email templates,product templates etc.Otherwise JSPs are
source  code.

Customer-managed content e.g. orders, reviews, profiles,
Java class, components, etc can not be considered.  

Significance of Content Administration in Ecommerce

Content can be updated without bringing production
site down. Business users can create and deploy content
on live site without any IT intervention.Content changes can be previewed and approved  before making it live.

Each and every changes made to the content can be tracked.
Content changes can be reverted back to a particular
version if required.Who changed what, under whose approval,
can be tracked.

you can also verify the significance of ATG Content Administration
in Ecommerce.

ATG Best Practices Form Handler Dont's

Don’t mix business logic with presentation: Formhandler and JSP page should not have any business logic. It should only contain page field’s validation. All business logic regarding validation should be defined in global component and formhandler should refer to it in handler method.

Reusable components: Different Formhandlers will be able to reuse the components.

Separation of business logic and presentation logic: You can change the way data is displayed without affecting business logic. In other words, web page designers can focus on presentation and Java developers can focus on business logic.

Don’t use FormHandler to load the page information, use Droplet to populate data for  display

o They can eliminate scriptlets in your JSP applications. Any 
  necessary parameters to the Droplet can be passed as attributes, 
  and therefore no Java code is needed to initialize or set
  component properties.

o They have simpler syntax. Scriptlets are written in Java code, but
  OOTB or custom Droplet can be used in an HTML-like syntax.

o They can improve the productivity of frontend or content
  developers

o They are reusable. They save development and testing time.
  Scriptlets are not reusable, unless you call cut-and-paste
  "reuse."

Never call Nucleus component and web services from Page. This may be fast and easy to use but at the cost of many other important features of formhandler like field security, cross
scripting attack, encoding and decoding.

Never set successUrl, errorUrl and other url for redirect from JSP page. This  should   be set   into   formhandler properties files. Defining redirect urls on page increase the  risk of  cross -site scripting attacks.

Try not to re-invent the wheel: ATG provides wide range of ATG OOTB droplets and Formhandlers.

Check to see if what you want is already available. Avoid writing Formhandler from scratch, find the component closest in functionality to what the application needs and extend it if needed.
  

See Also   

ATG Form Handler Best Practices Do's

  • Each and every JSP page should be associated with one form handler,it may be custom or OOTB form handler.
  • Avoid reusing custom formhandler; ideally it should be one to one mapping between page and custom formhandler.  This will reduce the maintenance effort and increase the readability.
  • Formhandler scope may be request or session, request scope is always recommended. Sometimes we can define session scope if the formhandler is called several times in one session, to avoid creation of multiple copies. But be very careful, you need to reset and initialize formhandler field after usage.
  • Formhandler should only refer to same scope or higher scope component i.e. session formhandler should never refer to any request scope component;session and global are valid scopes,and allowed.Never use Nucleus.resolveName to resolve component,this is very extremely expensive call. Better re-think about your component architecture.
  • Formhandler should never refer to another formhandler.  If they share form fields, better put those fields in base formhandler and then extend it. If this doesn’t solve well the purpose and makes your design complex, move common method to manager and refer it from formhandler to reuse code. ATG formhandlers are designed to be invoked from page. If you use it through component reference in other components, you may miss initialization beforeSet and afterSet callback methods.
  • All page data should be passed through formhandler, avoid passing any attribute through request and session.
  • Set the priority of the field to "-10" for required input fields other than submit button, so that it gets invoked after all of the setters have been called.
  • Return false from formhandler handler method if you are done with the page and no need to process the page further.
  • Return true to redirect to success page.
  • See ATG Repository Best Practices
  • See ATG Form Handler Basics 
  • See ATG Transaction Best Practice 
  • See ATG Weblogic Best Practices

ATG Repository Best Practices/Useful Tips While Creating Repository

Never user one primary table in more than one item descriptor,this can create problem in Item caching.If table get updated by one Item, other Item will not get invalidate.

Try to avoid derived properties, it can adversely affect system performance

Don’t use derived and transient property as part of RQL and ATG Query

Use Lazy loading in repository item to improve performance.

Most of time developers traverse from parent to child repository, you may need to evaluate. Use RQL instead of looping through repository item which can affect performance.

Maximize use of Query Builder to build query in case you need to build query dynamically rather than executing filtering at server end.

Use enumerator instated of flag until it is required.

You can also turn on debug messages by including a loggingDebug attribute tag in the repository definition for that item descriptor or property.

Use ATG cache pre-loading, this will achieve better performance disadvantage of this would be slower startups. You can configure the SQL repository to automatically save and restore its caches, or you can load the caches manually by using the startSQLRepository script with an appropriate XML file. It is probably a good practice to put cache-loading tags in a separate XML file with the same name as your repository definition file and rely on XML file combination to invoke the queries.

All properties referred to in the filterQuery or rqlFilterString should reside in the primary table for the item descriptor. This will provide good result in terms of performance; otherwise joins will be required to get result which can adversely affect performance.

Always add NULL check with Comparison and pattern-match repository queries,as it do not return items where the property queried is null. If you want null items to return you have explicitly add null constrain eg :(amount != 10) OR (amount IS NULL).

Used Named query, this can be reuse you don't have to build a new query object each time.

Define column-name  attribute explicitly even when identical to property name.

Set required atrribute to true for properties linked to non nullable columns.


See Repository Cache hitRatio,missRatio and usedRatio

How to run remote debug in eclipse with weblogic

I came across so many question and answers posted by peoples regarding to initiate a remote debug session from eclipse to application which is running in xyz port of weblogic server.so thought of coming up with what i have done,which is pretty straight forward.(i have tried this successfully in Weblogic9.1)

The very first golden rule is,while configuring the remote debug session make sure you are not specifying the same port number where your weblogic server is running,it has to be a free port(use this link to find the appropriate ports -> List of Ports).

The configuration  for remote debug is specified in the startup scripts of weblogic server,either in the 'startWeblogic.cmd' or 'setDomainEnv.cmd' or any other executable file associated with startup of the server.

I am modifying the script 'setDomainEnv.cmd'.Below are the two things you need to do to achieve this.

1.Set the debgug flag as true in the first line of the script.(set
  debugFlag=true)
2.Add the line to append JAVA_OPTIONS variable.

debug java options




In the address property specify the debug port which i have given 8000.

Save the file and restart your weblogic server.
At the startup of weblogic server you can see this message
'Listening for transport dt_socket at address: 8000'
you are done with Weblogic.

Now go to your Eclipse IDE,Select WIndow-Show View-Debug.Debug Configurations-Remote Java-Application,right click,New.Name - can be any name,Project will be set default if you have already opened a file in Eclipse,otherwise choose from available projects configured in workspace, Hostname is the Server you want debug remotely, and the port is 8000,start debugging .

you can also check how we can run a  remote debug while both your admin and managed servers are running ->
Remote Debug with Managed Servers Running

ATG Repository Caching Dont's

Don’t enable query caching it is turned off by default. If items in your repository are updated frequently, or if repeated queries are not common, you may not receive enough benefit from a query cache to justify the minor amount of overhead in maintaining the cache.

Disable caching when there is a possibility that the underlying data will be changed by a non-Dynamo repository application. You can also disable caching for an individual property within an item-descriptor by setting the cache-mode="disabled" attribute on the property itself. All other cache modes must be set at the item descriptor level, however, and cannot be set on a per-property basis.

If you use locked cache mode, you should disable the query cache, since query cache invalidation messages are not distributed between server instances. If query caching is important for the performance of your application, use distributed cache mode.

ATG Repository Caching Do's

Caching: ATG prints lot of SQL queries on console if you turn on SQL debug info. Most of the developers get confused how this can optimize database operation. The following paragraph will answer all such doubts:

The item caches hold the values of repository items. Repository queries are performed in two passes, using two separate SELECT statements. The first statement gathers the IDs of the repository items that match that query. The SQL repository then examines the result set from the first SELECT statement and finds any items that already exist in the item cache. A second SELECT statement retrieves from the database any items that are not in the item cache.

If query caching is enabled, the first time a query is issued, the result set is retrieved from the database and stored in the query cache. Then, the next time this same query is issued, the SQL repository can retrieve the result set from the cache, rather than needing to access the database. This cache only hold repository ids not all items and it fetch all the available items from Item cache and goes to db for rest of the items. i.e. your query return 200 items then query cache will hold 200 ids (which are just string objects) and if ATG found 190 items in item cache the repository will fetch 190 from cache and will retrieve remaining 10 items from db.

Use cacheReferencesById attribute of property, in some cases, you might have a property in a repository item that references a large sub-tree of items. Then, you can use the tag to set the attribute cacheReferencesById=true. The SQL Repository then will not store the repository items referred to, but will instead store only the repository IDs of the items referred to in the item cache.

install/deploy mutliple EAR at the same time in ATG platform

There are few things we need to take care while running multiple EARs in Managed Weblogic Servers during our development phase.

Below are the steps followed by me in running more than one EAR's.

This is how i did it.

I assume you have knowledge on how to create an admin server and  i assumed you have created one which is listening to  port 7001.

Now 

1. In weblogic admin, goto weblogic->environment->server
      - create a new managed server with port 7002.
2. In weblogic->environment->services->jdbc
      - add newly created managed server as target to your
   respectieve datasource XXX_DS
3. In weblogic->environment->deployment
    - install your EAR  and deploy it.
4. From the ATG's home/bin directory - (eg:C:\ATG\ATG9.0
   \home\bin)          
      - create a DRP server by running following command
        makeDynamoServer XXX-Drp-Server 8861 8851
5. In  
     C:\bea\user_projects\domains\base_domain\bin\
     startManagedWebLogic.cmd
     add following line
          set JAVA_OPTIONS=-Datg.dynamo.server.name=XXX-Drp-Server
          - add user name and password in the same file.

          Search for existing entries and enter password
                  set WLS_USER=weblogic       
                  set WLS_PW=weblogic
         
6. Create desktop shortcuts to start and stop XXX-Managed-Server

          start target:

   C:\bea\user_projects\domains\xxx_domain\bin\
   startManagedWebLogic.cmd  XXX-Managed-Server

          stop target:
   C:\bea\user_projects\domains\xxx_domain\bin\
   stopManagedWebLogic.cmd XXX-Managed-Server

You can create 'n' number of managed servers by following the same process,there by deploying EAR's of your different application modules to these managed servers.

Please provide your comment if you need any information
Related Posts Plugin for WordPress, Blogger...