Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PHP oci_connect ORA-12569 Checksum failure

JaminVPOct 28 2015 — edited Nov 10 2015

Greetings,

I'm using Nginx as a reverse proxy to authenticate a service (Elasticsearch and Kibana). I'm using a module that can proxy the authentication to a PHP-script, allowing for custom authentication.

While connecting to a remote Oracle database, I encountered the following error:

[27-Oct-2015 09:14:41 Europe/Brussels] PHP Warning:  oci_connect(): ORA-12569: TNS:packet checksum failure in D:\ontw\tools\ELK-new\nginx-1.9.5\auth\authentication.php on line 7.

I'm using php-cgi.exe as a bound service to my localhost on port 9100. This allows me to proxy the authentication requests to the required script.

What could be the cause of this error? I'm pretty sure my connection string is correct as a different hostname results in a "database not found"-error and a different port results in a "listener not found"-error.

Based on Google search results I'm inclined to believe that somewhere along the route between me and the remote database, one of the tcp-headers gets changed, resulting in the conflicting checksum.

However, connecting to the remote database through a JAVA web application with the same connection string goes smoothly.

This makes me wonder, what could be the cause of this abnormality and how can this be resolved?

Kind regards,

JaminVP

PS: Some more details:

- OS: Windows Server 2008 R2 Enterprise

- PHP Version 5.4.35

- Oracle Instant Client version 12.1.0.2.0 32-bit

- Path includes the Oracle Instant Client directory

- Oracle environment variables are not set as suggested by the PHP Oracle Underground Manual

UPDATE: I tried the PDO interface, but I get the same error. It's strange that I can access the database through a a webbapplication hosted by tomcat apache if the database is added as a resource. You'd expect the same to work in PHP, but nope.
.

Comments

664685
Hi,

One can use offline WLST scripts for automated deployment. The script (python scripts) can be invoked using Ant. In summary, the steps are:

1. Copy the relevant files in a folder (preferably <DOMAIN_HOME>). The files are
a. import.py: The actual python script that does the deployment process
b. import.properties: A properties file used by the import script. It contains information about the deployment jar file (sbconfig.jar), any customization file, host and port information of the OSB server and credential information
c. sbconfig.jar(Or any other name): OSB deployable artifacts bundled using the editor or exported from another OSB environment
d. build.xml: Defines the import task executed by ant
e. OSB customization xml file

2. Open a command prompt (Windows environment), navigate to <DOMAIN_HOME>/bin and execute setDomainenv.bat

3. Additionally add the follwing jar files to the classpath. These files are used by the APIs used in the python script. These were not needed prior to the 3.0 version of OSB (ALSB). The files are: +<BEA_HOME>/modules/com.bea.common.configfwk_1.1.0.0.jar+ and +<OSB_HOME>/lib/sb-kernel-api.jar+

4. Using the same command prompt, navigate to the folder where the files in step 1 had been placed and exeute the import task using ant (something like ant import)

Plese find a sample of the import.py, build.xml and import.properties files as follows:

*================= import.py =============================*
from java.util import HashMap
from java.util import HashSet
from java.util import Map
from java.util import Set
from java.util.Map import Entry
from java.util import ArrayList
from java.util import Hashtable
from java.lang import System
from java.io import FileInputStream

from weblogic.management.mbeanservers.domainruntime import DomainRuntimeServiceMBean
from javax.management.remote import JMXConnector
from weblogic.management.jmx import MBeanServerInvocationHandler
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.config.customization import Customization
from javax.management import ObjectName;
from com.bea.wli.config.resource import Diagnostics
from javax.management.remote import JMXConnectorFactory
from javax.management.remote import JMXServiceURL
from javax.naming import Context
from com.bea.wli.config import Ref
from com.bea.wli.sb.management.importexport import ALSBImportPlan
from com.bea.wli.sb.management.importexport import ALSBImportOperation

import sys


#=======================================================================================
# Entry function to deploy project configuration and resources
# into a OSB domain
#=======================================================================================

def importToALSBDomain(importConfigFile):
try:
print 'Loading Deployment config from :', importConfigFile
exportConfigProp = loadProps(importConfigFile)

