Search
Calendar
April 2024
S M T W T F S
« Sep    
 123456
78910111213
14151617181920
21222324252627
282930  
Your widget title
Archives

Posts Tagged ‘Weblogic’

PostHeaderIcon Tutorial: from an application, make a clustered application, within WebLogic 10

Abstract

You have a non-clustered installation, on the host with DNS name jonathanDevDesktop, with an admin (port: 7001), a muletier (port: 7003) and a webtier (port: 7005) instances.
You need set your muletier as a clustered installation, with two nodes, on the same server. The second node will dedeployed on port 7007.

We assume you have a configured JMS Modules (in our case: JmsMqModule, even though the bridge between WebLogic and MQ has no impact here).

Process

Batches

  • Copy $DOMAINS\jonathanApplication\start-muletier-server.bat" as $DOMAINS\jonathanApplication\start-muletier-server-2.bat"
  • Edit it:
    • Possibly, modify the debug port (usually: 5006)
    • Replace the line
      call "%DOMAIN_HOME%\bin\startManagedWebLogic.cmd" muletier t3://jonathanDevDesktop:7001

      with

      call "%DOMAIN_HOME%\bin\startManagedWebLogic.cmd" muletier2 t3://jonathanDevDesktop:7001

Second Node Creation

  • Following points are not required.
    • Copy the folder %DOMAIN_HOME%\servers\muletier as %DOMAIN_HOME%\servers\muletier2
    • Delete the folders %DOMAIN_HOME%\servers\muletier2\cache and %DOMAIN_HOME%\servers\muletier2\logs
  • Stop the server muletier
  • On WebLogic console:
    • Servers > New > Server Name: muletier2, Server Listen Port: 7007 > Check Yes, create a new cluster for this server. > Next
    • Name: jonathanApplication.cluster.muletier > Messaging Mode: Multicast, Multicast Address: 239.235.0.4, Multicast Port:5777
    • Clusters > jonathanApplication.cluster.muletier > Configuration > Servers > Select a server: muletier
    • Clusters > jonathanApplication.cluster.muletier > Configuration > Servers > Select a server: muletier2
  • Start the instances of muletier and muletier2 in MS-DOS consoles.
  • On the WebLogic console:
    • Deployments > jonathanApplication-web (the mule instance) > Targets > check “jonathanApplication.cluster.muletier” and “All servers in the cluster” > Save
  • On the muletier2 DOS console, you can see the application is deployed.

JMS Configuration

The deployment of JMS on clustered environment is a little tricky.

  • On WebLogic console: JMS Modules > JmsMqModule > Targets > check “jonathanApplication.cluster.muletier” and “All servers in the cluster
  • Even though it is not required, restart your muletiers. Then you can send messages either on port 7003 or 7007, they will be popped and handled the same way.

PostHeaderIcon Tutorial: Use WebShere MQ as JMS provider within WebLogic 10.3.3, and Mule ESB as a client

Abstract

You have an application deployed on WebLogic 10 (used version for this tutorial: 10.3.3). You have to use an external provider for JMS, in our case MQ Series / WebSphere MQ.
The client side is a Mule ESB launched in standalone.

Prerequisites

You have:

  • a running WebLogic 10 with an admin instance and an another instance, in our case: Muletier.
  • a file file.bindings, used for MQ.

JARs installation

  • Stop all your WebLogic 10 running instances.
  • Get the JARs from MQ Series folders:
    • providerutil.jar
    • fscontext.jar
    • dhbcore.jar
    • connector.jar
    • commonservices.jar
    • com.ibm.mqjms.jar
    • com.ibm.mq.jar
  • Copy them in your domain additional libraries folder (usually: user_projects/domains/jonathanApplication/lib/)
  • Start WebLogic 10 admin. A block like this should appear:
    <Oct 15, 2010 12:09:21 PM CEST> <Notice> <WebLogicServer> <BEA-000395> <Following extensions directory contents added to the end of the classpath:
    C:\win32app\bea\user_projects\domains\jonathanApplication\lib\com.ibm.mq.jar;C:\win32app\bea\user_projects\domains\jonathanApplication\lib\com.ibm.mqjms.jar;C:\win32app\bea\user_projects\domains\jonathanApplication\lib\commonservices.jar;C:\win32app\bea\user_projects\domains\jonathanApplication\lib\connector.jar;C:\win32app\bea\user_projects\domains\jonathanApplication\lib\dhbcore.jar;C:\win32app\bea\user_projects\domains\jonathanApplication\lib\fscontext.jar;C:\win32app\bea\
    user_projects\domains\jonathanApplication\lib\providerutil.jar>

