Fixing Resource Already Exists on Disk Errors in Eclipse

When I imported a new project I could not build it because of “Resource already exists on disk” errors like this.

Eclipse: The project was not built due to "Resource already exists on disk"

The simple fix was to remove the directory, typically classes, which contained the file it was complaining about and then refreshing. Removing just the file and then refreshing did not work.

However when I would do an ant build later and then refresh my project I would get the same error.

The better solution is to tell Eclipse not to copy the files it is complaining about to the output folder.

  1. Go to Project Properties.
  2. Select Java Compiler -> Building.
  3. In the Filtered resources box add the files you don’t want copied.
  4. Rebuild project.

Here is a screenshot showing how I added “*.properties, *.xslt” to the Filtered resources to fix this problem.

Eclipse: Filtered resources in Project Properties, Java Compiler, Building

Eclipse: Filtered resources in Project Properties, Java Compiler, Building

Cannot Login To BCC

Business Control Center Error

Sometimes I can’t login to the BCC. Usually when that happens I see errors like this in the logs.

page seeing error: /atg/templates/page/html/BizUIPageTemplate.jsp
error message: null

java.lang.NullPointerException
   at org.apache.pluto.factory.PortletObjectAccess.getRenderRequest(PortletObjectAccess.java:36)
   at org.apache.pluto.PortletContainerImpl.portletLoad(PortletContainerImpl.java:197)
   at atg.portal.portletstandard.services.ATGContainerService.portletLoad(ATGContainerService.java:202)
   at atg.portal.servlet.GearRequestDispatcherImpl.dispatch(GearRequestDispatcherImpl.java:397)
   at atg.portal.servlet.GearRequestDispatcherImpl.include(GearRequestDispatcherImpl.java:438)
   at atg.portal.servlet.GearRequestDispatcherImpl.include(GearRequestDispatcherImpl.java:453)
   at atg.portal.framework.taglib.IncludeTag.doEndTag(IncludeTag.java:162)
   at atg.portal.framework.taglib.elwrap.IncludeTagWrapper.doEndTag(IncludeTagWrapper.java:36)
   at org.apache.jsp.templates.layout.html.BizUILayout_jsp._jspx_meth_paf_005finclude_005f0(BizUILayout_jsp.java:708)
   at org.apache.jsp.templates.layout.html.BizUILayout_jsp._jspService(BizUILayout_jsp.java:263)
....stack trace CROPPED after 10 lines.
ATG Business Control Center 
© ATG 2005-2011

When this happens I first try clearing my cookies and then reloading the BCC login page.

When that doesn’t work I then remove the tmp and work directories.

$ cd /opt/jboss/home/server/merch
$ rm -rf tmp work

Then I restart the BCC and things seem happy again.

Fixing Existing Repository ID Errors

I was feeling part of the scenery. I walked right out of the machinery. | Flickr

I was feeling part of the scenery. I walked right out of the machinery. by Neal.

The other day I was trying to create a page repository item using the BCC when I got an error saying it could not create the item. Looking in the logs I saw this exception.

16:13:59,909 ERROR [RepositoryAssetService]
atg.repository.RepositoryException: createItem() was called with an existing ID : '3100007' for type 'page'. Use getItemForUpdate() instead.
        at atg.adapter.version.VersionRepository.createItem(VersionRepository.java:1903)
        at atg.adapter.version.VersionRepository.createItem(VersionRepository.java:1125)
        at atg.remote.assetmanager.editor.service.RepositoryAssetServiceImpl.doCreateAsset(RepositoryAssetServiceImpl.java:476)
        at atg.remote.assetmanager.editor.service.AssetServiceImpl.createAsset(AssetServiceImpl.java:331)
        at atg.remote.assetmanager.editor.service.AssetEditorService.createAssetAndLink(AssetEditorService.java:555)
        at atg.remote.assetmanager.editor.service.AssetEditorService.createAsset(AssetEditorService.java:508)

The problem was the ID generator was producing ID’s that already existed in the database. This sometimes happens when things are imported into the BCC.

To fix this problem do the following.

  1. Look for the row in the das_id_generator table which has the item descriptor that is causing the error.
  2. Change the seed value (typically upwards) or put a prefix or suffix on it.
  3. Restart the server.

In this case I ended up running this SQL to fix the existing ID error:

