Special thanks for my colleague Michel Schildmeijer for inspiring me to make this flexible script and off course for the necessary WLST code.
Important to know.
- Run this script on the AdminServer, else it won't find the Resource Adapter Plans
- First you need to create a Plan for the 3 Resource Adapters (Db,Aq,Jms) and add a dummy entry, think how you name it and where you put it.
- When a plan is changed and you have a soa cluster or the soa weblogic instance is running on a different server then you need to copy the plan to all servers or put it on a shared storage.
If you don't like this then you can always create new Resource Adapters by following this blogpost.
Let's explain how it works
first you need to change some variables in this build.properties
default this scripts runs against the weblogic dev settings. You can change this to your own and configure the dev entries ( dev entries at the bottom of the build.properties )
wls.environment=dev
Where are the adapter rars located in your FMW domain, this can be in your SOA or OSB Home of the FMW domain.
connectorLocation=C:/oracle/MiddlewarePS3/Oracle_SOA1/soa/connectors/
Then add your own EIS entries, these ones in this var will be added to weblogic.
resourceAdapterEntries=hrDB,hrAQ,cf1JMS,cf2JMS
Think if you need to set the XA or Not XA datasource property or in Jms the connectionFactoryLocation.
# AQ entry
hrAQ.type=aq
hrAQ.eisName=eis/AQ/hr2
hrAQ.property=xADataSourceName
hrAQ.value=jdbc/hrDS
# DB entry
hrDB.type=db
hrDB.eisName=eis/DB/hr2
hrDB.property=dataSourceName
hrDB.value=jdbc/hrDS
# JMS entries
cf1JMS.type=jms
cf1JMS.eisName=eis/JMS/hr3
cf1JMS.property=ConnectionFactoryLocation
cf1JMS.value=jms/MyCF
After you can run the ANT script
ant -f build.xml createResourceAdapterEntries
Here you can download the code on github
Here is the whole build.properties file
The wlst part with the wlRedeployResourceAdapter and wlCreateResourceAdapter macrodefs
And at last the build.xml
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi,
DeleteI don't think you got this soaps3 connection on your side
[wlst] Connecting to t3://soaps3:7001 with userid weblogic ...
thanks
This comment has been removed by the author.
Deletehi,
DeleteI think you are some ant libs jars or the ant contrib jar. put them in your ant lib or classpath.
thanks
Hi Biemond,
DeleteCould not load definitions from resource org/apach
e/tools/ant/antlib.xml. It could not be found.
where can find this lib iam unable to locate it...
It is located at the lib folder on github and loaded in the bat file.
Deletethanks
Hi Edwin,
DeleteIam able to execute the build successfully but the changes are not reflected on weblogic server, dont know where the problem is here pasting the log....
Hi,
Deleteyou must upgrade ANT and check your classpath and put contrib jar in the ant lib folder.
thanks
This comment has been removed by the author.
DeleteHi, Edwin,
ReplyDeleteThanks for share your code in GitHub, save me lots of time.
1. I did little change for my env. It's not problem in my Linux with using PlanPath, but don't know why it's not working in my Windows. just return Plan.xml without path.
planPath = get('/AppDeployments/'+appName+'/AbsolutePlanPath')
2. The destroy exist Variable/assignment function is not working in makeDeploymentPlanVariable, because you introduce idRandom on the name param. Either change this idRandom to FIXED string/number, or using find() to filter the exist Variable then destroy that. Otherwise always create new Avariable with the same eisName.
thanks
Thanks for your input.
DeleteI tested it on windows without any problem.
Thanks
This comment has been removed by the author.
ReplyDeleteScript ran SUCCESSFUL. But there is no new resource in DbAdapter(DbAdapter->Configuration->Outbound Connection Pools)(((
ReplyDeleteLog:
-----------------------------
createResourceAdapter:
[echo] Create Resource
[echo] eisName eis/DB/hr
[wlst] Connecting to t3://localhost:7001 with userid weblogic ...
[wlst] Successfully connected to Admin Server 'AdminServer' that belongs to domain 'toyota_domain_2'.
[wlst]
[wlst] Warning: An insecure protocol was used to connect to the
[wlst] server. To ensure on-the-wire security, the SSL port or
[wlst] Admin port should be used instead.
[wlst] Location changed to edit tree. This is a writable tree with
[wlst] DomainMBean as the root. To make changes you will need to start
[wlst] an edit session via startEdit().
[wlst]
[wlst] For more help, use help(edit)
[wlst] Starting an edit session ...
[wlst] Started edit session, please be sure to save and activate your
[wlst] changes once you are done.
[wlst] __ Using plan_2 C:\bea1031\osb_10.3\lib\transports\Plan.xml
[wlst] Loading application from C:/BEA1031/wlserver_10.3/osb_10.3/lib/transports/jca/DbAdapter.rar ...
[wlst] Edit session has been stopped successfully.
[echo] check for adapter changes and redeploy
[echo] found db
[echo] found for DbAdapter DbAdapter
[echo] redeploy DbAdapter
[wlst] Connecting to t3://localhost:7001 with userid weblogic ...
[wlst] Successfully connected to Admin Server 'AdminServer' that belongs to domain 'toyota_domain_2'.
[wlst]
[wlst] Warning: An insecure protocol was used to connect to the
[wlst] server. To ensure on-the-wire security, the SSL port or
[wlst] Admin port should be used instead.
[wlst] Location changed to edit tree. This is a writable tree with
[wlst] DomainMBean as the root. To make changes you will need to start
[wlst] an edit session via startEdit().
[wlst]
[wlst] For more help, use help(edit)
[wlst] Starting an edit session ...
[wlst] Started edit session, please be sure to save and activate your
[wlst] changes once you are done.
[wlst] Edit session has been stopped successfully.
BUILD SUCCESSFUL
Total time: 12 seconds
<10.08.2012 14:47:05 MSD>
------------------------------
Hi,
Deletedoes the plan C:\bea1031\osb_10.3\lib\transports\Plan.xml not have any new entry and what are your ant property settings
thanks
This comment has been removed by the author.
DeleteEdwin Biemond, thanks!!!
DeleteI made error in build.properties file: have written incorrect connectorLocation(
C:\Users\vxvm\Desktop\biemondosb\soa_tools-master\ant_resourceAdapter>ant create
ReplyDeleteResourceAdapter
Buildfile: build.xml
createResourceAdapter:
BUILD FAILED
C:\Users\vxvm\Desktop\biemondosb\soa_tools-master\ant_resourceAdapter\build.xml:
129: Property '${resourceAdapterEntry}.type' is not defined.
Hi,
DeleteDid you add your Resource Adapter values to the build.properties
like this
resourceAdapterEntries=hrDB,hrDB2,hrAQ,hrAQ2,cf1JMS,cf2JMS
and add the right types to hrAQ entries etc
hrAQ.type=aq
and run this on the adminserver
thanks
Hi Edwin Biemond
ReplyDeleteCan you please help out in resolving the above issue,Thanks!
Hi,
Deletedid you add the ant contrib jar to your classpath or add this to the ant lib folder.
thanks
Yes Edwin Biemond
DeleteI added in my classpath and as well as in ant lib folder.
Please find below classpath:
C:\Users\vxvm\oracleosb\Middleware\wlserver_10.3\server\lib\weblogic.jar;C:\Users\vxvm\oracleosb\Middleware\Oracle_OSB1\lib\alsb.jar;C:\Users\vxvm\oracleosb\Middleware\Oracle_OSB1\modules\com.bea.common.configfwk_1.6.0.0.jar;C:\Users\vxvm\oracleosb\Middleware\Oracle_OSB1\lib\sb-kernel-impl.jar;C:\Users\vxvm\oracleosb\Middleware\modules\org.apache.ant_1.7.1\lib\ant.jar;C:\Users\vxvm\oracleosb\Middleware\Oracle_OSB1\lib\sb-kernel-api.jar;C:\Users\vxvm\Desktop\biemondosb\soa_tools-master\ant\lib\ant-contrib-1.0b3.jar;
Thanks
Hi,
DeleteI did a fresh pull from github and everything is working fine.
can you check the following,
run the start.bat or change it to a sh script.
are you running this script on the osb server.
did you already create the resource adapter plans for aq,jms and db.
ant contrib is loaded in the build.xml ( from the lib folder )
path id="antcontrib.path"
pathelement path="lib/ant-contrib-1.0b3.jar"
/path
taskdef classpathref="antcontrib.path"
resource="net/sf/antcontrib/antlib.xml"
and does your connectorLocation=C:/oracle/MiddlewarePS5/Oracle_SOA1/soa/connectors/ exists
thanks
Hi
DeleteI'm running this on windows and i have osb server installed locally in my machine
and resource adapters JMS,DB,AQ connection factory is established but data source is not configured
Question:do I need to update antcontrib.path in the build.xml?
Also the connectorLocation exists and here is the path:connectorLocation=C:/Users/vxvm/oracleosb/Middleware/Oracle_OSB1/soa/connectors/
I'm running it from OSB domain
Also is there a way I can send my artifacts as an attachment?
Please clarify, Thanks!
Hi,
DeleteI think it is an ant contrib problem, that supports the property copy and the foreach
you can send it to biemond at gmail dot com
thanks
Hi Edwin,
ReplyDeleteI wrote the scripts based on your code. I put all python scripts in createAdapter.py and created target in build.xml to call this py script. After sucessfully run the script, the new resources is not showing in DbAdapter(DbAdapter->Configuration->Outbound Connection Pools). But new configuration is in DBplan.xml. After i run "updates" DbAdaper, I can see the new resources. looks like redeploy part is not picking up the new configuration from DBPlan.xml. below is my redeploy part code
def redeployResourceAdapter(appName):
planPath = get('/AppDeployments/'+appName+'/AbsolutePlanPath')
print '__ redeployResourceAdapter '+appName+' Using plan ' + planPath+ ' ___'
cd('/AppDeployments/'+appName+'/Targets');
redeploy(appName, planPath,targets=cmo.getTargets());
#updateApplication(appName, planPath)
cd('/')
and log after create adapter resources
[wlst] ___ DONE change plan ___
[wlst]
[wlst] ++++++++++++++++++++++++++++++++++++++++++++++++++
[wlst] Saving all your changes ...
[wlst] Saved all your changes successfully.
[wlst] Activating all your changes, this may take a while ...
[wlst] The edit lock associated with this edit session is released
[wlst] once the activation is completed.
[wlst] Activation completed
[wlst] --------------------------------------------------
[wlst] __ redeployResourceAdapter DbAdapter Using plan /oracle/Middleware/Oracle_SOA1/soa/connectors/plan/DBPlan.xml ___
[wlst] Redeploying application DbAdapter ...
[wlst]
[wlst] .Completed the redeployment of Application with status completed
[wlst] Current Status of your Deployment:
[wlst] Deployment command type: redeploy
[wlst] Deployment State : completed
[wlst] Deployment Message : no message
[wlst] Disconnected from weblogic server: AdminServer
[wlst] job finished successfully
[wlst]
BUILD SUCCESSFUL
Total time: 14 seconds
please help,
Kevin
Hi,
DeleteIt should works but maybe somehow it can't find the plan Path in your script for the redeployment.
thanks
Hi,
ReplyDeleteThanks for your reply. was thinking about that, but you can see in the log
[wlst] __ redeployResourceAdapter DbAdapter Using plan /oracle/Middleware/Oracle_SOA1/soa/connectors/plan/DBPlan.xml ___
that's correct path.
cheers
kevin
Hi Edwin.
ReplyDeleteThanks for this great post.
They were most helpful in creating our custom script.
Could you please share information on how we can edit or delete entries through the script.
Hi,
DeleteYou can better delete them (manually) and recreate them with this script. But deleting from WLST can't be that hard .
thanks.
instead redeploy(appName, planPath,targets=cmo.getTargets()); can we use update(appName, planPath,targets=cmo.getsTargets()); ?? after config if i dont want to redeploy the adapter and only want to update it ??
ReplyDeleteWill update works ?
Hi,
DeleteI think update should also work, I did not try it but from the weblogic console you can also do a update and this also works.
Thanks
Hi Edwin
Deletethis article really helped me a lot, I've trouble in creating multiple properties on an adapter.
I'm trying to configure MQAdapter jca, as per your createresourceadaptor, takes only one param property.
Can you give me some example please.
Thanks
Andy
Hi,
Deletenever tried this but can you call this method again with your second param.
makeDeploymentPlanVariable(myPlan, configProperty, cfName
thanks
Hi Biemond,
ReplyDeleteThanks that was useful post. Does this work for remote server even ? . It works good with localserver but when i am trying it with remote server it throwing the following error at the line where loadApplication line exists
Traceback (innermost last):
File "", line 1, in ?
File "", line 290, in loadApplication
Use dumpStack() to view the full stacktrace
at weblogic.management.scripting.ExceptionHandler.handleException(ExceptionHandler.java:59)
at weblogic.management.scripting.WLSTUtils.throwWLSTException(WLSTUtils.java:181)
at weblogic.management.scripting.JSR88DeployHandler.loadApplication(JSR88DeployHandler.java:196)
at weblogic.management.scripting.WLScriptContext.loadApplication(WLScriptContext.java:787)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
weblogic.management.scripting.ScriptException: weblogic.management.scripting.ScriptException: Error occured while performing loadApplication : Could not read confi
guration. : Exception in AppMerge flows' progression
Hi,
Deleteit doesn't , it searches for a local file ( the deployment plan on the server ) , probably only works in this situation when you have a shared storage ( NFS share )
thanks
how can i assign controlDir to some shared location in eis/HAFileAdapter ? i went to this path in console Deployments->File Adapter->Configuration->Outbound Connection Pools->javax.resource.cci.ConnectionFactory->eisHAFileAdapter->controlDir but i couldn't understand what should i have to do for assign controlDir to some shared location.
ReplyDeleteHi,
Deletestart an edit session , just click on the value , add your location, press enter and save
Hi Biemond,
ReplyDeletewe've created a custom jca resource adapter and deployed in oracle weblogic server.
we are using this adapter in soa 11g composite and everything is working fine.
The problem is we can't able to handle the business exception thrown from the adapter.
we need to know how to throw soap fault from resource adapter so that we can handle the exception at mediator of soa 11g..
we tried throwing as resourceException but at SOA level we are receiving it as runtime exception.
please do help us..
Thanks,
Godwin