host = exportConfigProp.get("host")
port = exportConfigProp.get("port")
intPort = int(port)
print "Connecting to: " + host + ":" + port
importUser = exportConfigProp.get("importUser")
importPassword = exportConfigProp.get("importPassword")

importJar = exportConfigProp.get("importJar")
customFile = exportConfigProp.get("customizationFile")

# passphrase = exportConfigProp.get("passphrase")
# project = exportConfigProp.get("project")

print "Initiate Connection"
conn = initConnection(host, intPort, importUser, importPassword)
print "Connection successful"

mbconn = conn.getMBeanServerConnection()
obname = DomainRuntimeServiceMBean.OBJECT_NAME
domainService = MBeanServerInvocationHandler.newProxyInstance(mbconn, ObjectName(obname))
name = SessionManagementMBean.NAME
type = SessionManagementMBean.TYPE
sm = domainService.findService(name, type, None)

bytes = readBinaryFile(importJar)


sessionName = "ScriptImport"

print "sessionName: ", sessionName

sm.createSession(sessionName)
alsbSession = domainService.findService(ALSBConfigurationMBean.NAME + "." + sessionName, ALSBConfigurationMBean.TYPE, None)

alsbSession.uploadJarFile(bytes)
jarInfo = alsbSession.getImportJarInfo()
importPlan = jarInfo.getDefaultImportPlan()
result = alsbSession.importUploaded(importPlan);

# list of created references
createdRef = ArrayList()

operationMap = importPlan.getOperations()
set = operationMap.entrySet()
for entry in set:
ref = entry.getKey()
createdRef.add(ref)

# Print out status and build a list of created references. Will be used for customization
if result.getImported().size() > 0:
print "The following resources have been imported: "
for successEntry in result.getImported():
print successEntry.toString()

# Check for error and discard session in any resource fails
failCount = result.getFailed().size()
if failCount > 0:
print ""
print "Failed for: " + failCount + " resources"
# print "The following resources failed to import"
# for entry in result.getFailed().entrySet():
# ref = entry.getKey()
# diagnostics = entry.getValue().toString()
# print ref + " Reason: " + diagnostics
# abort = true
# raise


#=================================================
# Apply Customizations
#=================================================
#customize if a customization file is specified
#affects only the created resources
if customFile != None :
print "Loading customization File: " + customFile
print "Customization applied to the created resources only" + createdRef.toString()
iStream = FileInputStream(customFile)
customizationList = Customization.fromXML(iStream)
filteredCustomizationList = ArrayList()
setRef = HashSet(createdRef)

# apply a filter to all the customizations to narrow the target to the created resources
for customization in customizationList:
newcustomization = customization.clone(setRef)
filteredCustomizationList.add(newcustomization)

alsbSession.customize(filteredCustomizationList)

#=========================
# Activate Session
#=========================
sm.activateSession(sessionName, "Imported Configuration")
print "Project imported"

conn.close()
except:
print "Unexpected error:", sys.exc_info()[0]
print "Discarding the session."
sm.discardSession(sessionName)
conn.close()
raise