Config

  • Get file.bindings, copy it into user_projects/domains/jonathanApplication/config/jms, rename it as .bindings (without any prefix)
  • Launch the console, login
  • JMS > JMS Modules > Create JMS System Module > Name: JmsMqModule. Leave other fields empty. > Next > target server MuleTier > Finish
  • Select JmsMqModule > New > Foreign Server > Name: MQForeignServer > keep check MuleTier > Finish
    • Select MQForeignServer >
    • Tab Connection Factories > New >
      • Name: MQForeignConnectionFactory
      • Local JNDI Name: the JNDI name on WebLogic side, eg: jonathanApplication/jms/connectionFactory/local (convention I could observe: separator on WebLogic: slash '/' ; unlike clients for which the separator in a dot '.')
      • Remote JNDI Name: the JNDI name on MQ side, eg: JONATHAN_APPLICATION.QCF
      • OK
    • Tab Destinations > New >
      • Queue of requests:
        • Name: JONATHAN.APPLICATION.REQUEST
        • Local JNDI Name: JONATHAN.APPLICATION.REQUEST
        • Remote JNDI Name: JONATHAN.APPLICATION.REQUEST
      • Queue of response:
        • Name: JONATHAN.APPLICATION.REPONSE
        • Local JNDI Name: JONATHAN.APPLICATION.REPONSE
        • Remote JNDI Name: JONATHAN.APPLICATION.REPONSE
      • NB: usually, MQ data are upper-cased and Java’s JNDI names are low-cased typed ; anyway (because of Windows not matching case?) here we use uppercase in for both names.

Mule

