Showing posts with label Listener. Show all posts
Showing posts with label Listener. Show all posts

Friday, 6 January 2017

Oracle Database Connectivity Issue | ORA-17002 IO Error : Socket read timed out

While connecting oracle database with SQL Developer got below error.

ORA-17002 IO Error: Socket read timed out


After analysis found that listener was down. Here are steps to analyze and fix this.

1. Go to ORACLE_HOME/bin and check listener status using lsnrctl status command. It will show below message.
=======================================================================
[root@dev bin]# ./lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 06-JAN-2017 18:42:11

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused


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

2. Now start the listener using lsnrctl start command.

=======================================================================
 [oracle@dev bin]$ ./lsnrctl start

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 06-JAN-2017 18:55:16

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Starting /app/oracle/product/12.1.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.1.0.2.0 - Production
System parameter file is /app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Log messages written to /app/oracle/diag/tnslsnr/dev/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                 TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date             06-JAN-2017 18:55:18
Uptime                  0 days 0 hr. 0 min. 0 sec
Trace Level           off
Security                ON: Local OS Authentication
SNMP                   OFF
Listener Parameter File   /app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File         /app/oracle/diag/tnslsnr/dev/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully


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

3. Now you can confirm listener status again using lsnrctl status command.

=======================================================================
 [oracle@dev bin]$ ./lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 06-JAN-2017 18:55:42

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                 TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date             06-JAN-2017 18:55:18
Uptime                  0 days 0 hr. 0 min. 24 sec
Trace Level          off
Security               ON: Local OS Authentication
SNMP                  OFF
Listener Parameter File   /app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File         /app/oracle/diag/tnslsnr/dev/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost)(PORT=5500))(Security=(my_wallet_directory=/app/oracle/product/12.1.0/dbhome_1/admin/dev/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "localhost" has 1 instance(s).
  Instance "dev", status READY, has 1 handler(s) for this service...
Service "devXDB.dev.local" has 1 instance(s).
  Instance "dev", status READY, has 1 handler(s) for this service...
The command completed successfully


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

Note : To perform this activity you should login as non root user.

Sunday, 11 January 2015

Customizing DeploymentEventListener

To confgiure a customized DeploymentEventListener, Here are the steps.
  1. Define a listener service class that implements the interface DeploymentEventListener and implement the method deploymentEvent(DeploymentEvent pEvent).
  2. Configure an instance in Nucleus on the appropriate server and register it with the DeploymentServer or DeploymentAgent as appropriate.
  • Configure the listener on the asset management server (BCC) and register it with the /atg/epub/DeploymentServer, so it listens for deployment events fired when the deployment changes its state.
  • Configure the listener on the target (production/stagging) server and register it with the local /atg/epub/DeploymentAgent, so it listens for deployment events fired when an agent changes its state.
Here is sample code to print the assets changed/modified in BCC project. Along with configuration. You can customize code as per your need.

Note : Custom is the custom module created for this customization.

1.   Custom listener class.
Path : /Custom/src/com/test/service/CustomDeploymentEventListener.java
File Content : 


package com.test.service;

import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.ejb.EJBException;
import javax.ejb.FinderException;

import atg.deployment.common.event.DeploymentEvent;
import atg.deployment.common.event.DeploymentEventListener;
import atg.epub.project.Project;
import atg.epub.project.ProjectConstants;
import atg.epub.project.ProjectHome;
import atg.nucleus.GenericService;
import atg.repository.RepositoryException;
import atg.repository.RepositoryItem;
import atg.versionmanager.AssetVersion;
import atg.versionmanager.exceptions.VersionException;

public class CustomDeploymentEventListener extends GenericService implements DeploymentEventListener {
/**
* boolean to denote whether to listen the event or ignore it
*/
private boolean enabled;
@SuppressWarnings("unchecked")
@Override
public void deploymentEvent(DeploymentEvent pDeploymentevent) {
vlogDebug("Enter deploymentEvent method of CustomDeploymentEventListener");
if (isEnabled() && pDeploymentevent != null &&
                 DeploymentEvent.DEPLOYMENT_COMPLETE == pDeploymentevent.getNewState()) {

 String[] projectIds = pDeploymentevent.getDeploymentProjectIDs();
 Project project = null;
 Set workSpaceAssets = null;
 Set<RepositoryItem> repositoryItemsUpdated = new LinkedHashSet<RepositoryItem>();
 Iterator<AssetVersion> workspaceAssetsIterator = null;
 RepositoryItem repositoryItem = null;
 try {
    if (projectIds != null && projectIds.length >= 1) {
   ProjectHome home = ProjectConstants.getPersistentHomes().getProjectHome();
   try {
project = home.findById(projectIds[0]);
   } catch (EJBException ejbException) {
if (isLoggingError()) {
logError("Cannot find project with Id " + projectIds[0], ejbException);
}
   } catch (FinderException finderException) {
if (isLoggingError()) {
       logError("Cannot find project with Id " 
                                                    + projectIds[0], finderException);
}
   }
}
if (project != null) {
workSpaceAssets = project.getAssets();
}
if (workSpaceAssets != null) {
 workspaceAssetsIterator = (Iterator<AssetVersion>) workSpaceAssets.iterator();
}
if (workspaceAssetsIterator != null) {
while (workspaceAssetsIterator.hasNext()) {
AssetVersion assetVersion = workspaceAssetsIterator.next();
try {
if (assetVersion != null) {
repositoryItem = assetVersion.getRepositoryItem();                        repositoryItemsUpdated.add(repositoryItem);
}
} catch (RepositoryException repoExc) {
      vlogError("Repository Exception while accessing item " 
                                                                   + repositoryItem, repoExc);
}
}
}

if (!repositoryItemsUpdated.isEmpty()) {
//print updated items
printUpdatedItems(repositoryItemsUpdated);
}
} catch (VersionException versionExc) {
vlogError("Version exception occured while processing deployed project"
                                                               , versionExc);
}
 }
vlogDebug("Exit deploymentEvent method of CustomDeploymentEventListener");
         }
/**
* Method to print updated repository items
* @param repositoryItems
*/
private void printUpdatedItems(Set<RepositoryItem> repositoryItems) {
vlogDebug("Start :: printUpdatedItems(Set<RepositoryItem>)");
for (RepositoryItem repositoryItem : repositoryItems) {
System.out.println("Updated item is "+repositoryItem);
}
vlogDebug("End :: printUpdatedItems(Set<RepositoryItem>)");
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}

2.   Custom listener component.
Path : /Custom/config/com/test/service/listener/CustomDeploymentEventListener.properties
File Content :
       $class=com.test.service.CustomDeploymentEventListener
       enabled=true

3.   Deployment agent configuration (For agent instances).
Path : /Custom/config/atg/epub/DeploymentAgent.properties
File Content :
      deploymentEventListeners+=/com/test/service/listener/CustomDeploymentEventListener

4.   Deployment server configuration (For BCC instance).
Path : /Custom/config/atg/epub/DeploymentServer.properties
File Content :
       deploymentEventListeners+=/com/test/service/listener/CustomDeploymentEventListener