UPDATE DAS_ID_GENERATOR SET PREFIX = 'pg_' WHERE id_space_name = ‘page’;

Clearing Out BCC Projects

Clean Up or You're Out! :Brooklyn Street Sign | Flickr

Clean Up or You’re Out! :Brooklyn Street Sign by emilydickinsonridesabmx

This may not be the best way to clear out your BCC projects but it’s quick.

delete from epub_pr_history;

delete from epub_project;

delete from epub_proc_history;

delete from epub_proc_taskinfo;

delete from epub_ind_workflow;

delete from epub_process;

delete from avm_asset_lock;

delete from avm_workspace;

Changing VirtualBox’s Disk Image Sizes

I was running out of room in my Virtual Box Windows 7 disk.  Windows was reporting used space of 18.6 GB and free space of 1.22 GB.  My Mac was reporting that my disk image was using up 21.39 GB.

Compacting

On your Windows Guest:

  1. Run Disk Cleanup.
  2. Run Disk Defragmenter.
  3. Download SDelete and use it to zero out free space. I put sdelete in C:\Windows\System32 and then ran it like this from the command prompt.
    C:\> sdelete -c c:/

  4. Shutdown Windows.

On your Mac Host:

  1. Run VBoxManage from the Terminal to compact the disk image.
    $ VBoxManage modifyhd Windows.vdi --compact

Sad Story

I first tried shrinking the disk image to see if that would free up room using the instructions above which were based on the article How To Shrink Your Virtualbox VM And Free Up Space For Your Hard Disk.

After doing this Windows reported used space of 18.8 GB and free space of 1.03 GB.  In other words no difference. Sad smile  But on the Mac the disk image was now only using up 20.51 GB.

Resizing

On your Windows Guest:

  1. Shutdown Windows.

On your Mac Host:

  1. Run VBoxManage from the Terminal to resize the disk image. This is how I did it.
    $ VBoxManage modifyhd Windows.vdi --resize N

On your Windows Guest:

  1. Restart Windows.
  2. Use diskpart to resize the C: drive to use the new space.

Happy Story

Realizing that compacting did not work I shut down again and this time increased the size of the disk image by 10 GB from 20 GB to 30 GB (N = 30720).

VirtualBox showed in its settings that the disk image size was now 30 GB.  But Windows still reported used space of 18.8 GB and free space of 1.03 GB.  Again no difference. Sad smile  And on the Mac the disk image was still the same but that was to be expected.

Back to Google which led me to Windows’ brilliant tool diskpart.

C:\>diskpart

Microsoft DiskPart version 6.1.7600
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: WIN-7-IMAC-POOP

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     D   VBOXADDITIO  CDFS   CD-ROM        38 MB  Healthy
  Volume 1         System Rese  NTFS   Partition    100 MB  Healthy    System
  Volume 2     C                NTFS   Partition     19 GB  Healthy    Boot

DISKPART> select volume 2

Volume 2 is the selected volume.

DISKPART> extend size=10240

DiskPart successfully extended the volume.

Windows now reported free space of 11.0 GB.Open-mouthed smile

End Note

I originally tried resizing the disk by specifying the size of how much I wanted the disk increased, i.e. 10 GB or N=10240.

$ VBoxManage modifyhd Library/VirtualBox/HardDisks/Windows\ 7.vdi --resize 10240

This failed with the strange error:

Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!

Fortunately I found out in one of the VirtualBox forums that this happened because I gave the wrong argument to resize.  Too bad the error message wasn’t a little more helpful. Smile

Adding a New Link to a Commerce Pipeline

To add new links to a commerce pipeline you need to override the default definition for the appropriate commerce pipeline.  Commerce pipelines are defined in XML so you use ATG’s XML combining feature to accomplish this.

For example if you want to add a new link to the ProcessOrder chain in the /atg/commerce/commercepipeline.xml you would create the following commercepipeline.xml in your local config.

[xml]<pipelinemanager>
<pipelinechain name="processOrder" xml-combine="append">
<pipelinelink transaction="TX_MANDATORY" name="authorizePayment" xml-combine="replace">
<processor jndi="/atg/commerce/order/processor/AuthorizePayment" />
<transition returnvalue="1" link="updateInventory" />
</pipelinelink>
<pipelinelink name="updateInventory" transaction="TX_MANDATORY">
<processor jndi="/betweengo/commerce/inventory/processor/ProcUpdateInventory" />
<transition returnvalue="1" link="updateGiftRepository" />
</pipelinelink>
</pipelinemanager>[/xml]

