Search
Calendar
July 2025
S M T W T F S
« Jun    
 12345
6789101112
13141516171819
20212223242526
2728293031  
Archives

Posts Tagged ‘Weblogic 10’

PostHeaderIcon WebLogic: use a startup and/or a shutdown class in a WAR

Abstract

WebLogic offers you to specify a startup and/or a shutdown class for an application. Anyway, this feature is restrained to EARs, and is not available for applications deployed as WARs. For EARs, Oracle WebLogic Server’s documentation is complete and gives basic examples: Programming Application Life Cycle Events

Yet, sometimes you need such a class even for a WebApp. You have two ways to handle this case.

Solutions

Full Weblogic!

Base

The first solution is not elegant. Open WebLogic console, go to Startup And Shutdown Classes, then add the classes names of which main() methods will be run on startup and shutdown, let’s say JonathanWeblogicStartup. These classes must be available in WebLogic classpath, which is surely different from your application classpath, eg in a library $DOMAIN_HOME/lib/customized-weblogic.jar.
Advantage of this means: if your startup/shutdown class does not evoluate often, then write it once and forget, it will be OK. Unlike, you will have to manage different versions of the JAR on each release… I assume your exploitation team may get angry at playing with classpaths and lib folders 😀

Suggestion

To improve the basic solution (and avoid your exploitation guy burst in your office), I had the following idea, that I did not experiment, but that should work:

  • Keep JonathanWeblogicStartup
  • Create another class JonathanConcreteStartup, locate as a source in your application code.
  • In JonathanStartup.main(), call JonathanConcreteStartup

This way,

  1. You keep a unique JAR in classpath that you do not need to update and you can forget.
  2. You can add, update or remove features in your very source code.
  3. The exploitation teams does not become hateful at you.

Add a Listener

The second one requires a bit more work.

  • Create a class implementing javax.servlet.ServletContextListener interface, let’s say MyLifecycleListener.
  • Implement methods contextInitialized() and contextDestroyed().
  • Edit your web.xml, add the following block:
      <listener>
            <listener-class>lalou.jonathan.MyLifecycleListener</listener-class>
        </listener>
  • Rebuild and deploy. It should be OK

PostHeaderIcon WebLogic: Unresolved Webapp Library references for … coherence-web-spi

Case

I have to integrate Oracle Coherence, or more accurately Coherence*Web, within an application deployed as a WAR in WebLogic 10.3.
Since Oracle bought both BEA and Tangosol, increasing their integration, using Coherence jars implicitely is allowed. Anyway I decided to add the following block in weblogic.xml

    <library-ref>
        <library-name>coherence-web-spi</library-name>
        <specification-version>1.0.0.0</specification-version>
        <implementation-version>1.0.0.0</implementation-version>
        <exact-match>false</exact-match>
    </library-ref>

Then I get this error:

Caused By: weblogic.management.DeploymentException: Error: Unresolved Webapp Library references for
""ServletContext@25681165[app:risklayer-web module:jonathan-lalou.war path:/jonathan-lalou spec-version:null]"", defined in weblogic.xml [Extension-Name: coherence-web-spi, Specification-Version: 1, Implementation-Version: 1.0.0.0, exact-match: false]

Fix

Indeed, I had to deploy Coherence*Web WAR in WebLogic, in the console:
Deployments > Install > select Coherence WAR, eg: C:\jonathan\bea\coherence_3.5\lib\coherence-web-spi.war > Next> Install this deployment as a library > Next > Target your server > Finish

PostHeaderIcon Mule / MQJE001 / MQJMS2007

Case

In a Mule ESB workflow, the endpoint is a <jms:outbound-endpoint>, pointing to a JMS queue hosted on MQ Series and accessed through WebLogic 10.3.3.

I get the following stracktrace

Exception stack is:
1. MQJE001: Completion Code 2, Reason 2027 (com.ibm.mq.MQException)
com.ibm.mq.MQQueue:1624 (null)
2. MQJMS2007: failed to send message to MQ queue(JMS Code: MQJMS2007) (javax.jms.JMSException)
com.ibm.mq.jms.services.ConfigEnvironment:622 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/JMSException.html)
3. Failed to create and dispatch response event over Jms destination "queue://MQSERVER/AMQ.4C8A5E112285475605?persistence=1". Failed to route event via endpoint: null. Message payload is of type: JMSObjectMessage (org.mule.api.transport.DispatchException)
org.mule.transport.jms.JmsReplyToHandler:154 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/transport/DispatchException.html)

Fix

On Mule config file, explicitly set the attribute disableTemporaryReplyToDestinations at true in the JMS outbound tag:

<jms:outbound-endpoint
 queue="jonathan.lalou.jms.queue"
 connector-ref="jmsConnector"
 transformer-refs="foo" disableTemporaryReplyToDestinations="true"/>

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:
    &lt;Oct 15, 2010 12:09:21 PM CEST&gt; &lt;Notice&gt; &lt;WebLogicServer&gt; &lt;BEA-000395&gt; &lt;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&gt;

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.