This part of the tutorial deals with a case of Mule ESB being your client application (sending and/or receiving JMS messages).

  • Get the archive wlfullclient.jar (56MB). Alternatively, you can generate it yourself: go to the server/lib directory of your WebLogic installation (usually: C:\win32app\bea\wlserver_10.3\server\lib, and run: java -jar wljarbuilder.jar
  • Copy the archive into $MULE_HOME/lib/user
  • Copy the seven jars above (providerutil.jar, fscontext.jar, dhbcore.jar, connector.jar, commonservices.jar, com.ibm.mqjms.jar, com.ibm.mq.jar) into the same folder: $MULE_HOME/lib/user
  • You can launch the mule. The config file is similar to any other configuration using standard JMS.

PostHeaderIcon Use a JDBC datasource from WebLogic’s JNDI

Case

Your application is connected to a database. The configuration of the DB connexion is set in a Spring file. You would like the connexion to be set in WebLogic, so that no URL/login/password lays in your source code.

Steps

WebLogic

Create a new data source:

  • go the WebLogic console >
    • JDBC >
      • DataSource >
        • New >
          • set the name, JNDI name (eg: database.jndi.name), DB type  (Oracle, Sybase, …) >
            • Next >
              • Select the driver >
                • Next >
                  • Select the targeted server(s)

This will

  1. create a new file <yourDomain>/config/jdbc/<datasourceName>-XXXX-jdbc.xml.
  2. add a <jdbc-system-resource> block in <yourDomain>/config/config.xml

Spring

Replace the block:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${database.driver}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
 </bean>

with:

<jee:jndi-lookup id="dataSource" jndi-name="${database.jndi.name}" />

PostHeaderIcon WebLogic Deployment with Maven: Dynamic Property Settings

Case

You have to deploy a WAR archive on a WebLogic server. To simplify the deployment process, you use weblogic-maven-plugin. Then, you only have to launch a mvn clean install weblogic:deploy to compile and deploy the WAR.

Actually, the plugin configuration expects you to hard write the settings in the pom.xml, such as:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>weblogic-maven-plugin</artifactId>
    <version>2.9.1</version>
    <configuration>
        <name>myWebApplication-web</name>
        <adminServerHostName>localhost</adminServerHostName>
        <adminServerPort>7001</adminServerPort>
        <adminServerProtocol>t3</adminServerProtocol>
        <targetNames>myTargetServer</targetNames>
        <userId>myUserId</userId>
        <password>myPassword</password>
        <securitymodel>Advanced</securitymodel>
        <artifactPath>${project.build.directory}/myWebApplication-web.war</artifactPath>
    </configuration>
</plugin>

Yet, when you work on a multi-environment / multi-developper platform, hard writing the properties bothers. Production teams are not pleased, and, above all, it’s not safe.

Unworking fix

At first glance, I tried to use Maven filtering mechanisms. Anyway, this features was designed for compilation phase: properties are recopied from a property file to the actual one, and then included in the archive generated (may it be JAR, EAR or WAR); in a deployment phase, properties are not taken in account.
http://maven.apache.org/guides/getting-started/index.html#How_do_I_filter_resource_files

Unelegant fix

Another solution is to set properties by profile. This works, but is not elegant at all: the password for production environment has to reason to be readable in the pom.xml used by a developper!

Fix

WebLogic / Maven plugin

Add the following block:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>weblogic-maven-plugin</artifactId>
  <version>2.9.1</version>
  <configuration>
      <name>myWebApplication-web</name>
      <adminServerHostName>${weblogic.server.name}</adminServerHostName>
      <adminServerPort>${weblogic.server.port}</adminServerPort>
      <adminServerProtocol>${weblogic.server.protocol}
      </adminServerProtocol>
      <targetNames>${weblogic.target}</targetNames>
      <userId>${weblogic.user}</userId>
      <password>${weblogic.password}</password>
      <securitymodel>${weblogic.security}</securitymodel>
      <artifactPath>${project.build.directory}/myWebApplication-web.war
      </artifactPath>
  </configuration>
</plugin>

Properties / Maven plugin

Under the tag, add the block:

<properties>
    <weblogic.server.name>${myTargetServer.server.name}</weblogic.server.name>
    <weblogic.server.port>${myTargetServer.server.port}</weblogic.server.port>
    <weblogic.server.protocol>${myTargetServer.server.protocol}</weblogic.server.protocol>
    <weblogic.user>${myTargetServer.user}</weblogic.user>
    <weblogic.password>${myTargetServer.password}</weblogic.password>
    <weblogic.target>${myTargetServer.target}</weblogic.target>
    <weblogic.security>${myTargetServer.security}</weblogic.security>
</properties>

Within the block, add the the following block:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0-alpha-2</version>
    <executions>
        <execution>
            <phase>initialize</phase>
            <goals>
                <goal>read-project-properties</goal>
            </goals>
            <configuration>
                <files>
                    <file>conf/${maven.user}.myTargetServer.properties</file>
                </files>
            </configuration>
        </execution>
    </executions>
</plugin>

Settings.xml

Optionnaly, in your settings.xml, in your default profile, set the following property:

<profile></pre>
<id>myDefaultProfile</id>
 <properties>
 <maven.user>jonathan_lalou</maven.user>
 </properties>
</profile>

You can decide to bypass this step. In this case, you will have to add the following parameter on launching Maven:
-Dmaven.user=jonathan_lalou

Property file

Create a property file, with a name corresponding to the one you specified in maven.user property.

myTargetServer.server.name=localhost
myTargetServer.server.port=7001
myTargetServer.server.protocol=t3
myTargetServer.user=myUserId
myTargetServer.password=myPassword
myTargetServer.target=myTargetServer
myTargetServer.security=Advanced

Now, you can launch mvn package weblogic:deploy. The WAR will be deployed on the right server.

PostHeaderIcon weblogic-maven-plugin / java.net.MalformedURLException: no protocol: and

Case

I run mvn weblogic:deploy, with a correct configuration inside pom.xml file, in order to deploy a WAR on a WebLogic 10 server. My development machine runs under Windows XP, the distant server is under Linux. I get the following error:
java.net.MalformedURLException: no protocol: and

Complete stacktrace:

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'weblogic'.
[INFO] ------------------------------------------------------------------------
[INFO] Building myWar Maven Webapp
[INFO]    task-segment: [weblogic:deploy]
[INFO] ------------------------------------------------------------------------
Downloading: http://repository.codehaus.org/weblogic/weblogic/9.0/weblogic-9.0.pom
[INFO] Unable to find resource 'weblogic:weblogic:pom:9.0' in repository codehaus.org (http://repository.codehaus.org)
Downloading: http://repo1.maven.org/maven2/weblogic/weblogic/9.0/weblogic-9.0.pom
[INFO] Unable to find resource 'weblogic:weblogic:pom:9.0' in repository central (http://repo1.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/weblogic/weblogic/9.0/weblogic-9.0.pom
[INFO] Unable to find resource 'weblogic:weblogic:pom:9.0' in repository central (http://repo1.maven.org/maven2)
Downloading: http://repository.codehaus.org/weblogic/webservices/9.0/webservices-9.0.pom
[INFO] Unable to find resource 'weblogic:webservices:pom:9.0' in repository codehaus.org (http://repository.codehaus.org)
Downloading: http://repo1.maven.org/maven2/weblogic/webservices/9.0/webservices-9.0.pom
[INFO] Unable to find resource 'weblogic:webservices:pom:9.0' in repository central (http://repo1.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/weblogic/webservices/9.0/webservices-9.0.pom
[INFO] Unable to find resource 'weblogic:webservices:pom:9.0' in repository central (http://repo1.maven.org/maven2)
[INFO] [weblogic:deploy]
[INFO] Weblogic Deployment beginning with parameters DeployMojoBase[adminServerHostName = myLocalHost, adminServerProtocol = t3, adminServerPort = 7001, userId = weblogic, password = myPassword, artifactPath = C:\...\target/myWar.war, projectPackaging = war, name = myWar, targetNames = oneTier, remote = true]
[INFO] Weblogic Deployment parameters [-adminurl, t3://myLocalHost:7001, -username, weblogic, -password, myPassword, -verbose, -debug, -name, myWar, -targets, muletier, -upload, -source, C:\...\target/myWar, -deploy]
weblogic.Deployer invoked with options:  -adminurl t3://myLocalHost:7001 -username weblogic -verbose -debug -name myWar -targets muletier -upload -source C:\workarea\development\primeweb\primeweb\projects\strategic\myWar\target/myWar -deploy
[WebLogicDeploymentManagerImpl.<init>():103] : Constructing DeploymentManager for J2EE version V1_4
deployments
[WebLogicDeploymentManagerImpl.getNewConnection():146] : Connecting to admin server at myLocalHost:7001, as user weblogic
[ServerConnectionImpl.getEnvironment():288] : setting environment
[ServerConnectionImpl.getEnvironment():291] : getting context using t3://myLocalHost:7001
[ServerConnectionImpl.getMBeanServer():239] : Connecting to MBeanServer at service:jmx:t3://myLocalHost:7001/jndi/weblogic.management.mbeanservers.domainruntime
[ServerConnectionImpl.getMBeanServer():239] : Connecting to MBeanServer at service:jmx:t3://myLocalHost:7001/jndi/weblogic.management.mbeanservers.runtime
[DomainManager.resetDomain():36] : Getting new domain
[DomainManager.resetDomain():39] : Using pending domain: true
[MBeanCache.addNotificationListener():96] : Adding notification listener for weblogic.deploy.api.spi.deploy.mbeans.TargetCache@19ccba
[MBeanCache.addNotificationListener():107] : Disabling mbean caching due to: java.net.MalformedURLException: no protocol: and
[MBeanCache.addNotificationListener():96] : Adding notification listener for weblogic.deploy.api.spi.deploy.mbeans.ModuleCache@ae1cf
[MBeanCache.addNotificationListener():107] : Disabling mbean caching due to: java.net.MalformedURLException: no protocol: and
[ServerConnectionImpl.initialize():171] : Connected to WLS domain: myMainDomain
[ServerConnectionImpl.setRemote():482] : Running in remote mode
[ServerConnectionImpl.init():161] : Initializing ServerConnection : weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl@a0e990
[BasicOperation.dumpTmids():690] : Incoming tmids:
[BasicOperation.dumpTmids():692] :   {Target=muletier, WebLogicTargetType=server, Name=myWar}, targeted=true
[BasicOperation.deriveAppName():139] : appname established as: myWar
<Aug 16, 2010 11:46:42 AM CEST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, myWar [archive: C:\workarea\development\primeweb\primeweb\projects\strategic\myWar\target\myWar], to muletier .>
[ServerConnectionImpl.upload():658] : Uploaded app to C:\win32app\bea\user_projects\domains\myMainDomain\.\servers\adminServer\upload\myWar
[BasicOperation.dumpTmids():690] : Incoming tmids:
[BasicOperation.dumpTmids():692] :   {Target=muletier, WebLogicTargetType=server, Name=myWar}, targeted=true
[BasicOperation.loadGeneralOptions():607] : Delete Files:false
Timeout :3600000
Targets:
muletier
ModuleTargets={}
SubModuleTargets={}
}
Files:
null
Deployment Plan: null
App root: C:\win32app\bea\user_projects\domains\myMainDomain\.\servers\adminServer\upload\myWar
App config: C:\win32app\bea\user_projects\domains\myMainDomain\.\servers\adminServer\upload\myWar\plan
Deployment Options: {isRetireGracefully=true,isGracefulProductionToAdmin=false,isGracefulIgnoreSessions=false,rmiGracePeriod=-1,retireTimeoutSecs=-1,undeployAllVersions=false,archiveVersion=null,planVersion=null,isLibrary=false,libSpecVersion=null,libImplVersion=null,stageMode=null,clusterTimeout=3600000,altDD=null,altWlsDD=null,name=myWar,securityModel=null,securityValidationEnabled=false,versionIdentifier=null,isTestMode=false,forceUndeployTimeout=0,defaultSubmoduleTargets=true,timeout=0}

[BasicOperation.execute():424] : Initiating deploy operation for app, myWar, on targets:
[BasicOperation.execute():426] :    muletier
<strong>java.net.MalformedURLException: no protocol: and</strong>
        at java.net.URL.<init>(URL.java:567)
        at java.net.URL.<init>(URL.java:464)
        at java.net.URL.<init>(URL.java:413)
        at sun.rmi.server.LoaderHandler.pathToURLs(LoaderHandler.java:751)
        at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:147)
        at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
        at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
        at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
        at javax.management.remote.rmi.RMIConnectionImpl$6.run(RMIConnectionImpl.java:1513)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.management.remote.rmi.RMIConnectionImpl.unwrap(RMIConnectionImpl.java:1505)
        at javax.management.remote.rmi.RMIConnectionImpl.access$500(RMIConnectionImpl.java:72)
        at javax.management.remote.rmi.RMIConnectionImpl$7.run(RMIConnectionImpl.java:1548)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.management.remote.rmi.RMIConnectionImpl.unwrap(RMIConnectionImpl.java:1544)
        at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:771)
        at javax.management.remote.rmi.RMIConnectionImpl_WLSkel.invoke(Unknown Source)
        at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
        at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
        at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
        at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
[ServerConnectionImpl.close():334] : Closing DM connection
[ServerConnectionImpl.close():354] : Unregistered all listeners
[ServerConnectionImpl.closeJMX():374] : Closed JMX connection
[ServerConnectionImpl.closeJMX():386] : Closed Runtime JMX connection
[ServerConnectionImpl.closeJMX():398] : Closed Edit JMX connection

Explanation

Indeed, the " and " comes from the address of my local Maven 2 repository: C:\Documents and Settings\myLogin\.m2\repository, which is the default location. I consider this to be a bug of Mojo’s weblogic-maven-plugin plugin.

Fix

You do not have many choices :-(… You have to move your repository to a destination without blank spaces, such as C:\M2_repository.
Then, take care to edit your settings.xml, and add the following block after <settings> tag:

<localRepository>C:\M2_repository</localRepository>