In this example we added the new updateInventory link which is inserted between the authorizePayment and updateGiftRepository links.

Create Tablespaces in Oracle

Zero Table | Flickr

Zero Table by CommandZed

Previously I posted about how to import and create users in Oracle and in those examples I used the tablespaces provided by Oracle, users and temp.  But often you will want to create your own tablespace and use that one as the default tablespace for your users.

Here is an example of how to create a tablespace with the name foo of size 1 GB. Note that it is created in /Users/oracle/oradata/orcl which is the default folder for dataspaces on Mac OS X.

create tablespace
foo
datafile '/Users/oracle/oradata/orcl/foo.dbf'
size 1g;

Here is an example of how to create the same tablespace except now you are allowing it to grow bigger in 100 MB increments up to a maximum of 2 GB.  If you don’t specify the maximum it will grow unlimited.

create tablespace
foo
datafile '/Users/oracle/oradata/orcl/foo.dbf'
size 1g
autoextend on
next 100m
maxsize 2g;

If your tablespace is not big enough you can resize it using syntax like this.

alter database
datafile '/Users/oracle/oradata/orcl/foo.dbf'
resize 10g;

To see how big your tablespaces are you can use this query.

SELECT /* + RULE */  df.tablespace_name "Tablespace",
       df.bytes / (1024 * 1024) "Size (MB)",
       SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
       Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
       Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
  FROM dba_free_space fs,
       (SELECT tablespace_name,SUM(bytes) bytes
          FROM dba_data_files
         GROUP BY tablespace_name) df
 WHERE fs.tablespace_name (+)  = df.tablespace_name
 GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
       fs.bytes / (1024 * 1024),
       SUM(df.bytes_free) / (1024 * 1024),
       Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
       Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
  FROM dba_temp_files fs,
       (SELECT tablespace_name,bytes_free,bytes_used
          FROM v$temp_space_header
         GROUP BY tablespace_name,bytes_free,bytes_used) df
 WHERE fs.tablespace_name (+)  = df.tablespace_name
 GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
 ORDER BY 4 DESC;

Here is an example of how to drop a tablespace including its contents and datafiles.

drop tablespace foo including contents and datafiles

For further reading please see Oracle create tablespace & alter tablespace syntax, Tablespace – Oracle FAQ and How enlarge or decrease the size of an Oracle Tablespace.

SQL Delete in One Table Based on Values in Another Table

Growing | Flickr

Growing by Simon Peckham

Delete From One Table Whose Values Don’t Appear in Another Table

Sometimes you will find that you have items in a table whose values reference items in another table that no longer exist.  For example in ATG you may have orders that reference profiles that no longer exist.  This could happen if an order is for an anonymous profile that was deleted.

Here is an example of how to delete items in a table whose values reference items in another table that no longer exist, in this case ATG orders whose profiles no longer exist.

DELETE FROM dcspp_order
WHERE profile_id
NOT IN
(
  SELECT id
  FROM dps_user
);

This example does not actually work because of the dependencies on the dcspp_order table so please don’t try it. Smile

Delete From One Table Based on Values in Another Table

Sometimes you want to delete items in one tables based on values in another table.  You can do this similarly to the previous case.

DELETE FROM dcspp_order
WHERE profile_id
IN
(
  SELECT id
  FROM dps_user
  WHERE id LIKE '6%'
);

This example also does not actually work because of the dependencies on the dcspp_order table so please don’t try it. Smile

For further reading please see How to delete records from a SQL Server database and SQL Delete Rows Based on Another Table.

Specifying the Calculator per Promotion

calculator on Flickr

(Photo: calculator by ansik)

ATG’s documentation, as far as I can tell, does not document how to specify the calculator for a promotion.  Promotion’s have a repository property called pricingCalculatorService.  In the ACC you won’t see it by default but you will see it if you show expert-level information.  Also you can see it configured in the Promotion repository (/atg/commerce/pricing/Promotions).

Having a repository property for each promotion allows you to specify different calculators for different promotions.  But typically you will probably specify the same one for the same class of promotion, e.g. /betweengo/commerce/pricing/calculators/ItemDiscountCalculator.