#==================================================
# Utility function for initiating connection
#================================================
def initConnection(hostname, port, username, password):
serviceURL = JMXServiceURL("t3", hostname, port,"/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME)
h=Hashtable()
h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote")
return JMXConnectorFactory.connect(serviceURL, h)



#=======================================================================================
# Utility function to print the list of operations
#=======================================================================================
def printOpMap(map):
set = map.entrySet()
for entry in set:
op = entry.getValue()
print op.getOperation(),
ref = entry.getKey()
print ref
print

#=======================================================================================
# Utility function to print the diagnostics
#=======================================================================================
def printDiagMap(map):
set = map.entrySet()
for entry in set:
diag = entry.getValue().toString()
print diag
print

#=======================================================================================
# Utility function to load properties from a config file
#=======================================================================================

def loadProps(configPropFile):
propInputStream = FileInputStream(configPropFile)
configProps = Properties()
configProps.load(propInputStream)
return configProps

#=======================================================================================
# Connect to the Admin Server
#=======================================================================================

def connectToServer(username, password, url):
connect(username, password, url)
domainRuntime()

#=======================================================================================
# Utility function to read a binary file
#=======================================================================================
def readBinaryFile(fileName):
file = open(fileName, 'rb')
bytes = file.read()
return bytes

#=======================================================================================
# Utility function to create an arbitrary session name
#=======================================================================================
def createSessionName():
sessionName = String("SessionScript"+Long(System.currentTimeMillis()).toString())
return sessionName

#=======================================================================================
# Utility function to load a session MBeans
#=======================================================================================
def getSessionMBean(sessionName):
SessionMBean = findService("Session","com.bea.wli.config.mbeans.SessionMBean")
SessionMBean.createSession(sessionName)
return SessionMBean



# IMPORT script init
try:
# import the service bus configuration
# argv[1] is the export config properties file
importToALSBDomain(sys.argv[1])

except:
print "Unexpected error: ", sys.exc_info()[0]
dumpStack()
raise
*=================================================================*


*================ import.properties ======================================*

##################################################################
# OSB Admin Security Configuration #
##################################################################
host=localhost
port=7001
importUser=weblogic
importPassword=weblogic

##################################################################
# OSB Jar to be exported, optional customization file #
##################################################################
importJar=ALSBSampleProject.jar

##########################################################
#Use the following if you have any customization xml file#
##########################################################
#customizationFile=ALSBSampleProject_Customization.xml

##################################################################
# Optional passphrase and project name #
##################################################################
#passphrase=
#project=

*===================================================================*

*============================== build.xml===============================*
<project default="import">
<property name="domain.import.script" value="import.py"/>
<property name="import.config.file" value="import.properties"/>
<target name="import">
<echo message="Importing configuration"/>
<echo message="importscript: ${domain.import.script}"/>
<java classname="weblogic.WLST" fork="true">
<arg line="${domain.import.script} ${import.config.file}"/>
</java>
</target>
</project>
*=====================================================================*

Hope this helps

Thanks & Regards,
Vivek
776630
Hi Vivek,

This is really very very useful information. Thank you for sharing your work with Oracle Forum. This will enable everyone who is using OSB to develop automated build scirpts for deployment.

Your help is highly appreciated. I will try the steps provided and update here if any change is required.

Cheers,
Sakthi
595538
Hi All,

I am successfully able to import the configuration using the import.py option.But the End point URIs are not getting changed for all the Business services.

My import script

from java.util import HashMap
from java.util import HashSet
from java.util import ArrayList
from java.io import FileInputStream

from com.bea.wli.sb.util import Refs
from com.bea.wli.config.customization import Customization
from com.bea.wli.sb.management.importexport import ALSBImportOperation

import sys

#=======================================================================================
# Entry function to deploy project configuration and resources
# into a ALSB domain
#=======================================================================================

def importToALSBDomain(importConfigFile):
try:
SessionMBean = None
print 'Loading Deployment config from :', importConfigFile
exportConfigProp = loadProps(importConfigFile)
adminUrl = exportConfigProp.get("adminUrl")
importUser = exportConfigProp.get("importUser")
importPassword = exportConfigProp.get("importPassword")

importJar = exportConfigProp.get("importJar")
customFile = exportConfigProp.get("customizationFile")

passphrase = exportConfigProp.get("passphrase")
project = exportConfigProp.get("project")

connectToServer(importUser, importPassword, adminUrl)

print 'Attempting to import :', importJar, "on ALSB Admin Server listening on :", adminUrl

theBytes = readBinaryFile(importJar)
print 'Read file', importJar
sessionName = createSessionName()
print 'Created session', sessionName
SessionMBean = getSessionManagementMBean(sessionName)
print 'SessionMBean started session'
ALSBConfigurationMBean = findService(String("ALSBConfiguration.").concat(sessionName), "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
print "ALSBConfiguration MBean found", ALSBConfigurationMBean
ALSBConfigurationMBean.uploadJarFile(theBytes)
print 'Jar Uploaded'

if project == None:
print 'No project specified, additive deployment performed'
alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
alsbImportPlan.setPassphrase(passphrase)
alsbImportPlan.setPreserveExistingEnvValues(true)
importResult = ALSBConfigurationMBean.importUploaded(alsbImportPlan)
SessionMBean.activateSession(sessionName, "Complete test import with customization using wlst")
else:
print 'ALSB project', project, 'will get overlaid'
alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
alsbImportPlan.setPassphrase(passphrase)
operationMap=HashMap()
operationMap = alsbImportPlan.getOperations()
print
print 'Default importPlan'
printOpMap(operationMap)
set = operationMap.entrySet()

alsbImportPlan.setPreserveExistingEnvValues(true)

#boolean
abort = false
#list of created ref
createdRef = ArrayList()

for entry in set:
ref = entry.getKey()
op = entry.getValue()
#set different logic based on the resource type
type = ref.getTypeId
if type == Refs.SERVICE_ACCOUNT_TYPE or type == Refs.SERVICE_PROVIDER_TYPE:
if op.getOperation() == ALSBImportOperation.Operation.Create:
print 'Unable to import a service account or a service provider on a target system', ref
abort = true
elif op.getOperation() == ALSBImportOperation.Operation.Create:
#keep the list of created resources
createdRef.add(ref)

if abort == true :
print 'This jar must be imported manually to resolve the service account and service provider dependencies'
SessionMBean.discardSession(sessionName)
raise

print
print 'Modified importPlan'
printOpMap(operationMap)
importResult = ALSBConfigurationMBean.importUploaded(alsbImportPlan)

printDiagMap(importResult.getImportDiagnostics())

if importResult.getFailed().isEmpty() == false:
print 'One or more resources could not be imported properly'
raise

#customize if a customization file is specified
#affects only the created resources
if customFile != None :
print 'Loading customization File', customFile
print 'Customization applied to the created resources only', createdRef.toString()
iStream = FileInputStream(customFile)
customizationList = Customization.fromXML(iStream)
filteredCustomizationList = ArrayList()
setRef = HashSet(createdRef)

# apply a filter to all the customizations to narrow the target to the created resources
for customization in customizationList:
print customization
newcustomization = customization.clone(setRef)
filteredCustomizationList.add(newcustomization)

ALSBConfigurationMBean.customize(filteredCustomizationList)

SessionMBean.activateSession(sessionName, "Complete test import with customization using wlst")

print "Deployment of : " + importJar + " successful"
except:
print "Unexpected error:", sys.exc_info()[0]
if SessionMBean != None:
SessionMBean.discardSession(sessionName)
raise

#=======================================================================================
# Utility function to print the list of operations
#=======================================================================================
def printOpMap(map):
set = map.entrySet()
for entry in set:
op = entry.getValue()
print op.getOperation(),
ref = entry.getKey()
print ref
print

#=======================================================================================
# Utility function to print the diagnostics
#=======================================================================================
def printDiagMap(map):
set = map.entrySet()
for entry in set:
diag = entry.getValue().toString()
print diag
print

#=======================================================================================
# Utility function to load properties from a config file
#=======================================================================================

def loadProps(configPropFile):
propInputStream = FileInputStream(configPropFile)
configProps = Properties()
configProps.load(propInputStream)
return configProps

#=======================================================================================
# Connect to the Admin Server
#=======================================================================================

def connectToServer(username, password, url):
connect(username, password, url)
domainRuntime()

#=======================================================================================
# Utility function to read a binary file
#=======================================================================================
def readBinaryFile(fileName):
file = open(fileName, 'rb')
bytes = file.read()
return bytes

#=======================================================================================
# Utility function to create an arbitrary session name
#=======================================================================================
def createSessionName():
sessionName = String("SessionScript"+Long(System.currentTimeMillis()).toString())
return sessionName

#=======================================================================================
# Utility function to load a session MBeans
#=======================================================================================
def getSessionManagementMBean(sessionName):
SessionMBean = findService("SessionManagement", "com.bea.wli.sb.management.configuration.SessionManagementMBean")
SessionMBean.createSession(sessionName)
return SessionMBean



# IMPORT script init
try:
# import the service bus configuration
# argv[1] is the export config properties file
importToALSBDomain(sys.argv[1])

except:
print "Unexpected error: ", sys.exc_info()[0]
dumpStack()
raise




Can someone help.

Regards
Lalit
746573
Obviously OSB is not able to change all properties of a business service, like the endpoint uri, when upgrading with a new import or when customizing with the customization shown above. What we had to do, is to remove the business service first, import the new one and then re-customize it from scratch, all in one change session :-(

Edited by: user11105257 on 03.09.2010 07:26

Edited by: user11105257 on 03.09.2010 10:25
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 8 2015
Added on Oct 28 2015
3 comments
3,573 views