Dopo aver affrontato, anche da un punto di vista teorico, alcuni aspetti inerenti l'integrazione tecnologica e funzionale dei moduli Java EE sugli ambienti server, in questo secondo articolo affrontiamo la creazione di un server standalone. Si tratta di approntare un ambiente server WebSphere nella sua configurazione più semplice.
Creare un ambiente server
Vediamo ora come creare un ambiente server WebSphere nella sua configurazione più semplice: un application server standalone, che nel provisioning form si posiziona come ambiente di pre-integrazione o di integrazione a livello di unità di distribuzione. Attraverso il Profile Management Tool andremo a creare un profilo WebSphere di questo tipo. Questo verrà creato sul file system al percorso /opt/IBM/WebSphere/AppServer/profiles/<NOME_PROFILO> (nel nostro caso "AppSrvStdAlone").
Figura 1 - Selezione del profilo.
Il wizard propone l'assegnazione delle porte:
Figura 2 - Assegnazione delle porte.
Al termine, dopo aver lanciato il comando di verifica dell'installazione, otterremo:
Server name is:server1
Profile name is:AppSrvStdAlone
Profile home is:/opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone
Profile type is:default
Cell name is:<SERVER>Node01Cell
Node name is:<SERVER>NodeStdAlone
Current encoding is:UTF-8
Server port number is:9082
IVTL0020I: The Installation Verification Tool cannot connect to WebSphere Application Server; waiting for the server to start.
IVTL0010I: Connecting to the WebSphere Application Server <SERVER> on port: 9082
IVTL0020I: The Installation Verification Tool cannot connect to WebSphere Application Server; waiting for the server to start.
Start running the following command:/opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/bin/startServer.sh server1 -profileName AppSrvStdAlone
>ADMU0116I: Tool information is being logged in file
> /opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/logs/server1/startServer.log
>ADMU0128I: Starting tool with the AppSrvStdAlone profile
>ADMU3100I: Reading configuration for server: server1
>ADMU3200I: Server launched. Waiting for initialization status.
>ADMU3000I: Server server1 open for e-business; process id is 11698
IVTL0015I: WebSphere Application Server <SERVER> is running on port: 9082 for profile AppSrvStdAlone
Testing server using the following URL:http://<SERVER>:9082/ivt/ivtserver?parm2=ivtservlet
IVTL0050I: Servlet engine verification status: Passed
Testing server using the following URL:http://<SERVER>:9082/ivt/ivtserver?parm2=ivtAddition.jsp
IVTL0055I: JavaServer Pages files verification status: Passed
Testing server using the following URL:http://<SERVER>:9082/ivt/ivtserver?parm2=ivtejb
IVTL0060I: Enterprise bean verification status: Passed
IVTL0035I: The Installation Verification Tool is scanning the file /opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/logs/server1/SystemOut.log for errors and warnings.
[4/15/09 11:50:46:843 CEST] 0000000a WSKeyStore W CWPKI0041W: One or more key stores are using the default password.
[4/15/09 11:51:24:574 CEST] 0000000a ThreadPoolMgr W WSVR0626W: The ThreadPool setting on the ObjectRequestBroker service is deprecated.
IVTL0040I: 2 errors/warnings are detected in the file /opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/logs/server1/SystemOut.log
IVTL0070I: The Installation Verification Tool verification succeeded.
IVTL0080I: The installation verification is complete.
Per avviare o fermare il server da linea di comando:
[root@<SERVER> bin]# pwd /opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/bin [root@<SERVER> bin]# ./stopServer.sh server1 ADMU0116I: Tool information is being logged in file /opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/logs/server1/stopServer.log ADMU0128I: Starting tool with the AppSrvStdAlone profile ADMU3100I: Reading configuration for server: server1 ADMU3201I: Server stop request issued. Waiting for stop status. ADMU4000I: Server server1 stop completed.
[root@<SERVER> bin]# ./startServer.sh server1 ADMU0116I: Tool information is being logged in file /opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/logs/server1/startServer.log ADMU0128I: Starting tool with the AppSrvStdAlone profile ADMU3100I: Reading configuration for server: server1 ADMU3200I: Server launched. Waiting for initialization status. ADMU3000I: Server server1 open for e-business; process id is 14121
Console di amministrazione
Durante la creazione del profilo viene distribuita la console amministrativa raggiungibile alla url
HYPERLINK "https://localhost:9047/ibm/console/logon.jsp" https://<SERVER>:9047/ibm/console/logon.jsp
Figura 3 - Console amministrativa.
Applicazioni installate
I moduli Java EE dell'applicazione Java EE "IVTApplication" sono due: un modulo web (WAR) e un modulo EJB come riportato di seguito. Il contesto di deploy è dato dalla definizione di WebSphere: cella, nodo, server, come riportato.
Figura 4 - Applicazioni installate.
Figura 5 - Moduli Java EE associati ad una applicazione.
L'applicazione web è accedibile alla url
HYPERLINK "http://localhost:9082/ivt/ivtDate.jsp" http://localhost:9082/ivt/ivtDate.jsp
Figura 6 - Accesso alla web application.
Deploy di un EAR
La console amministrativa mette a disposizione un wizard di deploy delle applicazioni Java EE. Va considerato che, soprattutto in presenza di molti EAR di cui effettuare il deploy, esiste la possibilità di distribuire attraverso scripting, con un comando
wsadmin.sh
collocato nella bin del profilo
Undeploy dell'EAR
Per effettuare un undeploy dell'archivio, occorre agire come segue:
uninstallEar.sh:
/opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/bin/wsadmin.sh -user <WAS_USER> -password <WAS_USER_PWD>-f /root/deployCmd/unistallApp.jacl
unistallApp.jacl:
$AdminApp uninstall IVTApplication $AdminConfig save
Si ottiene il seguente output della console:
[root@<SERVER> deployCmd]# ./uninstallEar.sh WASX7209I: Connected to process "server1" on node <SERVER>NodeStdAlone using SOAP connector; The type of process is: UnManagedProcess ADMA5017I: Uninstallation of IVTApplication started. ADMA5104I: The server index entry for WebSphere:cell=<SERVER>Node01Cell,node=<SERVER>NodeStdAlone is updated successfully. ADMA5102I: The configuration data for IVTApplication from the configuration repository is deleted successfully. ADMA5011I: The cleanup of the temp directory for application IVTApplication is complete. ADMA5106I: Application IVTApplication uninstalled successfully.
Deploy dell'EAR
L'EAR deve preventivamente essere presente sul file system del server
/opt/IBM/WebSphere/AppServer/installableApps/ivtApp.ear
Come descritto nel precedente articolo, sarà possibile inserire un opportuno task di Ant nel file di configurazione di Cruise Control che trasferisca automaticamente l'EAR sul file system del nostro application server.
installEar.sh
/opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/bin/wsadmin.sh -user wasadmin -password wasadmin -f /root/deployCmd/installApp.jacl
installApp.jacl
$AdminApp install /opt/IBM/WebSphere/AppServer/installableApps/ivtApp.ear {-appname IVTApplication -MapWebModToVH {{"IVT Application" ivt_app.war,WEB-INF/web.xml default_host}} -MapModulesToServers {{"IVT EJB Module" ivtEJB.jar,META-INF/ejb-jar.xml WebSphere:cell=<SERVER>Node01Cell,node=<SERVER>NodeStdAlone,server=server1}{"IVT Application" ivt_app.war,WEB-INF/web.xml WebSphere:cell=<SERVER>Node01Cell,node=<SERVER>NodeStdAlone,server=server1}}}
$AdminConfig save
Mapping del modulo web sul virtual host
-MapWebModToVH {{"IVT Application" ivt_app.war,WEB-INF/web.xml default_host}}
dove default_host:
"IVT Application" ivt_app.war * WEB-INF/web.xml
-MapModulesToServers
* "IVT EJB Module" ivtEJB.jar,META-INF/ejb-jar.xml
Figura 7 - Descrittore di distribuzione del modulo Ejb.
"IVT Application" ivt_app.war,WEB-INF/web.xml
Figura 8 - Descrittore di distribuzione del modulo Web.
Ambito WebSphere
cell=<SERVER>Node01Cell,node=<SERVER>NodeStdAlone,server=server1
Output della console:
[root@<SERVER> deployCmd]# ./installEar.sh
WASX7209I: Connected to process "server1" on node <SERVER>NodeStdAlone using SOAP connector; The type of process is: UnManagedProcess
ADMA0080W: A template policy file without any permission set is included in the 1.2.x enterprise application. You can modify the Java 2 Security policy for the enterprise application by editing the was.policy file that is located in the ${user.install.root}/config/cells/(yourCellName)/applications/(yourAppName).ear/deployments/(yourAppName)/META-INF directory after the application is installed.
WASX7327I: Contents of was.policy file:
//
// Template policy file for enterprise application.
// Extra permissions can be added if required by the enterprise application.
//
// NOTE: Syntax errors in the policy files will cause the enterprise application FAIL to start.
// Extreme care should be taken when editing these policy files. It is advised to use
// the policytool provided by the JDK for editing the policy files
// (WAS_HOME/java/jre/bin/policytool).
//
grant codeBase "file:${application}" {
};
grant codeBase "file:${jars}" {
};
grant codeBase "file:${connectorComponent}" {
};
grant codeBase "file:${webComponent}" {
};
grant codeBase "file:${ejbComponent}" {
};
ADMA5016I: Installation of IVTApplication started. ADMA5058I: Application and module versions are validated with versions of deployment targets. ADMA5005I: The application IVTApplication is configured in the WebSphere Application Server repository. ADMA5053I: The library references for the installed optional package are created. ADMA5005I: The application IVTApplication is configured in the WebSphere Application Server repository. ADMA5001I: The application binaries are saved in /opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/wstemp/Script120a9a52a20/workspace/cells/<SERVER>Node01Cell/applications/IVTApplication.ear/IVTApplication.ear ADMA5005I: The application IVTApplication is configured in the WebSphere Application Server repository. SECJ0400I: Successfuly updated the application IVTApplication with the appContextIDForSecurity information. ADMA5011I: The cleanup of the temp directory for application IVTApplication is complete. ADMA5013I: Application IVTApplication installed successfully.
Dopo il suo deploy, l'applicazione è comunque ancora da avviare.
Figura 9 - Applicazione da avviare.
Nella cartella
/opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/logs/server1
saranno a disposizione i file di log di cui riportiamo qui sotto un fragment del systemOut.
************ Start Display Current Environment ************ WebSphere Platform 6.1 [ND 6.1.0.0 b0620.14] running with process name <SERVER>Node01Cell\<SERVER>NodeStdAlone\server1 and process id 11698 Host Operating System is Linux, version 2.6.9-42.EL Java version = J2RE 1.5.0 IBM J9 2.3 Linux x86-32 j9vmxi3223-20060504 (JIT enabled) J9VM - 20060501_06428_lHdSMR JIT - 20060428_1800_r8 GC - 20060501_AA, Java Compiler = j9jit23, Java VM name = IBM J9 VM was.install.root = /opt/IBM/WebSphere/AppServer user.install.root = /opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone Java Home = /opt/IBM/WebSphere/AppServer/java/jre ws.ext.dirs = /opt/IBM/WebSphere/AppServer/java/lib:/opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/classes:/opt/IBM/WebSphere/AppServer/classes:/opt/IBM/WebSphere/AppServer/lib:/opt/IBM/WebSphere/AppServer/installedChannels:/opt/IBM/WebSphere/AppServer/lib/ext:/opt/IBM/WebSphere/AppServer/web/help:/opt/IBM/WebSphere/AppServer/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime Classpath = /opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/properties:/opt/IBM/WebSphere/AppServer/properties:/opt/IBM/WebSphere/AppServer/lib/startup.jar:/opt/IBM/WebSphere/AppServer/lib/bootstrap.jar:/opt/IBM/WebSphere/AppServer/lib/j2ee.jar:/opt/IBM/WebSphere/AppServer/lib/lmproxy.jar:/opt/IBM/WebSphere/AppServer/lib/urlprotocols.jar:/opt/IBM/WebSphere/AppServer/deploytool/itp/batchboot.jar:/opt/IBM/WebSphere/AppServer/deploytool/itp/batch2.jar:/opt/IBM/WebSphere/AppServer/java/lib/tools.jar Java Library path = /opt/IBM/WebSphere/AppServer/java/jre/bin:/opt/IBM/WebSphere/AppServer/java/jre/bin/j9vm:/opt/IBM/WebSphere/AppServer/java/jre/bin:/opt/IBM/WebSphere/AppServer/bin:/opt/IBM/WebSphere/AppServer/java/jre/bin:/opt/IBM/WebSphere/AppServer/java/jre/bin/j9vm:/opt/IBM/WebSphere/AppServer/java/jre/bin:/home/db2inst1/sqllib/lib:/usr/lib ************** End Display Current Environment **************
[4/15/09 14:13:38:211 CEST] 000000a8 ApplicationMg A WSVR0200I: Starting application: IVTApplication [4/15/09 14:13:38:215 CEST] 000000a8 ApplicationMg A WSVR0203I: Application: IVTApplication Application build level: WAS61.SERV1 [b0620.14] [4/15/09 14:13:38:628 CEST] 000000a8 EJBContainerI I WSVR0037I: Starting EJB jar: ivtEJB.jar [4/15/09 14:13:38:903 CEST] 000000a8 EJBContainerI I WSVR0057I: EJB jar started: ivtEJB.jar [4/15/09 14:13:39:114 CEST] 000000a8 WebGroup A SRVE0169I: Loading Web Module: IVT Application. [4/15/09 14:13:39:673 CEST] 000000a8 VirtualHost I SRVE0250I: Web Module IVT Application has been bound to default_host[*:9082,*:80,*:9445,*:5065,*:5064,*:443]. [4/15/09 14:13:39:897 CEST] 000000a8 ApplicationMg A WSVR0221I: Application started: IVTApplication
Deploy da remoto
Diamo ora una brevissima descrizione dei comandi ant e run.bat, dell'impostazione del runtime di WAS (necessaria installazione locale di WAS)
Individuiamo la porta SOAP in ascolto sul server1 alla variabile SOAPCONNECTORADDRESS
Figura 10 - Lista delle porte di un application server.
Occorre anzitutto aggiornare il key store locale (viene richiesta user e password di WAS remoto), come segue:
D:\Programmi\IBM\SDP70_1\runtimes\base_v61\profiles\AppSrv01\bin>wsadmin.bat -conntype SOAP -host 10.4.7.94 -port 8884
DN soggetto: CN=was61host00, O=IBM, C=US DN emittente: CN=was61host00, O=IBM, C=US Numero di serie: 1239702359 Scadenza: Wed Apr 14 11:45:59 CEST 2010 Digest SHA-1: 7F:C1:98:C1:97:55:2A:21:DF:10:21:DB:48:87:44:89:CA:04:88:90 Digest MD5: B6:68:D7:91:B6:DF:9C:20:42:91:75:ED:DE:F9:FE:0C
[exec] Aggiungere ora il firmatario all'archivio trust? (s/n)
D:\Programmi\IBM\SDP70_1\runtimes\base_v61\profiles\AppSrv01\etc\trust.p12
Lanciare il task di ant: integrare il cruise control alla fine della compilazione e creazione dell'EAR). Nel menu in alto a sinistra è disponibile l'allegato deployAnt.zip: attenzione, perche' è un task piuttosto lento se usato per molti EAR sul protocollo SOAP.
xBuildfile: build.xml
ear.deploy:
[echo] --------------------------------------
[echoproperties] #Ant properties
[echoproperties] #Thu Apr 16 17:49:57 CEST 2009
[echoproperties] deploy.ear.jacl=<PATH_JACL_FILE>/DeployStartApp.jacl
[echoproperties] project.name=ivtApp
[echoproperties] websphere.host.name=<SERVER>
[echoproperties] websphere.soap.port=8884
[echo] --------------------------------------
[exec] WASX7209I: Connesso al processo "server1" sul nodo <SERVER>NodeStdAlone utilizzando il connettore SOAP; il tipo di processo è: UnManagedProcess
[exec] ADMA5017I: Uninstallation of IVTApplication started.
[exec] ADMA5104I: The server index entry for WebSphere:cell=<SERVER>Node01Cell,node=<SERVER>NodeStdAlone is updated successfully.
[exec] ADMA5102I: The configuration data for IVTApplication from the configuration repository is deleted successfully.
[exec] ADMA5011I: The cleanup of the temp directory for application IVTApplication is complete.
[exec] ADMA5106I: Application IVTApplication uninstalled successfully.
[exec] ADMA0080W: Un file modello della politica senza autorizzazioni impostate viene incluso nell'applicazione enterprise 1.2.x. È possibile modificare la politica di Java 2 Security per l'applicazione cambiando il file was.policy che si trova nella directory ${user.install.root}/config/cells/(NomeCella)/applications/(NomeApplicazione).ear/deployments/(NomeApplicazione)/META-INF dopo aver installato l'applicazione.
[exec] WASX7327I: Contenuti del file was.policy:
[exec] //
[exec] // Template policy file for enterprise application.
[exec] // Extra permissions can be added if required by the enterprise application.
[exec] //
[exec] // NOTE: Syntax errors in the policy files will cause the enterprise application FAIL to start.
[exec] // Extreme care should be taken when editing these policy files. It is advised to use
[exec] // the policytool provided by the JDK for editing the policy files
[exec] // (WAS_HOME/java/jre/bin/policytool).
[exec] //
[exec]
[exec] grant codeBase "file:${application}" {
[exec] };
[exec]
[exec] grant codeBase "file:${jars}" {
[exec] };
[exec]
[exec] grant codeBase "file:${connectorComponent}" {
[exec] };
[exec]
[exec] grant codeBase "file:${webComponent}" {
[exec] };
[exec]
[exec] grant codeBase "file:${ejbComponent}" {
[exec] };
[exec]
[exec]
[exec] ADMA5016I: Installation of IVTApplication started.
[exec] ADMA5058I: Application and module versions are validated with versions of deployment targets.
[exec] ADMA5005I: The application IVTApplication is configured in the WebSphere Application Server repository.
[exec] ADMA5053I: The library references for the installed optional package are created.
[exec] ADMA5005I: The application IVTApplication is configured in the WebSphere Application Server repository.
[exec] ADMA5001I: The application binaries are saved in /opt/IBM/WebSphere/AppServer/profiles/AppSrvStdAlone/wstemp/Script120af9ee58a/workspace/cells/<SERVER>Node01Cell/applications/IVTApplication.ear/IVTApplication.ear
[exec] ADMA5005I: The application IVTApplication is configured in the WebSphere Application Server repository.
[exec] SECJ0400I: Successfuly updated the application IVTApplication with the appContextIDForSecurity information.
[exec] ADMA5011I: The cleanup of the temp directory for application IVTApplication is complete.
[exec] ADMA5013I: Application IVTApplication installed successfully.
[exec] Starting IVTApplication on node <SERVER>NodeStdAlone, server server1.
[exec]
BUILD SUCCESSFUL Total time: 1 minute 26 seconds
E così abbiamo messo a disposizione un server come schematizzato nella figura 11.
Figura 11 - Provisioning dell'ambiente di pre-integrazione.
Conclusioni
In questo articolo siamo andati avanti nella nostra panoramica sul provisioning degli ambienti server. In particolare, abbiamo visto come creare un server standalone in WebSphere attraverso un "tutorial" passo per passo. Nel prossimo articolo aggiungeremo un po' di complessità, affrontando praticamente il tema della scalabilità e trattando il concetto di failover.
Riferimenti
- [1] WebSphere Application Server, Versione 6.1
HYPERLINK "http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp" http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp
- [2] Steve Robinson, WebSphere Tools
HYPERLINK "http://www.webspheretools.com" http://www.webspheretools.com
