<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>James Bayer&apos;s Blog</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/" />
    <link rel="self" type="application/atom+xml" href="http://dev2dev.bea.com/blog/jbayer/atom.xml" />
   <id>tag:dev2dev.bea.com,2008:/blog/jbayer//215</id>
    <updated>2008-06-24T05:33:25Z</updated>
    
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 3.31</generator>
 
<entry>
    <title>ALSB FTP Nuance</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2008/06/alsb_ftp_nuance.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2008/06/alsb_ftp_nuance.html</id>
    
    <published>2008-06-18T21:17:44Z</published>
    <updated>2008-06-24T05:33:25Z</updated>
    
    <summary>One of my customers just recently had an issue with AquaLogic Service Bus&apos;s FTP transport.  This blog entries explains the nuance involved with FTP Business Service when a particular user and path are required.</summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: AquaLogic Service Bus" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<p>One of my customers just recently had an issue with AquaLogic Service Bus's FTP transport.&#160; They were attempting to write a file to a remote ftp site using a Business Service, but they kept getting a <a href="http://www.the-eggman.com/seminars/ftp_error_codes.html">553 error</a> from the FTP server.&#160; The stack looked similar to this:</p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">com.bea.wli.sb.transports.TransportException: Received error response (553) from FTP server [localhost] IP [127.0.0.1 port [21] status [connected] upon executing command [stor ./data/inbound/somefile.csv]
at com.bea.wli.sb.transports.ftp.connector.FTPTransportProvider.sendMessage(FTPTransportProvider.java:399)
at com.bea.wli.sb.transports.ftp.connector.FTPTransportProvider.sendMessageAsync(FTPTransportProvider.java:289)
at sun.reflect.GeneratedMethodAccessor579.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)</pre>
</div>

<p>It turns out that the path on the business service should be relative to the user of the service account of the FTP Business Service based on the directory the user was being placed in upon a successful ftp login.</p>

<p>So the original FTP URI was <a href="ftp://locahost:21/data/inbound/">ftp://locahost:21/data/inbound/</a></p>

<p>but since a specific user was being used being placed in a user-specific directory by the ftp-server, the URI should have been:</p>

<p><a href="ftp://localhost:21/../../data/inbound">ftp://localhost:21/../../data/inbound</a></p>

<p>The relative path components are required because the &quot;data&quot; directory is two levels above where the user was being placed.&#160; If you encounter this problem and need help from support, reference case 790268 and they should be able to help you out.</p>]]>
        
    </content>
</entry>
<entry>
    <title>Using X.509 Certificates for Identity Propagation with Web Service Security</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2008/04/using_x509_cert.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2008/04/using_x509_cert.html</id>
    
    <published>2008-04-29T19:11:42Z</published>
    <updated>2008-04-29T19:11:57Z</updated>
    
    <summary>One of my customers is considering a web services interface for exchanging information with their clients.  Security is a very important consideration in their design, so they are considering using best practices for authentication, integrity and confidentiality.  In this post I&apos;ll explain their situation and some detail around setting up a simple prototype.</summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: WebLogic Server" />
            <category term="Technology: Security" />
            <category term="Technology: Web Services" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<p>One of my customers is considering a web services interface for exchanging information with their clients.&#160; Security is a very important consideration in their design, so they are considering using best practices for authentication, integrity and confidentiality.&#160; In this post I'll explain some detail around my experiences setting up a simple prototype using Web Service Security hands-on.</p>  <h3>Introduction</h3>  <p>Currently they plan on using HTTPS for the transport, but SSL may be terminated by SSL hardware accelerators before it reaches the application server, so transport level security is not enough in this instance, we'll also need some message level security.&#160; The newer WS-Security 1.1 specification is available in the latest releases of WebLogic Server, but WS-Security 1.0 has maximum interoperability with other web services stacks.&#160; So it you are not in control of web service stack's that your clients are using, it's best to use the older standard.&#160; SAML, Username, and X.509 Token Profiles can be used for authentication.&#160; In this instance since certificates are already required for SSL, it will be straightforward to also use them to authenticate identity.&#160; This is a similar use-case to a previous dev2dev article posted on <a href="http://dev2dev.bea.com/pub/a/2007/06/securing-web-services.html">securing web services in WLS 9.2</a>, but in this case we are going to use the X.509 certificates for the identity propagation instead of Username Token.&#160; The formal name for this is the OASIS WS-Security X.509 Token Profile.&#160; The identity in the certificate will map to an LDAP user.</p>  <p>Note that WebLogic Server ships with examples that perform User-name Token authentication located at &lt;BEA_HOME&gt;\wlserver_10.0\samples\server\examples\src\examples\webservices\wss1.1</p>  <p>I was not able to find a X.509 Token Profile example, so I wrote it up here and hopefully you can benefit from my experiences by getting this running and understand the steps in under an hour.</p>  <h3>Client Diagram</h3>  <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingX509forIdentityPropagationinWLS10We_A7D3/ws-secClient_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="480" alt="ws-secClient" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingX509forIdentityPropagationinWLS10We_A7D3/ws-secClient_thumb.jpg" width="512" border="0" /></a> </p>  <h3>Server-side Diagram</h3>  <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingX509forIdentityPropagationinWLS10We_A7D3/ws-secServer_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="480" alt="ws-secServer" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingX509forIdentityPropagationinWLS10We_A7D3/ws-secServer_thumb.jpg" width="605" border="0" /></a> </p>  <h3>Basic Steps</h3>  <li>Client Certificate Setup (10 minutes)</li>  <li>Server Configuration (20 minutes)</li>  <li>Server-side JWS Programming (15 minutes)</li>  <li>Client-side Web Service Programming (15 minutes)</li>  <h3>Client Certificate Setup</h3>  <p>First, set up a java key store and certificate identifying a user that we can map to an LDAP user.&#160; In this example I use only the CN attribute.&#160; This CN attribute will map to a user in WebLogic's embedded LDAP, but you can use another enterprise LDAP (Active Directory, eDirectory, OpenLDAP) just as easily.&#160; We will use self-signed certificates in this simple example, but in production I would highly encourage you to use certificates issued by a <a href="http://en.wikipedia.org/wiki/Certificate_authority">Certificate Authority</a>.</p>  <p></p>  <p>   <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">keytool -genkey -v -keyalg RSA -sigalg SHA1withRSA -keystore D:/bea102/wlserver_10.0/samples/domains/wl_server/keystores/Identity.jks -alias testalias -keysize 1024 -keypass weblogic -storepass weblogic -dname CN=secuser'</pre>
  </div>
</p>

<p></p>

<p>Now we need to export the pubic key to a .pem file so we can import it on the server side.</p>

<p></p>

<p>
  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">keytool -export -alias testalias -file testalias.pem -sigalg SHA1withRSA -keystore D:/bea102/wlserver_10.0/samples/domains/wl_server/keystores/Identity.jks -storepass weblogic -rfc</pre>
  </div>
</p>

<p></p>

<p>&#160;</p>

<h3>Server Configuration</h3>

<p>Some administrative configuration is required in the console to load the certificate into the trusted certificate chain and to tell the web services security stack to do identity propagation when X.509 tokens are found.</p>

<p>WebLogic ships with a DemoTrust keystore that can be used for testing purposes.&#160; Again, for production domains, you would want to not use the DemoTrust keystore, but it works well for prototyping the configuration steps.&#160; Here is how I imported the certificate into the keystore.</p>

<p></p>

<p>
  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">keytool -v -import -trustcacerts -alias testalias -file testalias.pem -keystore D:/bea102/wlserver_10.0/server/lib/DemoTrust.jks -keypass DemoTrustKeyStorePassPhrase -noprompt</pre>
  </div>
</p>

<p></p>

<p>Web Service Security Configuration for the domain is also required.&#160; Follow the <a href="http://edocs.bea.com/wls/docs100/ConsoleHelp/taskhelp/webservices/webservicesecurity/CreateDefaultWSSConfig.html">console configuration instructions here</a>.&#160; Then <a href="http://edocs.bea.com/wls/docs100/ConsoleHelp/taskhelp/webservices/webservicesecurity/UseX509ForIdentity.html">follow the instructions here</a> to configure the identity propagation with a Token Handler.&#160; Note that one of the steps will specify that we are using the CN attribute to map to the user name in LDAP.</p>

<p>If you have not already done so, create a user.</p>

<p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingX509forIdentityPropagationinWLS10We_A7D3/users%20%5B2%5D_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="391" alt="users [2]" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingX509forIdentityPropagationinWLS10We_A7D3/users%20%5B2%5D_thumb.jpg" width="644" border="0" /></a> </p>

<h3>Server-side JWS Programming</h3>

<p>In order to require authentication on a web service, you need only specify a policy via an annotation in the JWS file.&#160; WLS ships with a policy inside the weblogic.jar file known as Auth.xml (as well as Sign.xml and Encrypt.xml which are <a href="http://dev2dev.bea.com/pub/a/2007/06/securing-web-services.html">explained in the earlier article</a> I mentioned).&#160; Here is a simple JWS file that shows how to attach that policy.&#160; This will require all users calling the time operation to be authenticated.&#160; Use the context object to retrieve the identity principal used to validate that we are indeed using an authenticated user.</p>

<p></p>

<p>
  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">package com.bea.sample.webservice; 

import java.util.Date; 

import javax.jws.WebMethod;
import javax.jws.WebService; 

import weblogic.jws.Context;
import weblogic.jws.Policies;
import weblogic.jws.Policy;
import weblogic.wsee.jws.JwsContext; 

@WebService
<span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Auth { 

    @Context
      <span style="color: #0000ff">private</span> JwsContext ctx;
      @WebMethod
      @Policies({
        @Policy(uri = <span style="color: #006080">&quot;policy:Auth.xml&quot;</span>, direction=Policy.Direction.inbound )})
    <span style="color: #0000ff">public</span> String time() 
    {
        <span style="color: #0000ff">return</span> <span style="color: #006080">&quot;User &quot;</span> + ctx.getCallerPrincipal() + <span style="color: #006080">&quot; &quot;</span> + (<span style="color: #0000ff">new</span> Date().toString());
    }
}</pre>
  </div>
</p>

<p></p>

<h3>Client-side JAX-RPC Programming</h3>

<p>The normal way to generate JAX-RPC clients provided by BEA is to use <a href="http://edocs.bea.com/wls/docs100/webserv_ref/anttasks.html#wp1039270">clientgen</a>.&#160; In this case we need to add a special parameter generatePolicyMethods=&quot;true&quot; to indicate that policy is being used and generate extra methods on the stubs that are created.&#160; Here is the snippet from the build.xml file for ant that generates the client code.</p>

<p></p>

<p>
  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&lt;target name=<span style="color: #006080">&quot;run-clientgen&quot;</span> depends=<span style="color: #006080">&quot;clean&quot;</span>&gt;
   &lt;taskdef name=<span style="color: #006080">&quot;clientgen&quot;</span> classname=<span style="color: #006080">&quot;weblogic.wsee.tools.anttasks.ClientGenTask&quot;</span> classpathref=<span style="color: #006080">&quot;compile.classpath&quot;</span> /&gt;

   &lt;mkdir dir=<span style="color: #006080">&quot;${build.dir}&quot;</span>/&gt;

   &lt;clientgen
      wsdl=<span style="color: #006080">&quot;${wsdl.dir}/${project.name}.wsdl&quot;</span>
      packageName=<span style="color: #006080">&quot;${client.package.prefix}.security.http.x509certbst.standalone.stub&quot;</span>
      destDir=<span style="color: #006080">&quot;${build.dir}&quot;</span>
      generatePolicyMethods=<span style="color: #006080">&quot;true&quot;</span>
   /&gt;

   &lt;javac
      srcdir=<span style="color: #006080">&quot;${build.dir}&quot;</span>
      destdir=<span style="color: #006080">&quot;${build.dir}&quot;</span>
      source=<span style="color: #006080">&quot;1.5&quot;</span>
   &gt;
      &lt;include name=<span style="color: #006080">&quot;test/**/*.java&quot;</span>/&gt;
      &lt;classpath&gt;
         &lt;path refid=<span style="color: #006080">&quot;compile.classpath&quot;</span>/&gt;
      &lt;/classpath&gt;
   &lt;/javac&gt;

   &lt;delete file=<span style="color: #006080">&quot;${lib.dir}/${client.jar.name}Client.jar&quot;</span>/&gt;
   &lt;mkdir dir=<span style="color: #006080">&quot;${lib.dir}&quot;</span>/&gt;

   &lt;jar destfile=<span style="color: #006080">&quot;${lib.dir}/${client.jar.name}Client.jar&quot;</span>&gt;
      &lt;fileset dir=<span style="color: #006080">&quot;${build.dir}&quot;</span>&gt;
         &lt;include name=<span style="color: #006080">&quot;**/*.*&quot;</span>/&gt;
         &lt;exclude name=<span style="color: #006080">&quot;**/*.java&quot;</span>/&gt;
      &lt;/fileset&gt;
   &lt;/jar&gt;
&lt;/target&gt;</pre>
  </div>
</p>

<p></p>

<p>The JAX-RPC client code specifies the policy that indicates which certificate to use for x509 identity propagation.&#160; It is different from just using the policy attached to the WSDL on the server-side because we need to give some guidance to the web service stack on the client as to how to embed the identity.&#160; Notice how we specify the CN=secuser in the TokenIssuer element.&#160; I have not included the policy element to sign the body to lower the overhead of the web service invocation.&#160; It is a trade-off of additional security versus performance.</p>

<p></p>

<p>
  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&lt;wsp:Policy wsu:Id=<span style="color: #006080">&quot;WSSEX509CertificateTokenPolicy.xml&quot;</span>
  xmlns:wsp=<span style="color: #006080">&quot;http://schemas.xmlsoap.org/ws/2004/09/policy&quot;</span>
  xmlns:wsu=<span style="color: #006080">&quot;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd&quot;</span>
  xmlns:wssp=<span style="color: #006080">&quot;http://www.bea.com/wls90/security/policy&quot;</span>
&gt;
   &lt;wssp:Identity&gt;
      &lt;wssp:SupportedTokens&gt;
         &lt;wssp:SecurityToken TokenType=<span style="color: #006080">&quot;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3&quot;</span>/&gt;
      &lt;/wssp:SupportedTokens&gt;
   &lt;/wssp:Identity&gt;
   &lt;wssp:Integrity xmlns:wls=<span style="color: #006080">&quot;http://www.bea.com/wls90/security/policy/wsee#part&quot;</span>&gt;
      &lt;wssp:SignatureAlgorithm URI=<span style="color: #006080">&quot;http://www.w3.org/2000/09/xmldsig#rsa-sha1&quot;</span>/&gt;
      &lt;wssp:CanonicalizationAlgorithm URI=<span style="color: #006080">&quot;http://www.w3.org/2001/10/xml-exc-c14n#&quot;</span>/&gt;
      &lt;wssp:Target&gt;
         &lt;wssp:DigestAlgorithm URI=<span style="color: #006080">&quot;http://www.w3.org/2000/09/xmldsig#sha1&quot;</span>/&gt;
         &lt;wssp:MessageParts Dialect=<span style="color: #006080">&quot;http://www.bea.com/wls90/security/policy/wsee#part&quot;</span>
         &gt;wls:SecurityHeader(wsu:Timestamp)&lt;/wssp:MessageParts&gt;
      &lt;/wssp:Target&gt;
      &lt;wssp:SupportedTokens&gt;
         &lt;wssp:SecurityToken IncludeInMessage=<span style="color: #006080">&quot;true&quot;</span> TokenType=<span style="color: #006080">&quot;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3&quot;</span>&gt;
            &lt;wssp:TokenIssuer&gt;CN=secuser&lt;/wssp:TokenIssuer&gt;
         &lt;/wssp:SecurityToken&gt;
      &lt;/wssp:SupportedTokens&gt;
   &lt;/wssp:Integrity&gt;
   &lt;wssp:MessageAge Age=<span style="color: #006080">&quot;300&quot;</span>/&gt;
&lt;/wsp:Policy&gt;</pre>
  </div>
</p>

<p></p>

<p>Inside the Client.java file that makes use of the generated JAX-RPC classes from clientgen, simply specify the policy file in the constructor for the port.</p>

<p></p>

<p>
  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">AuthService_Impl service = <span style="color: #0000ff">new</span> AuthService_Impl();

Auth port = service.getAuthSoapPort(
    Thread.currentThread().getContextClassLoader().getResourceAsStream(_properties.getProperty(<span style="color: #006080">&quot;helloworld.http.x509certbst.WSPolicyFile&quot;</span>)),
    <span style="color: #0000ff">true</span>,
    <span style="color: #0000ff">false</span>
);</pre>
  </div>
</p>

<p></p>

<p>There is also some special code required to set up reading from the keystore.&#160; I've commented out some code that illustrates how we would inject a Username token if we were using that approach instead.</p>

<p></p>

<p>
  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">List&lt;CredentialProvider&gt; credProviders = <span style="color: #0000ff">new</span> ArrayList&lt;CredentialProvider&gt;();

CredentialProvider cp = <span style="color: #0000ff">new</span> ClientBSTCredentialProvider(
    _properties.getProperty(<span style="color: #006080">&quot;helloworld.http.x509certbst.IdentityKeyStore&quot;</span>),
    _properties.getProperty(<span style="color: #006080">&quot;helloworld.http.x509certbst.IdentityKeyStorePassword&quot;</span>),
    _properties.getProperty(<span style="color: #006080">&quot;helloworld.http.x509certbst.IdentityKeyAlias&quot;</span>),
    _properties.getProperty(<span style="color: #006080">&quot;helloworld.http.x509certbst.IdentityKeyPassword&quot;</span>)
);

credProviders.add(cp);        

<span style="color: #008000">/*</span>
<span style="color: #008000">CredentialProvider cp = new ClientUNTCredentialProvider(</span>
<span style="color: #008000">        _properties.getProperty(&quot;helloworld.http.passwordunt.username&quot;).getBytes(),</span>
<span style="color: #008000">        _properties.getProperty(&quot;helloworld.http.passwordunt.password&quot;).getBytes()</span>
<span style="color: #008000">    );</span>
<span style="color: #008000">credProviders.add(cp);</span>
<span style="color: #008000">*/</span>
authStub._setProperty(
    WSSecurityContext.CREDENTIAL_PROVIDER_LIST,
    credProviders
);

authStub._setProperty(
    WSSecurityContext.TRUST_MANAGER,
    <span style="color: #0000ff">new</span> TrustManager()
    {
        <span style="color: #0000ff">public</span> boolean certificateCallback(X509Certificate[] chain, <span style="color: #0000ff">int</span> validateErr)
        {
            <span style="color: #0000ff">return</span> <span style="color: #0000ff">true</span>;
        }
    }
);</pre>
  </div>
</p>

<p></p>

<p>When you run the client, you should see output like this if everything is working correctly.</p>

<p></p>

<p>
  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">[Client.Client()]: Attempting to load .properties file from JAXRPCClients.properties
[Client.Client(String)]: JAXRPCClients.properties was loaded successfully.
[Client.time()]: response.getStringParameter()=User secuser Mon Apr 28 17:26:26 CDT 2008
[Client.example()]: Elapsed milliseconds: 1141</pre>
  </div>
</p>

<p></p>

<p>If you encounter problems, then you can enable verbose debugging on both the client and server side by specifying the JVM argument -Dweblogic.wsee.verbose=* which will output to the standard out all the details over the web service requests and responses.</p>

<p>I have attached my Eclipse-based <a href="http://dev2dev.bea.com/blog/jbayer/WebServiceSecurityProjects.zip">Workshop Studio projects</a> from the WebLogic Portal 10.2 download to the site if you would like to try it out yourself.&#160; You may have to adjust some of the project settings to adjust the location of webservicesclient.jar and add the weblogic.jar to the ant classpath to generate the client.&#160; Hopefully my experiences with this simple prototype will benefit you.</p>]]>
        
    </content>
</entry>
<entry>
    <title>Playing with Workshop and the Dojo Ajax Framework</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2008/03/playing_with_wo.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2008/03/playing_with_wo.html</id>
    
    <published>2008-03-23T23:04:44Z</published>
    <updated>2008-03-23T23:19:33Z</updated>
    
    <summary>I have been Inspired by the recent article by Gary Horen called &quot;Ajax programming with BEA Workshop&quot; and the numerous blogs from Skip Sauls that have touched on JSON and Firefox plug-ins like Firebug and YSlow.  I decided to try using what I perceive to be the most popular javascript framework, Dojo, to solve a relatively simple requirement from one of my customers to populate the options of a select drop-down based on the selection of another drop-down without refreshing the page.  For example, the options in the City drop-down will be populated based on the user&apos;s selection of an option in the State drop-down.</summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: BEA Workshop Product Family" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<p>I have been Inspired by the recent article by <a href="http://dev2dev.bea.com/pub/au/3430">Gary Horen</a> called &quot;<a href="http://dev2dev.bea.com/pub/a/2008/03/ajax-with-bea-workshop.html">Ajax programming with BEA Workshop</a>&quot; and the numerous blogs from <a href="http://dev2dev.bea.com/blog/skip/">Skip Sauls</a> that have touched on JSON and Firefox plug-ins like Firebug and YSlow.&#160; I decided to try using what I perceive to be the most popular javascript framework, <a href="http://dojotoolkit.org/">Dojo</a>, to solve a relatively simple requirement from one of my customers to populate the options of a select drop-down based on the selection of another drop-down without refreshing the page.&#160; For example, the options in the City drop-down will be populated based on the user's selection of an option in the State drop-down.&#160; Here's a look at the finished example.</p>  <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/PlayingwithWorkshopandtheDojoAjaxFramewo_F103/state_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="123" alt="state" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/PlayingwithWorkshopandtheDojoAjaxFramewo_F103/state_thumb.jpg" width="244" border="0" /></a> </p>  <p>The State drop-down is the only one available, the City and the Submit button are disabled.</p>  <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/PlayingwithWorkshopandtheDojoAjaxFramewo_F103/stateSelect_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="123" alt="stateSelect" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/PlayingwithWorkshopandtheDojoAjaxFramewo_F103/stateSelect_thumb.jpg" width="244" border="0" /></a> </p>  <p>This is not a normal html select, it is a Dijit FilteringSelect that has enhanced capabilities, such as type-ahead, and the user selects a state.</p>  <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/PlayingwithWorkshopandtheDojoAjaxFramewo_F103/selectCity%20%5B2%5D_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="120" alt="selectCity [2]" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/PlayingwithWorkshopandtheDojoAjaxFramewo_F103/selectCity%20%5B2%5D_thumb.jpg" width="244" border="0" /></a> </p>  <p>Once a state is selected, the list of cities is populated and is now enabled.</p>  <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/PlayingwithWorkshopandtheDojoAjaxFramewo_F103/submit_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="120" alt="submit" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/PlayingwithWorkshopandtheDojoAjaxFramewo_F103/submit_thumb.jpg" width="244" border="0" /></a> </p>  <p>Once a user selects a city, the submit button is now enabled.&#160; This has all happened without a screen refresh and provides a better user experience.</p>  <h3>The Tools</h3>  <ol>   <li><a href="http://commerce.bea.com/products/workshop/workshop_prod_fam.jsp">BEA Workshop 10.2</a> </li>    <li><a href="http://www.aptana.com/studio">Aptana Studio</a> - Set of javascript plug-ins for Eclipse that among other things help with Javascript debugging </li>    <li><a href="http://www.mozilla.com/en-US/firefox/">Firefox 2</a> </li>    <li><a href="https://addons.mozilla.org/en-US/firefox/addon/1843">Firebug</a> - Great Firefox plug-in for debugging client side issues </li>    <li><a href="http://dojotoolkit.org/downloads">Dojo 1.0.2</a> </li> </ol>  <h3></h3>  <h3>Getting Started</h3>  <p>The Workshop 10.2 projects used for this example (minus Dojo) are <a href="http://dev2dev.bea.com/blog/jbayer/AjaxDynamicSelectProjects.zip">available here</a>.&#160; Import the projects, extract Dojo 1.0.2 to the WebContent folder of the DynamicSelectWEB project and deploy the DynamicSelectEAR project to a server to get it up and running.&#160; This includes a city / state web service in the CitiesStatesWEB project that returns the city and state information.&#160; The ServiceControl in the DyanmicSelectWEB project is assuming that web service is deployed to localhost and port 7001, so make sure to adjust that if your server settings are different.</p>  <p>I could have tried using <a href="http://dojotoolkit.org/downloads">IceFaces</a>, an Ajax-enabled JSF framework, but I think it's important to get the fundamentals down before adding additional layers of complexity.&#160; So my first recommendation is to start simple with plain HTML and JSON files.&#160; Once you get the basics going, then add in the dynamic pieces (JSPs, etc).</p>  <p>The Dojo documentation has some excellent basic examples in the &quot;<a href="http://dojotoolkit.org/book/dojo-book-1-0">Book of Dojo 1.0</a>&quot;.&#160; After reading the of the form basics, particularly the <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/form-validation-specialized-input/select">FilteringSelect example</a>, I figured out the basic framework.&#160; Each FilteringSelect object has an attribute called a &quot;store&quot; that is responsible for holding data for the options.&#160; You can populate the store programmaticly in javascript, by invoking a URL that returns JSON, etc.&#160; The example uses a static <a href="http://dojotoolkit.org/files/states_0.txt">states.txt</a> file that shows what the JSON looks like and I use that as a basis for my purposes.&#160; It is easy to take the JSON response and create a new dojo.data.ItemFileReadStore and set the &quot;store&quot; value of the FilteringSelect to that new value without any complex parsing.&#160; I use the same json.jsp for populating both the cities and the states; and the action code in the pageflow just populates some lists for that jsp that can be reused to populate any select-based Dojo element.</p>  <p>Here's a look at how easy Dojo makes it to wire up events to javascript functions.&#160; This onLoad function gets called when the page loads via some javascript on the body tag.&#160; The &quot;states&quot;, &quot;cities&quot;, and &quot;myButton&quot; references are the id's of the DOM objects.&#160; &quot;onChange&quot; and &quot;onClick&quot; are the names of the events to register.&#160;&#160; &quot;onchange_states&quot;, &quot;onchange_cities&quot;, and &quot;button_click&quot; are the names of javascript functions to call respectively when those events occur.</p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">function</span> onLoad() {
  <span style="color: #0000ff">var</span> states = dijit.byId(<span style="color: #006080">&quot;states&quot;</span>);
  dojo.connect(states, <span style="color: #006080">&quot;onChange&quot;</span>, <span style="color: #006080">&quot;onchange_states&quot;</span>);
  
  <span style="color: #0000ff">var</span> cities = dijit.byId(<span style="color: #006080">&quot;cities&quot;</span>);
  dojo.connect(cities, <span style="color: #006080">&quot;onChange&quot;</span>, <span style="color: #006080">&quot;onchange_cities&quot;</span>);
  
  <span style="color: #0000ff">var</span> button = dijit.byId(<span style="color: #006080">&quot;myButton&quot;</span>);
  dojo.connect(button, <span style="color: #006080">&quot;onClick&quot;</span>, <span style="color: #006080">&quot;button_click&quot;</span>);
}</pre>
</div>

<p>Since Workshop has very nice Apache Beehive pageflow tooling, I just prototyped using that framework.&#160; Below is a look at my site-map.&#160; You can see how I started with a test.html file.&#160; Once I got that working, then I migrated the code over to the index.jsp and added in the dynamic elements.&#160; Each drop-down onChange calls a different pageflow action, that return dynamic JSON.&#160; You can see that in the getCities action, I'm passing the entire form.&#160; This way I can pull out the value of the selected state and only return the cities for that state.</p>

<p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/PlayingwithWorkshopandtheDojoAjaxFramewo_F103/pageflow%20%5B2%5D_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="225" alt="pageflow [2]" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/PlayingwithWorkshopandtheDojoAjaxFramewo_F103/pageflow%20%5B2%5D_thumb.jpg" width="449" border="0" /></a> </p>

<h3></h3>

<h3></h3>

<h3>Gotchas</h3>

<p>Take note of this css code that the FilteringSelect requires to display properly.&#160; I had to use this approach instead of the @import example used on the Dojo site due to an issue in one of the Eclipse plug-ins that caused a hang consistently.</p>

<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
  <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&lt;link rel=<span style="color: #006080">&quot;stylesheet&quot;</span> type=<span style="color: #006080">&quot;text/css&quot;</span> href=<span style="color: #006080">&quot;dojo-release-1.0.2/dijit/themes/tundra/tundra.css&quot;</span> /&gt;</pre>
</div>

<p>I decided to submit the form with a post when the state is selected since that is most likely how you would do more complex forms.&#160; Here's what that function looks like.</p>

<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
  <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">function</span> populate_cities()
{
  <span style="color: #0000ff">var</span> ajaxReq = {
          form: dojo.byId(<span style="color: #006080">&quot;myForm&quot;</span>),
          url: <span style="color: #006080">&quot;getCities.do&quot;</span>,
          handleAs:<span style="color: #006080">&quot;json-comment-filtered&quot;</span>,
          load: <span style="color: #0000ff">function</span>(response){
                  dijit.byId(<span style="color: #006080">'cities'</span>).store = <span style="color: #0000ff">new</span> dojo.data.ItemFileReadStore({data:response});  
          },
          error: <span style="color: #0000ff">function</span>(data){
                  alert(<span style="color: #006080">&quot;Holy Bomb Box, Batman!  An error occurred: &quot;</span> + data);
          },
          timeout: 2000
          };
  <span style="color: #008000">//dojo.xhrGet(ajaxReq);  //Servlet get argement with doGet</span>
  dojo.xhrPost(ajaxReq);  <span style="color: #008000">//Servlet get argement with doPost</span>
}</pre>
</div>

<p>I found that Dojo does this with a multi-part submission by default, so an extra annotation is necessary on the Pageflow to allow multi-part.</p>

<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
  <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">@Jpf.Controller(simpleActions = { @Jpf.SimpleAction(name = <span style="color: #006080">&quot;begin&quot;</span>, path = <span style="color: #006080">&quot;index.jsp&quot;</span>) }, multipartHandler=Jpf.MultipartHandler.memory )
<span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Controller extends PageFlowController {</pre>
</div>

<h3>Conclusion</h3>

<p>The Firebug plug-in is invaluable for debugging purposes.&#160; I found the Javascript debugging and the ability to look at the XHR request/response values to be particularly helpful.&#160; My example still has debugging turned on and to use this on a high-traffic site I would recommend turning that off and using some javascript compression.&#160; Check out <a href="http://dev2dev.bea.com/blog/skip/archive/2008/03/web_20_performa_2.html">Skip's recent post</a> for more detail on that.&#160; If you have had a better experience using a different javascript framework like prototype, DWR, IceFaces, etc please leave a comment.&#160; Overall Ajax programming is made easier with these frameworks and tools, but they are not quite as mature as what server-side java developers are used to, but they are getting there fast.</p>

<p>I had some ambitious plans to create a Workshop facet to add Dojo support to Dynamic Web projects, however that's going to be for another time.&#160; Check out <a href="http://dev2dev.bea.com/blog/editors/archive/2008/03/eclipsecon_2008.html">Konstantin's presentation</a> if you have curiosity about how to do that.</p>]]>
        
    </content>
</entry>
<entry>
    <title>Scala Development with Eclipse and WebLogic</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2008/02/scala_developme.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2008/02/scala_developme.html</id>
    
    <published>2008-02-07T02:57:31Z</published>
    <updated>2008-02-07T02:57:52Z</updated>
    
    <summary>At the end of my previous post about the hype/buzz for alternative programming languages I promised an entry on my experimenting with Scala in WebLogic.  I have only spent a few hours of weekend time playing around, so I can&apos;t say much yet, but I&apos;ll document some of my first impressions and experiences in this post.  This is not meant to be a post on learning Scala,.  It is a post that documents my experience of using Scala with tooling and an application server familiar to java developers in Eclipse and WebLogic Server.</summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: WebLogic Server" />
            <category term="Role: Architect" />
            <category term="Technology: Dev Toolbox" />
            <category term="Technology: Eclipse" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<p>At the end of <a href="http://dev2dev.bea.com/blog/jbayer/archive/2008/02/paparazzi_for_p.html">my previous post</a> about the hype/buzz for alternative programming languages I promised an entry on my experimenting with <a href="http://www.scala-lang.org/">Scala</a> in WebLogic.&nbsp; I have only spent a few hours of weekend time playing around, so I can't say much yet, but I'll document some of my first impressions and experiences in this post.&nbsp; This is not meant to be a post on learning Scala,&nbsp; For that I recommend an <a href="http://www.javaworld.com/podcasts/jtech/2007/120607jtech007.html">excellent podcast from Bill Venners</a> that goes into great detail about Scala and why you might use it.&nbsp; I highly recommend it, it is well-worth the listen.&nbsp; If you prefer reading, then start with <a href="http://www.ibm.com/developerworks/java/library/j-scala01228.html">The busy Java developer's guide to Scala: Functional programming for the object oriented</a>.&nbsp; This is a post that documents my experience of using Scala with tooling and an application server familiar to java developers, namely Eclipse and WebLogic Server.</p> <h3>Prequisites</h3> <ol> <li><a href="http://download.eclipse.org/webtools/downloads/drops/R2.0/R-2.0.1-20070926042742/">Download Eclipse 3.3 / WTP 2.0.1</a>.&nbsp; I used wtp-all-in-one-sdk-R-2.0.1.&nbsp; Workshop 10.0/10.1 are still based on Eclipse 3.2, so they won't work with the Scala Plugin for Eclipse, which requires 3.3.  <li>In order to easily deploy code to WLS, use Eclipse Update to install <a href="https://dev2devclub.bea.com/updates/wls-tools/">WebLogic Server Tools</a>, I used version 1.1.2 from update site <b><a href="https://dev2devclub.bea.com/updates/wls-tools/europa/">https://dev2devclub.bea.com/updates/wls-tools/europa/</a></b>  <li>Use Eclipse Update to install the <a href="http://www.scala-lang.org/downloads/eclipse/index.html">Scala Plugin for Eclipse</a>.&nbsp; I used version 2.6.5 from update site <a title="http://www.scala-lang.org/downloads/scala-plugin/" href="http://www.scala-lang.org/downloads/scala-plugin/">http://www.scala-lang.org/downloads/scala-plugin/</a></li></ol> <h3>Obligatory HelloWorld</h3> <p>After restarting Eclipse because of the new plug-ins, I didn't have to set any paths to configure the Scala Plugin as the set of 5 scala plugins installed include the Scala SDK.&nbsp; Simply follow the instructions at the bottom of the <a href="http://www.scala-lang.org/downloads/eclipse/index.html">Scala Plugin for Eclipse page</a> to create your first HelloWorld application to make sure that everything is wired up correctly.&nbsp; I did not encounter a single snag with HelloWorld at all and my console printed "HelloWorld" in no time flat.</p> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/ScalaDevelopmentwithEclipseandWebLogic_10CB7/ScalaHelloWorld_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="ScalaHelloWorld" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/ScalaDevelopmentwithEclipseandWebLogic_10CB7/ScalaHelloWorld_thumb.jpg" width="609" border="0"></a> </p> <h3>Interoperability with Java</h3> <p>The scalac compiler takes .scala files and builds .class files that have a dependency on the scala-library.jar.&nbsp; Go check out the bin directory in the Resource perspective and see for yourself.&nbsp; Therefore, the only thing you need to invoke and run them from java is to have the .class files and the scala-library.jar on your classpath.&nbsp; The converse is also true; Scala objects can just as easily invoke java objects by including them on the scala classpath.</p> <p>Now this is where the developer experience is not quite ideal with respect to the packaging scala artifacts to be used easily in Dynamic Web Projects for iterative development with WebLogic Server.&nbsp; First of all, I could not find a non-custom way of exporting the Scala .class files into a jar file.&nbsp; In order to package up my Scala Project into a jar with the IDE I had to:</p> <p>Right click on the project -&gt; Export... -&gt; General -&gt; Archive File -&gt; and select appropriate values as shown in multiple places.</p> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/ScalaDevelopmentwithEclipseandWebLogic_10CB7/ScalaJarExport_4.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="ScalaJarExport" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/ScalaDevelopmentwithEclipseandWebLogic_10CB7/ScalaJarExport_thumb_1.jpg" width="483" border="0"></a> </p> <p>Is this really that big of a deal?&nbsp; Well, it depends on how you use your IDE to develop.&nbsp; In the normal process of doing Java web development in the IDE, I find it convenient to have a project with Java code, say a Utility project, which is automatically included in your Dynamic Web Project's classpath and packaged up in the EAR as a jar when I do an export or a deployment.&nbsp; It doesn't appear that such a nice arrangement is possible using the default tooling.&nbsp; Of course you can always create a custom ant builder yourself and attach this to your project's build activity, but there is some work involved.&nbsp; Certainly this will be addressed as the Scala Plugin for Eclipse matures.</p> <p>Trying out some various alternatives, I was able to modify the .project xml file for the Scala project and add a Java nature and a java builder so that both .java source and .scala source were compiled into the same bin directory.&nbsp; This seemed a little fragile and the build order had to be just right in order for both sets of .class files to be in the bin directory after the build.&nbsp; I suspect that when the build order was reversed that the bin directory was being cleaned by one of the builders.&nbsp; Here is the .project file if you feel like taking this approach.</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 263px; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; height: 448px; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">="1.0"</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">="UTF-8"</span>?<span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;</span><span style="color: #800000">projectDescription</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">name</span><span style="color: #0000ff">&gt;</span>ScalaExamples<span style="color: #0000ff">&lt;/</span><span style="color: #800000">name</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">comment</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">comment</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">projects</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">projects</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">buildSpec</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">buildCommand</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">name</span><span style="color: #0000ff">&gt;</span>org.eclipse.jdt.core.javabuilder<span style="color: #0000ff">&lt;/</span><span style="color: #800000">name</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">arguments</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">arguments</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">buildCommand</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">buildCommand</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">name</span><span style="color: #0000ff">&gt;</span>ch.epfl.lamp.sdt.core.scalabuilder<span style="color: #0000ff">&lt;/</span><span style="color: #800000">name</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">arguments</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">arguments</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">buildCommand</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">buildSpec</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">natures</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">nature</span><span style="color: #0000ff">&gt;</span>ch.epfl.lamp.sdt.core.scalanature<span style="color: #0000ff">&lt;/</span><span style="color: #800000">nature</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">nature</span><span style="color: #0000ff">&gt;</span>org.eclipse.jdt.core.javanature<span style="color: #0000ff">&lt;/</span><span style="color: #800000">nature</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">natures</span><span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;/</span><span style="color: #800000">projectDescription</span><span style="color: #0000ff">&gt;</span>
</pre></div>
<p>&nbsp;</p>
<h3>Mix Scala with a Dynamic Web Application</h3>
<p>After deciding not to spend more time on the packaging issues I moved on to another basic concept, simply calling a Scala object from a JSP.&nbsp; In this case there is a suitable example <a href="http://www.scala-lang.org/docu/examples/files/addressbook.html">addressbook.scala</a> on the Scala site that spits out an addressbook in Xhtml.&nbsp; This example also showcases one of the Scala languages handy features of native XML support.&nbsp; Check out the source.&nbsp; In order to invoke this quickly from a JSP, I moved it to a package called <strong><font face="Courier New" size="2">examples</font></strong> and created a new function named toXhtml to the AddressBook class to return the Xhtml string since the example was meant to be called from a main method and needed the function to be callable from the JSP.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">def toXhtml(): <span style="color: #0000ff">String</span> = page.toString
</pre></div>
<p>Here is the index.jsp</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&lt;%@page import=<span style="color: #006080">"examples.addressbook"</span>%&gt;
&lt;%= addressbook.toXhtml() %&gt;</pre></div>
<p>The steps are:</p>
<ol>
<li>Package the addressbook classes in a jar and place into WEB-INF/lib 
<li>Copy the scala-library.jar into WEB-INF/lib (get this from the Scala SDK or from your plugin, mine is here: D:\eclipse3.3\eclipse\plugins\ch.epfl.lamp.sdt.compiler_2.6.9.RC412860\lib) 
<li>Create the JSP 
<li>Deploy to a server and invoke the jsp</li></ol>
<p>Here is the end result:</p>
<p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/ScalaDevelopmentwithEclipseandWebLogic_10CB7/scalaAddressbook_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="472" alt="scalaAddressbook" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/ScalaDevelopmentwithEclipseandWebLogic_10CB7/scalaAddressbook_thumb.jpg" width="644" border="0"></a> </p>
<h3>Summary</h3>
<p>There is nothing really WebLogic Server specific to this, I could have just as easily deployed this to Tomcat., or <a href="http://www.bea.com/eventserver/">WebLogic Event Server</a>.&nbsp; The point is that Scala actually is fairly easy to integrate into both tools and runtimes that most java developers will already be familiar with.&nbsp; If you have thoughts on Scala, better integration with java IDE's, etc, drop a comment.</p>]]>
        
    </content>
</entry>
<entry>
    <title>Paparazzi for Programming Languages</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2008/02/paparazzi_for_p.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2008/02/paparazzi_for_p.html</id>
    
    <published>2008-02-04T06:33:54Z</published>
    <updated>2008-02-04T06:37:31Z</updated>
    
    <summary>Have you noticed that there is a growing buzz about alternative programming languages in the blogosphere and online technical journals?  Is this simply just US-Weekly for technology selling the latest Brangelina gossip that will be forgotten next week or is there really a coming revolution to get out in front of or even catch up with?</summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: WebLogic Server" />
            <category term="Role: Architect" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<h3></h3> <p>Have you noticed that there is a growing buzz about alternative programming languages in the blogosphere and online technical journals?&nbsp; Is this simply just US-Weekly for technology selling the latest Brangelina gossip that will be forgotten next week or is there really a coming revolution to get out in front of or even catch up with?</p> <h3>The Old Standbys</h3> <p>PHP and Perl have been popular Internet languages for some time and there is a history of using these languages in conjunction with the WebLogic Server (See WLS information about <a href="http://dev2dev.bea.com/pub/a/2007/02/php-java-bridge.html">PHP</a>, <a href="http://www.bea.com/framework.jsp?CNT=index.htm&amp;FP=/content/products/weblogic/bluedragon/">ColdFusion</a>, and <a href="http://edocs.bea.com/wls/docs100/webapp/configureresources.html#wp159131">CGI</a>).&nbsp;&nbsp; Even JavaScript&nbsp; / ECMAScript is <a href="http://www.tonotono.net/ua/nph-.cgi/000000A/http/www.onjava.com/pub/a/onjava/2006/04/26/mustang-meets-rhino-java-se-6-scripting.html">getting integrated into the JVM</a> in Java 6.</p> <h3>The New Popular Kids</h3> <p>Lately a newer set of languages have been getting all the attention in both the <a href="http://www.infoq.com/news/2008/01/why-scala">Java world</a> and the <a href="http://www.hanselman.com/blog/WhyWouldANETProgrammerLearnRubyOnRails.aspx">.NET world</a>.&nbsp; Of course you've heard about <a href="http://www.ruby-lang.org">Ruby</a> and <a href="http://www.rubyonrails.org/">Ruby on Rails</a> unless you've been under a rock.&nbsp; Java has responded with it's own scripting language, <a href="http://groovy.codehaus.org/">Groovy</a> and rails like framework called <a href="http://grails.codehaus.org/">Grails</a>.&nbsp; Presumably Groovy and Grails would be more applicable to enterprise developers because of Java roots and higher likelihood of being accessible to Java developers to learn quickly.&nbsp; Secondly, because Groovy is interoperable with existing java code, it can run on your corporate application server standard, which is of the utmost importance for enterprise adoption.&nbsp; There is also <a href="http://jruby.codehaus.org/">JRuby</a>; so you can mix Java and Ruby and not have to give up WLS container provided services and all of those plentiful java API's you have lying around from existing applications, frameworks, and packaged applications.&nbsp; Not to be left-out, functional programming fans have also have a reason to get excited with <a href="http://www.scala-lang.org">Scala</a> and <a href="http://research.microsoft.com/fsharp/fsharp.aspx">F#</a>, which combine elements of OO languages with functional principles.&nbsp; Even <a href="http://en.wikipedia.org/wiki/Erlang_%28programming_language%29">ERLang</a> is getting some hype.&nbsp; </p> <h3>Why all the buzz and what to do about it?</h3> <p>The rationale to use these alternate languages seems to vary, but the most substantive reasons seem to center around <a href="http://www.hanselman.com/blog/TheWeeklySourceCode13FibonacciEdition.aspx">brevity, clarity (see the Fibonacci examples),</a> and that they are <a href="http://www.theserverside.com/tt/articles/article.tss?l=IntegratingJavaandErlang">better for taking advantage of concurrent programming</a> on the <a href="http://www.it-director.com/technology/content.php?cid=10233">growing number of multi-core architectures</a>.&nbsp; So as an enterprise Java developer and WebLogic Server user how are you to know which of these technologies is the most relevant?&nbsp; In my humble opinion, it's too early to declare definitive winners.&nbsp; I don't think that brevity alone can be responsible for a seismic shift.&nbsp; I am personally more swayed by the multi-core / concurrent programming arguments, but I don't feel the urgency immediately.&nbsp; I think these are technologies to monitor and dip your toe in, but not necessarily to dive all the way in unless you have an edge case that is in the sweet spot in one of the languages.</p> <p>I am definitely bullish on the value of the application server and the rock-solid foundation provided by WebLogic Server.&nbsp; I feel that the new languages that will have the best synergy with existing Java assets will have the highest likelihood of success.&nbsp; I've spent a limited amount of time playing with Scala this weekend and deployed an example in WLS.&nbsp; Look for my write-up on this in an upcoming entry if you want to hear about my experiences.&nbsp; If you have an opinion on future programming language adoption in the enterprise, please leave a comment.</p>]]>
        
    </content>
</entry>
<entry>
    <title>Workshop, JPA, and DataSources</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2008/01/workshop_jpa_an.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2008/01/workshop_jpa_an.html</id>
    
    <published>2008-01-26T07:35:32Z</published>
    <updated>2008-01-26T07:40:41Z</updated>
    
    <summary><![CDATA[One of my customers is evaluating JPA as a persistence framework for a new project and using Workshop 10.1 for development and WebLogic Server 10.0 MP1 for a target runtime.&nbsp; They had some trouble figuring out how to configure JPA...]]></summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: BEA Workshop Product Family" />
            <category term="Product: WebLogic Server" />
            <category term="Technology: EJB" />
            <category term="Technology: Persistence" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<p>One of my customers is evaluating JPA as a persistence framework for a new project and using Workshop 10.1 for development and WebLogic Server 10.0 MP1 for a target runtime.&nbsp; They had some trouble figuring out how to configure JPA to use WebLogic managed DataSources instead of using a direct OpenJPA managed connection.&nbsp; In this entry, I'll illustrate how to specify JNDI DataSources in persistence.xml.</p> <h3></h3> <h3></h3> <h3>Default behavior is direct connection</h3> <p>In Workshop 10.1, when you right click on a table in DbXplorer and select "Generate JPA Mapping...", and target a Web project with JPA facets, Workshop will add the connection information from DbXplorer to the persistence.xml file that uses the direction connection method.&nbsp; Here's an example of the output for one class called Supplier.&nbsp; Notice that the direct connection is used and the password is embedded in the file.&nbsp; This might be ok for development, but this might raise some eyebrows if left unchecked for production.</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">="1.0"</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">="UTF-8"</span>?<span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;</span><span style="color: #800000">persistence</span> <span style="color: #ff0000">xmlns</span><span style="color: #0000ff">="http://java.sun.com/xml/ns/persistence"</span>
    <span style="color: #ff0000">xmlns:xsi</span><span style="color: #0000ff">="http://www.w3.org/2001/XMLSchema-instance"</span>
    <span style="color: #ff0000">xsi:schemaLocation</span><span style="color: #0000ff">="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"</span>
    <span style="color: #ff0000">version</span><span style="color: #0000ff">="1.0"</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">persistence-unit</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="pu"</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">class</span><span style="color: #0000ff">&gt;</span>com.test.supplier.jpa.Supplier<span style="color: #0000ff">&lt;/</span><span style="color: #800000">class</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">properties</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="openjpa.TransactionMode"</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">="local"</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="openjpa.ConnectionDriverName"</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">="oracle.jdbc.driver.OracleDriver"</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="openjpa.ConnectionURL"</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">="jdbc:oracle:thin:@localhost:1521:XE"</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="openjpa.ConnectionUserName"</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">="weblogic"</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="openjpa.ConnectionPassword"</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">="weblogic"</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="openjpa.jdbc.Schema"</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">="WEBLOGIC"</span><span style="color: #0000ff">/&gt;</span>
        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">properties</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">persistence-unit</span><span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;/</span><span style="color: #800000">persistence</span><span style="color: #0000ff">&gt;</span></pre></div>
<h3>Best practice - use container managed DataSources</h3>
<p>Instead of managing all of database connections separately in each application, it is a best practice to use container managed DataSources that are shared among applications.&nbsp; Here are two data-sources I have configured in the WLS console.</p>
<p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/WorkshopJPAandDataSources_1784/datasources_2.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="104" alt="datasources" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/WorkshopJPAandDataSources_1784/datasources_thumb.jpg" width="644" border="0"></a> </p>
<p>Using DataSources also has the added benefit of not requiring developers to have access to the database attributes, specifically the password.&nbsp; It turns out that the Workshop 10.1 JPA plug-in does not directly support specifying the JNDI name of the WebLogic DataSource in the GUI.&nbsp; Looking at the <a href="http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">persistence XSD file</a> or trying a code-completion in the persistence.xml file will show you that the persistent-unit element has a child element named jta-data-source that can be used for specifying the JNDI name.&nbsp; In fact, there is a second element as well, non-jta-data-source, which is also required if you want transactions to work properly with XA compliant DataSources.&nbsp; The OpenJPA documentation user-guide <a href="http://openjpa.apache.org/builds/1.0.1/apache-openjpa-1.0.1/docs/manual/ref_guide_dbsetup_thirdparty.html#ref_guide_dbsetup_thirdparty_enlist">does an excellent job explaining</a> this.</p>
<h3>Watch your step</h3>
<p>This is where I got tripped up.&nbsp; Unfortunately, there is a bug in Eclipse WTP which prevents the XML Validator from working properly in Web projects.&nbsp; Therefore, unless you are careful, you can accidentally place the DataSource elements in the incorrect place.&nbsp; Code-completion still works in the xml document, but it does not prevent you from making a mistake.&nbsp; In my case, I put the jta-data-source element after the class element.&nbsp; This results in an error at runtime such as: <font face="Courier New" size="2">persistence.xml [Location: Line: 8, C: 20]: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'jta-data-source'. One of '{"</font><a href="http://java.sun.com/xml/ns/persistence&quot;:class"><font face="Courier New" size="2">http://java.sun.com/xml/ns/persistence":class</font></a><font face="Courier New" size="2">, "</font><a href="http://java.sun.com/xml/ns/persistence&quot;:exclude-unlisted-classes"><font face="Courier New" size="2">http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes</font></a><font face="Courier New" size="2">, "</font><a href="http://java.sun.com/xml/ns/persistence&quot;:properties}'"><font face="Courier New" size="2">http://java.sun.com/xml/ns/persistence":properties}'</font></a><font face="Courier New" size="2"> is expected.</font></p>
<p>Once I put the data-source elements in the valid location, everything worked great at runtime (thank you <a href="http://dev2dev.bea.com/blog/pinaki.poddar/">Pinaki</a>!).&nbsp; Here is an example of a persistence.xml file that uses the two DataSources correctly and complies with the XSD.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">="1.0"</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">="UTF-8"</span>?<span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;</span><span style="color: #800000">persistence</span> <span style="color: #ff0000">xmlns</span><span style="color: #0000ff">="http://java.sun.com/xml/ns/persistence"</span>
    <span style="color: #ff0000">xmlns:xsi</span><span style="color: #0000ff">="http://www.w3.org/2001/XMLSchema-instance"</span>
    <span style="color: #ff0000">xsi:schemaLocation</span><span style="color: #0000ff">="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"</span>
    <span style="color: #ff0000">version</span><span style="color: #0000ff">="1.0"</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">persistence-unit</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="pu"</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">jta-data-source</span><span style="color: #0000ff">&gt;</span>OracleXADataSource<span style="color: #0000ff">&lt;/</span><span style="color: #800000">jta-data-source</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">non-jta-data-source</span><span style="color: #0000ff">&gt;</span>OracleDataSource<span style="color: #0000ff">&lt;/</span><span style="color: #800000">non-jta-data-source</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">class</span><span style="color: #0000ff">&gt;</span>com.test.supplier.jpa.Supplier<span style="color: #0000ff">&lt;/</span><span style="color: #800000">class</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">properties</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="openjpa.jdbc.DBDictionary"</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">="oracle(DriverVendor=oracle)"</span> <span style="color: #0000ff">/&gt;</span>
        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">properties</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">persistence-unit</span><span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;/</span><span style="color: #800000">persistence</span><span style="color: #0000ff">&gt;</span>

</pre></div>
<h3>Conclusion</h3>
<p>Hopefully the JPA tooling in Workshop will incorporate the JNDI data-source connection in a future release and incorporate a fix for validating xml files in Web projects.&nbsp; For more JPA blog entries, I highly encourage <a href="http://dev2dev.bea.com/blog/pinaki.poddar/">Pinaki's blog</a>.&nbsp; He's got lots of great JPA stuff.</p>]]>
        
    </content>
</entry>
<entry>
    <title>Hermes JMS - Open Source JMS Console</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2008/01/hermes_jms_open.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2008/01/hermes_jms_open.html</id>
    
    <published>2008-01-02T22:55:22Z</published>
    <updated>2008-01-02T22:55:38Z</updated>
    
    <summary>Hermes JMS can provide an improved user experience for monitoring, inspecting and copying jms messages.</summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: WebLogic Server" />
            <category term="Technology: JMS" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<p>The WebLogic Server Administration Console provides the ability to monitor and view JMS messages from 9.x onwards.&nbsp; However it is a web-based tool that is optimized for configuration, not monitoring and development testing.&nbsp; Looking at the contents of multiple messages requires multiple screen refreshes and it can not do some advanced JMS activities like copy messages from one queue to another very easily.&nbsp; <a href="http://hermesjms.com">Hermes JMS</a> is a handy open source project <a href="https://sourceforge.net/project/showfiles.php?group_id=61713">hosted by Sourceforge</a> and built by Colin Crist that can be used to monitor, inspect, and interact with JMS Queues, Topics, and Messages.&nbsp; Here's how Colin describes it on the website:</p> <blockquote> <p>HermesJMS is an <a href="http://hermesjms.com/confluence/display/HJMS/Python">extensible console</a> that helps you interact with JMS providers making it easy to browse or search queues and topics, copy messages around and delete them. It fully integrates with JNDI letting you discover administered objects stored, create JMS sessions from the connection factories and use any destinations found. Many providers include a plugin that uses the native API to do non-JMS things like getting queue depths (and other statistics) or finding queue and topic names.</p></blockquote> <p>It works with many of the popular JMS providers such as Active MQ, Arjuna MQ, Tibco EMS, Fiorano MQ, JBoss MQ, JORAM, OpenJMS, Oracle, Pramati, SAP, SeeBeyond ICAN, SeeBeyond JCAPS, Sonic MQ, WebLogic JMS, WebMethods, and WebSphere MQ. This post will explain how to get Hermes installed and configured for use with WebLogic JMS.&nbsp; If you would like to see the setup with WebLogic as a web recording, <a href="http://hermesjms.com/demos/ConfigureHermesWithWLS.html">go here</a>, otherwise read on for the step-by-step.&nbsp; </p> <p>If you work in the financial vertical, Hermes also <a href="http://www.hermesjms.com/demos/hermes-fix.html">has some capabilities with FIX</a> messages that are worth checking out.</p> <h3>Quick setup</h3> <p>To install, get the installer from sourceforge and run “java –jar hermes-installer-1.12.jar” in the directory where you have placed the installer jar.  <ol> <li>Open the &lt;HERMES_HOME&gt;/bin/hermes.bat or hermes.sh in your favorite editor. Add the path to your WLS JVM at the beginning of the file right after the REM comments.&nbsp; <em>Note: When I tested with the WLS 10.3 Tech Preview, I had to use the Java 6 JVM that shipped with the tech preview, so if you run into issues in the "discovery" phase, be sure to use the same JVM with Hermes as the WLS JVM you want to connect to.</em></li></ol> <blockquote> <p><font face="Courier New" size="2">set PATH=D:\bea922\jdk150_10\jre\bin<br>set JAVA_HOME=D:\bea922\jdk150_10\jre</font></p></blockquote> <ol start="2"> <li>Launch Hermes by calling the hermes.bat  <li>Right click on “sessions” and select “new -&gt; New session…”.  <li>On the resulting prompt, go to the “providers” tab at the bottom and add a “group” called “weblogic92” and a “library” specifying your path to weblogic.jar. Select “Don’t Scan” when prompted. </li></ol> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/HermesJMSOpenSourceJMSConsole_EE23/clip_image002_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="164" alt="clip_image002" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/HermesJMSOpenSourceJMSConsole_EE23/clip_image002_thumb.jpg" width="304" border="0"></a>  <ol start="6"> <li>No go back to the “Sessions” tab. Enter a name for the session, in this case “examplesQCF”. In the “Connection Factory” section, select “weblogic92” for the loader (you may have to save and then edit the session to see the provider you just configured in the drop down for loader). Then select “BEA WebLogic” for the “Plug In” dropdown. Then add the properties as in the image below select “OK”. </li></ol> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/HermesJMSOpenSourceJMSConsole_EE23/clip_image004_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="425" alt="clip_image004" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/HermesJMSOpenSourceJMSConsole_EE23/clip_image004_thumb.jpg" width="304" border="0"></a>  <ol start="7"> <li>Right click on the newly created “examplesQCF” session and select Discover. It should find all of the available destinations and list them under the examplesQCF session. </li></ol> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/HermesJMSOpenSourceJMSConsole_EE23/clip_image006_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="241" alt="clip_image006" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/HermesJMSOpenSourceJMSConsole_EE23/clip_image006_thumb.jpg" width="244" border="0"></a>  <ol start="8"> <li>If you right click on the exampleQueue node under the session and select “Browse”, you should be able to see the contents of the queue. I have populated my exampleQueue with 3 messages. The first of which has a message payload of “Test Message”. Notice the headers are also displayed. </li></ol> <p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="224" alt="clip_image008" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/HermesJMSOpenSourceJMSConsole_EE23/clip_image008_thumb.jpg" width="604" border="0">  <p>Hermes can monitor multiple queues at once, auto-refresh, use selectors, delete messages, etc. Check out the user guide at <a href="http://www.hermesjms.com/">http://www.hermesjms.com</a> for more information and tutorials. </p>]]>
        
    </content>
</entry>
<entry>
    <title>Using Workshop 10.1 with WebLogic Server 10.0 MP1</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2007/12/using_workshop.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2007/12/using_workshop.html</id>
    
    <published>2007-12-15T18:50:34Z</published>
    <updated>2007-12-21T23:45:38Z</updated>
    
    <summary>Workshop for WebLogic 10.1 ships with WebLogic Server 10.0 GA bundled in the installer.  Since that time BEA has released Maintenance Pack 1 for WLS 10.0.  So when one of my customers was getting started with developing on WebLogic Server 10.0, I recommended that they start with Server 10.0 MP1 because it has about 7 months worth of bug fixes that the 10.0 GA bits don&apos;t have.  This entry details how to use them together.</summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: BEA Workshop Product Family" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<h3></h3> <h3>Background</h3> <p>Workshop for WebLogic 10.1 ships with WebLogic Server 10.0 GA bundled in the installer.&nbsp; Since that time BEA has released Maintenance Pack 1 for WLS 10.0.&nbsp; So when one of my customers was getting started with developing on WebLogic Server 10.0, I recommended that they start with Server 10.0 MP1 because it has about 7 months worth of bug fixes that the 10.0 GA bits don't have.&nbsp; Now this customer also wanted to take advantage of all of the great features that first showed up in Workshop 10.1, such as JSF, JPA, Hibernate, Struts, Spring, Beehive tooling all nicely assembled in Eclipse.&nbsp; After talking with Workshop product management, I realized that there are no plans to update the Workshop 10.1 installer to include the WebLogic Server 10.0 MP1 bits.&nbsp; You can still use Workshop 10.1 to deploy to Server 10.0 MP1, but there are some caveats.</p> <p>Expectation:&nbsp; I should just be able to update the WebLogic Server 10.0 GA instance to MP1 by using SmartUpdate.&nbsp; Theoretically yes, but not in this case.&nbsp; The WebLogic Server 10.0 GA bits that are included with the default Workshop 10.1 installation are there just to support Workshop and are not able to be upgraded because Workshop 10.1 has not been updated itself for MP1.</p> <p>Disclaimer:&nbsp; Note that this configuration (deploying from Workshop 10.1 to Server 10.0 MP1) has not been explicitly tested by our support teams.&nbsp; I've found most use-cases work just fine.&nbsp; I've noted several gotchas below, but be aware that this has not gone through an extensive QA.</p> <h3>The installation steps</h3> <p><a href="http://commerce.bea.com/showallversions.jsp?family=WLW">Workshop 10.1 Installer</a></p> <p>Choose the "complete" installation.</p> <p><font color="#ff0000"><strong>*Updated 12/21/07*</strong> Do not choose the custom installation!&nbsp; Choose "Complete".&nbsp; It turns out that Workshop 10.1 does have dependences on the Server 10.0 GA bits, so it's best to leave the defaults selected and install both Workshop 10.1 and Server 10.0 GA into the same BEA Home.&nbsp; You can still install Server 10.0 MP1 into a different BEA Home without its Workshop 10.0 MP1 components as I show further below.&nbsp; One of the things that will not work if Workshop 10.1 is installed without Server 10.0 GA in its BEA Home is deploying an application with EJBs to WebLogic Server from Workshop.&nbsp; Reference CR356168 with BEA Support if you encounter troubles in this regard.</font></p> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingWorkshop10.1withWebLogicServer.0MP1_C03E/complete.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="291" alt="complete" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingWorkshop10.1withWebLogicServer.0MP1_C03E/complete_thumb.jpg" width="404" border="0"></a> </p> <p>&nbsp;</p> <p>Now <a href="http://commerce.bea.com/showproduct.jsp?family=WLS&amp;major=10&amp;minor=1">install Server 10.0 MP1</a> into a new BEA_HOME directory.</p> <p>Select the custom installation, and make sure you install into a separate BEA_HOME directory from Workshop 10.1.</p> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingWorkshop10.1withWebLogicServer.0MP1_C03E/server1.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="289" alt="server1" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingWorkshop10.1withWebLogicServer.0MP1_C03E/server1_thumb.jpg" width="404" border="0"></a> </p> <p>Deselect the Workshop 10.0 components if you do not plan on using Workshop 10.0 MP1, but it doesn't harm anything other than take up disk space if you leave it selected.</p> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingWorkshop10.1withWebLogicServer.0MP1_C03E/server2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="289" alt="server2" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingWorkshop10.1withWebLogicServer.0MP1_C03E/server2_thumb.jpg" width="404" border="0"></a> </p> <h3>Post-installation Configuration</h3> <p>At this point, I recommend changing the default JVM that Workshop will use to be the more recent Sun JDK that ships with Server 10 MP1.&nbsp; I'll address this later, but it follows from the infamous <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267224">serialVersionUID bug</a> that has been around in the Sun JVM for awhile.&nbsp; Open Workshop's ini file (mine is D:\Workshop10.1\workshop_10.1\workshop4WP\workshop4WP.ini) and point it to the updated JDK.</p> <p>Before:</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 46px; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 94.41%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; height: 52px; background-color: #f4f4f4; border-bottom-style: none"><p>-vm
D:/Workshop10.1/jdk150_06/jre/bin/javaw.exe</p><p>etc, etc.</p></pre></div>
<p>After:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; height: 66px; background-color: #f4f4f4; border-bottom-style: none"><p>-vm
D:/bea100MP1/jdk150_11/jre/bin/javaw.exe</p><p>etc, etc.</p></pre></div>
<p>Now you'll have both Workshop 10.1 and Server 10 MP1 installed on your machine, the next step is to configure Workshop 10.1 so that it is aware of the Server 10 runtime.&nbsp; Go ahead and open a workspace and select Window-&gt;Preferences...-&gt;Server-&gt;Installed Runtimes.&nbsp; Delete the existing 10.0 GA runtime and add the runtime for WebLogic Server 10 MP1.&nbsp; Normally I wouldn't have to do this step, but since we installed Workshop and Server separately we have to tell Workshop where to find Server and where the correct library modules are located.</p>
<p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingWorkshop10.1withWebLogicServer.0MP1_C03E/runtime.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="runtime" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingWorkshop10.1withWebLogicServer.0MP1_C03E/runtime_thumb.jpg" width="541" border="0"></a> </p>
<p>After we set that we should see that WebLogic-&gt;J2EE Libraries is now populated with the 10.0 MP1 libraries:</p>
<p><font color="#ff0000">Note:&nbsp; If you did not delete the 10.0 GA runtime, you'll see multiple copies of the libraries.&nbsp; They are actually unique, which you can tell by highlighting one, clicking the edit button and noting that the implementation version is different, even though the specification version is the same.</font></p>
<p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingWorkshop10.1withWebLogicServer.0MP1_C03E/libraries.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="libraries" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingWorkshop10.1withWebLogicServer.0MP1_C03E/libraries_thumb.jpg" width="475" border="0"></a> </p>
<p>Now we're all set to develop and deploy as normal.&nbsp; If you forgot to switch your JVM to the version that ships with WLS 10 MP1, which is jdk150_11, you will probably encounter the serialVersionUID error when you work with Beehive Service Controls.&nbsp; Here is a a look at what that stack might look like, so you know to switch the JVM, delete your types-jar file from WEB-INF/lib, rebuild your controls in Workshop and then redeploy if you encounter it.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 95.06%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; height: 115px; background-color: #f4f4f4; border-bottom-style: none"><p><span style="color: #0000ff">&lt;</span><span style="color: #800000">Dec</span> <span style="color: #ff0000">14</span>, <span style="color: #ff0000">2007</span> <span style="color: #ff0000">1:26:32</span> <span style="color: #ff0000">PM</span> <span style="color: #ff0000">CST</span><span style="color: #0000ff">&gt;</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">Error</span><span style="color: #0000ff">&gt;</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">com.bea.control.servicecontrol.util.memento.ServiceClassMementoUtil</span><span style="color: #0000ff">&gt;</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">BEA-000000</span><span style="color: #0000ff">&gt;</span> </p><p><span style="color: #0000ff">&lt;</span>com.bea.control.servicecontrol.util.memento.ServiceClassMementoUtil: Could not load the ServiceClassMemento from the following resource file:</p><p> control/EchoServiceControlServiceClassMemento.ser.</p><p>This is probably due to a versioning issue and if the developer was astute when they made the change then this should not be the reason. Another </p><p>possibility is that this resource has become corrupt.  The good news is a rebuild of your app should fix it.

Throwable: java.io.InvalidClassException: javax.xml.namespace.QName; local class incompatible: stream classdesc serialVersionUID = </p><p>4418622981026545151, local class serialVersionUID = -9120448754896609940
Stack Trace:
java.io.InvalidClassException: javax.xml.namespace.QName; local class incompatible: stream classdesc serialVersionUID = </p><p>4418622981026545151, local class serialVersionUID = -9120448754896609940
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:546)
</p></pre></div>]]>
        
    </content>
</entry>
<entry>
    <title>Using LDAP as a user-store for WebLogic Administrators</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2007/12/using_ldap_as_a.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2007/12/using_ldap_as_a.html</id>
    
    <published>2007-12-13T21:51:50Z</published>
    <updated>2007-12-13T21:51:49Z</updated>
    
    <summary>I have previously posted on how to set up WebLogic Server for use with OpenLDAP so that LDAP users can be used for authentication for web apps, etc.  In this post, I&apos;ll discuss how to extend that to WebLogic Administration, so that centralized administration of WebLogic Administrators can be enabled via external LDAP.</summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: WebLogic Server" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<p>One of my customers that has hundreds of WLS instances recently asked me about moving towards a centralized model for managing WebLogic Administrators.&nbsp; Currently they use the file-based out-of-the-box embedded LDAP that ships with WebLogic Server as an Administrator store.&nbsp; This is great for getting started quickly, but it means that each instance has it's own local user store for Administrators.&nbsp; Therefore, when one of their Administrators leaves the company they have to go to each server and change the Administrator password.&nbsp; Now that can be a headache!&nbsp; I have previously posted on <a href="http://dev2dev.bea.com/blog/jbayer/archive/2007/08/using_openldap.html">how to set up WebLogic Server for use with OpenLDAP</a> so that LDAP users can be used for authentication for web apps, etc.&nbsp; In this post, I'll discuss how to extend that to WebLogic Administration, so that centralized administration of WebLogic Administrators can be enabled via external LDAP.</p> <h3>Review the documentation for Authentication Providers</h3> <p>E-docs has some great detail on how to <a href="http://edocs.bea.com/wls/docs100/secmanage/atn.html#wp1198903">configure more than one Authentication Provider</a> and how to <a href="http://edocs.bea.com/wls/docs100/secmanage/atn.html#wp1198953">configure LDAP Authentication Providers</a>, and specifically addresses the case in which LDAP is the only Authentication Provider.&nbsp; One thing that is important to highlight if you go down the path of only having LDAP as the sole Authentication Provider is that it introduces a point of failure into your WebLogic Servers, meaning that if your WLS instances get network partitioned from your LDAP server(s) or your LDAP server(s) goes down, your WLS instances will not boot.&nbsp; You can partially guard against this by <a href="http://edocs.bea.com/wls/docs100/secmanage/atn.html#wp1199016">configuring LDAP fail-over</a>, but to keep the flexibility, you may want to keep the Default Authenticator around for emergencies and keep that user/password isolated to a master Administrator.&nbsp; There are <a href="http://edocs.bea.com/wls/docs100/secmanage/atn.html#wp1211007">two ways to enable someone to be a WebLogic Administrator</a>:</p> <ol> <li>Add the user to the Administrators group in LDAP (which is included in the Admin global role by default)  <li>Add the user to the Admin global role (you can do this by group, explicit user, etc)</li></ol> <p>As it is mentioned in the docs, your LDAP may already use the Administrators group for another purpose, or you may not want to put users in that group and give them Administrator access to all the domains in your environment.&nbsp; In this case, the 2nd method allows you to be much more granular and even put users in groups that might correlate to their business unit.&nbsp; So I could have an HRWebLogicAdmins group in LDAP for the Human Resources department, and when I create the domains for that department, make sure I add that group to the Admin Global Role.&nbsp; If that approach is taken, users may be able to use their normal LDAP user and credentials instead of a special Administrative account that is shared because their personal user has group membership to HRWebLogicAdmins.&nbsp; This provides you with an additional level of auditing since you are not using shared Administrator accounts.</p> <h3></h3> <h3>Configure your base domain</h3> <p>Let's put this into practice.&nbsp; First let's assume were starting from scratch with no domains at all.&nbsp; We'll configure LDAP with it and confirm that we can have Administrators in LDAP, then create a domain template with LDAP preconfigured so that new domains don't have to do this LDAP setup at all.&nbsp; I'm going to use WLS 10 MP1 for this, but the steps should be similar in other versions of WLS.&nbsp; I'm using the same OpenLDAP configuration that I discussed in my <a href="http://dev2dev.bea.com/blog/jbayer/archive/2007/08/using_openldap.html">previous post</a>, so refer to that for more detail on this setup if you need it.</p> <ol> <li>Create a domain - D:\bea100MP1\wlserver_10.0\common\bin\config.cmd (sh)  <li>Keep the defaults, which will have weblogic/weblogic as your Administrator.  <li>Start the AdminServer and login with weblogic/weblogic.at <a title="http://localhost:7001/console" href="http://localhost:7001/console">http://localhost:7001/console</a>  <li>Click the "Lock &amp; Edit" button in the console and optionally then click the "Record" button if you are in WLS 10 or higher and want to record the WLST script  <li>Add the OpenLDAP Authenticator to your realm (remember to set the control flag of both Authenticators to OPTIONAL or SUFFICENT)  <li>Review the Admin role mapping to see that it maps to the users/groups you want.&nbsp; In this example, I'm assuming that the using the Adminstrators group in LDAP is okay.</li></ol> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingLDAPasauserstoreforWebLogicAdminist_CD8B/Roles%20%5B2%5D_4.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="380" alt="Roles [2]" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingLDAPasauserstoreforWebLogicAdminist_CD8B/Roles%20%5B2%5D_thumb_1.jpg" width="644" border="0"></a> </p> <p>Here is the default mapping for all users in the Admin role.&nbsp; Notice that it includes all of the users in the Adminstrators group by default.&nbsp; This is where I could add other groups.&nbsp; Be aware that role changes you make are stored as XACML and have to be imported/exported.</p> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingLDAPasauserstoreforWebLogicAdminist_CD8B/groupMapping_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="401" alt="groupMapping" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingLDAPasauserstoreforWebLogicAdminist_CD8B/groupMapping_thumb.jpg" width="644" border="0"></a> </p> <p>Now click "Activate Changes" and notice the name of the WLST script if you did a recording and the notice that we need to restart the server for the changes to take affect since we modified the security subsystem.&nbsp; At this point we can shut the server down.</p> <p>Now let's review my LDAP configuration.&nbsp; Using <a href="http://www.jxplorer.org/">JXplorer</a> I can both view and edit my OpenLDAP configuration.&nbsp; Here are the settings that work with the LDAP config from my previous post:&nbsp; Note that the password is "secret".</p> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingLDAPasauserstoreforWebLogicAdminist_CD8B/jxplorer_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="308" alt="jxplorer" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingLDAPasauserstoreforWebLogicAdminist_CD8B/jxplorer_thumb.jpg" width="404" border="0"></a> </p> <p>Note that I added an Administrators group and added the jbayer user as a member of that group.&nbsp; To add a group, just right click on "groups" and select "New" and go through the prompts.</p> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingLDAPasauserstoreforWebLogicAdminist_CD8B/Explorer_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="393" alt="Explorer" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingLDAPasauserstoreforWebLogicAdminist_CD8B/Explorer_thumb.jpg" width="644" border="0"></a> </p> <p>Ok, now I should be able to boot WLS with the jbayer user and login to the console as an Administrator.&nbsp; Let's try both.&nbsp; First I need to update the boot.properties file that is located in the domain's &lt;Server_Name&gt;/security directory.&nbsp; In my case, that is:&nbsp; D:\bea100MP1\user_projects\domains\open_ldap_domain3\servers\AdminServer\security</p> <p>Opening the file shows you that the username and password are encrypted, so now we need to replace the {3DES} encrypted values with plain text ones for my jbayer user.&nbsp; The next time WLS boots, it will re-encrypt these values.&nbsp; Note that we can also find out the domains encrypted values ourselves by using the encryption utility:</p> <div class="csharpcode-wrapper"><pre class="csharpcode" style="width: 847px; height: 149px">D:\bea100MP1\user_projects\domains\open_ldap_domain3\bin<span class="kwrd">&gt;</span>setDomainEnv.cmd

D:\bea100MP1\user_projects\domains\open_ldap_domain3<span class="kwrd">&gt;</span>java weblogic.security.Encrypt jbayer
{3DES}yunUy+yVmfY=

D:\bea100MP1\user_projects\domains\open_ldap_domain3<span class="kwrd">&gt;</span>java weblogic.security.Encrypt weblogic
{3DES}PmZxnuL1akG6MzWSRo/g3w==
</pre></div>
<div class="csharpcode-wrapper">Now we can boot the domain.&nbsp; If there is a problem, you'll see a stack trace that mentions the security sub-system, you'll probably have to change the boot.properties file back to the original values, weblogic/weblogic if you didn't change the defaults and see if you messed up anywhere.</div>
<div class="csharpcode-wrapper">&nbsp;</div>
<div class="csharpcode-wrapper">If there is no problem and the server goes to a RUNNING state, then we have booted the server as jbayer, which is in the Admin role because that user is in the Administrators group in OpenLDAP.&nbsp; Now try logging into the console and that should work as well.&nbsp; Here is my screen-shot showing the successful jbayer user login as Administrator to the console.</div>
<div class="csharpcode-wrapper"><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingLDAPasauserstoreforWebLogicAdminist_CD8B/jbayer%20%5B2%5D_4.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="166" alt="jbayer [2]" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/UsingLDAPasauserstoreforWebLogicAdminist_CD8B/jbayer%20%5B2%5D_thumb_1.jpg" width="304" border="0"></a> </div>
<h3>Make it repeatable with WLST or a Domain Template</h3>
<p>Doing all of this configuration each time you want to setup a new domain can monotonous and prone to typing mistakes.&nbsp; This is where using WLST or domain templates can come in very handy.&nbsp; First let's review the .py file that was created during our WLST recording as we created the OpenLDAP Authenticator.&nbsp; Mine was saved to my domain's base directory with the name Script1197502551016.py.&nbsp; For more on WLST see my <a href="http://dev2dev.bea.com/blog/jbayer/archive/2007/10/automate_wls_co.html">intro to WLST post</a> and the <a href="http://e-docs.bea.com/wls/docs100/config_scripting/reference.html">command reference</a> for documentation on WLST commands.</p>
<div class="csharpcode-wrapper"><pre class="csharpcode" style="width: 1023px; height: 383px">cd('/SecurityConfiguration/open_ldap_domain/Realms/myrealm')
cmo.createAuthenticationProvider('openLdapAuthenticator', 'weblogic.security.providers.authentication.OpenLDAPAuthenticator')

cd('/SecurityConfiguration/open_ldap_domain/Realms/myrealm/AuthenticationProviders/openLdapAuthenticator')
cmo.setGroupBaseDN('ou=groups, dc=bea, dc=com')
cmo.setStaticGroupObjectClass('groupOfNames')
cmo.setUserBaseDN('ou=people, dc=bea, dc=com')
cmo.setUserObjectClass('inetOrgPerson')
cmo.setPrincipal('cn=Manager,dc=bea,dc=com')
setEncrypted('Credential', 'Credential_1197503008359', 'D:/bea100MP1/user_projects/domains/open_ldap_domain/Script1197502551016Config', 'D:/bea100MP1/user_projects/domains/open_ldap_domain/Script1197502551016Secret')
cmo.setStaticGroupDNsfromMemberDNFilter('(&amp;(member=%M)(objectclass=groupOfNames))')
cmo.setUserFromNameFilter('(&amp;(cn=%u)(objectclass=inetOrgPerson))')
cmo.setGroupFromNameFilter('(&amp;(cn=%g)(objectclass=groupOfNames))')
cmo.setControlFlag('SUFFICIENT')

cd('/SecurityConfiguration/open_ldap_domain/Realms/myrealm/AuthenticationProviders/DefaultAuthenticator')
cmo.setControlFlag('SUFFICIENT')

activate()
</pre></div>
<p>I could simply use a script like this to configure my new domains to have LDAP support after they have been created.&nbsp; However, I can go one step further and use the domain that has already been configured for LDAP and create a domain template using the Domain Template Builder D:\bea100MP1\wlserver_10.0\common\bin\config_builder.cmd.&nbsp; Now when I create new Domains using the Config Wizard and base it off that template, authentication to OpenLDAP will be pre-configured.&nbsp; Just launch the Domain Template Wizard, point it at the domain and follow all of the defaults.&nbsp; I can even configure the Admin Role here to include other groups.</p>
<h3>One Last Gotcha</h3>
<p>One big gotcha that I encountered is that the new domains that I created based off that template still had the OpenLDAP password for the manager user set to the encrypted value of the first domain in the config.xml file in the new domain's config directory.&nbsp; Each domain has a unique way of encrypting it's passwords so the encrypted values cannot be exchanged between domains.&nbsp; I've highlighted the incorrect value below in the credential-encrypted element.&nbsp; Make sure you replace that value with new domains correct {3DES} value that you can retrieve with technique illustrated earlier: java weblogic.security.Encrypt password.&nbsp; I'm investigating whether this is working as designed or not as I expected the Config Wizard to take care of that for me.&nbsp; </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">sec:authentication-provider</span> <span style="color: #ff0000">xsi:type</span><span style="color: #0000ff">="wls:open-ldap-authenticatorType"</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">sec:name</span><span style="color: #0000ff">&gt;</span>openLdapAuthenticator<span style="color: #0000ff">&lt;/</span><span style="color: #800000">sec:name</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">sec:control-flag</span><span style="color: #0000ff">&gt;</span>SUFFICIENT<span style="color: #0000ff">&lt;/</span><span style="color: #800000">sec:control-flag</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">wls:propagate-cause-for-login-exception</span><span style="color: #0000ff">&gt;</span>false<span style="color: #0000ff">&lt;/</span><span style="color: #800000">wls:propagate-cause-for-login-exception</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">wls:user-object-class</span><span style="color: #0000ff">&gt;</span>inetOrgPerson<span style="color: #0000ff">&lt;/</span><span style="color: #800000">wls:user-object-class</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">wls:principal</span><span style="color: #0000ff">&gt;</span>cn=Manager,dc=bea,dc=com<span style="color: #0000ff">&lt;/</span><span style="color: #800000">wls:principal</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">wls:user-base-dn</span><span style="color: #0000ff">&gt;</span>ou=people, dc=bea, dc=com<span style="color: #0000ff">&lt;/</span><span style="color: #800000">wls:user-base-dn</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">wls:credential-encrypted</span><span style="color: #0000ff">&gt;</span><span style="color: #ff0000">{3DES}68bCeqro3EA=</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">wls:credential-encrypted</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">wls:user-from-name-filter</span><span style="color: #0000ff">&gt;</span>(<span style="color: #ff0000">&amp;amp;</span>(cn=%u)(objectclass=inetOrgPerson))<span style="color: #0000ff">&lt;/</span><span style="color: #800000">wls:user-from-name-filter</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">wls:group-base-dn</span><span style="color: #0000ff">&gt;</span>ou=groups, dc=bea, dc=com<span style="color: #0000ff">&lt;/</span><span style="color: #800000">wls:group-base-dn</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">wls:group-from-name-filter</span><span style="color: #0000ff">&gt;</span>(<span style="color: #ff0000">&amp;amp;</span>(cn=%g)(objectclass=groupOfNames))<span style="color: #0000ff">&lt;/</span><span style="color: #800000">wls:group-from-name-filter</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">wls:static-group-object-class</span><span style="color: #0000ff">&gt;</span>groupOfNames<span style="color: #0000ff">&lt;/</span><span style="color: #800000">wls:static-group-object-class</span><span style="color: #0000ff">&gt;</span>
  <span style="color: #0000ff">&lt;</span><span style="color: #800000">wls:static-group-dns-from-member-dn-filter</span><span style="color: #0000ff">&gt;</span>(<span style="color: #ff0000">&amp;amp;</span>(member=%M)(objectclass=groupOfNames))<span style="color: #0000ff">&lt;/</span><span style="color: #800000">wls:static-group-dns-from-member-dn-filter</span><span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;/</span><span style="color: #800000">sec:authentication-provider</span><span style="color: #0000ff">&gt;</span>
</pre></div>
<p>Hopefully this illustrates how LDAP can provide a way to manage WebLogic Administration in a way that is more scalable than having individual user stores in embedded LDAP when many WLS instances are involved.</p>]]>
        
    </content>
</entry>
<entry>
    <title>Asynchronous Servlet Article Extras - Push Events</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2007/12/asynchronous_se.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2007/12/asynchronous_se.html</id>
    
    <published>2007-12-05T17:34:56Z</published>
    <updated>2007-12-05T17:35:11Z</updated>
    
    <summary>I just finished reading Francesco Marchioni&apos;s article entitled Using Asynchronous Servlets to Deal with Hung Threads and thought that I could add some information for those that want to explore this functionality more and see a working example of a chat room built with AJAX.  This is really about implementing virtual push events to web clients.</summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: WebLogic Server" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<p>I just finished reading <a href="http://dev2dev.bea.com/pub/au/3371">Francesco Marchioni</a>'s article entitled <a href="http://dev2dev.bea.com/pub/a/2007/12/asynchronous-servlets.html?page=1">Using Asynchronous Servlets to Deal with Hung Threads</a> and thought that I could add some information for those that want to explore this functionality more and see a working example of a chat room built with AJAX.&nbsp; This is really about implementing virtual push event to web clients.&nbsp; Starting with WLS 10, there is an out-of-the-box example that ships with WebLogic Server that illustrates using the Abstract Asynchronous Servlet to build a chat room.&nbsp; In effect, it uses AJAX to create an event push (via a long poll).&nbsp; So now when a client sends a message to the chat room, all the clients receive the message virtually instantly without constantly polling the server for new messages.&nbsp; This technique has come to be known as <a href="http://en.wikipedia.org/wiki/Comet_(programming)">Comet</a> in AJAX terminology.&nbsp; To read the details of the example, just go to &lt;BEA_HOME&gt;/wlserver_10.0/samples/server/docs/core/index.html and expand the tree as shown below.&nbsp; To run it, just follow the directions which are very straight-forward.</p> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/AsynchronousServletArticleExtrasPushEven_A314/ChatExample_2.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="468" alt="ChatExample" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/AsynchronousServletArticleExtrasPushEven_A314/ChatExample_thumb.jpg" width="644" border="0"></a> </p> <p>Also check the <a href="http://edocs.bea.com/wls/docs100/javadocs/weblogic/servlet/http/AbstractAsyncServlet.html">javadoc for the AbstractAsynchrounousServlet</a> to get more information about the API.</p> <p>One neat thing to do is to run the example with both Firefox and IE at the same time and see messages sent by the IE client show up immediately in the Firefox client.&nbsp; I have the <a href="http://www.getfirebug.com/">Firebug</a> plug-in installed and you can see how the XmlHttpRequest (XHR) is waiting for new chat messages to come in.&nbsp; If no new messages arrive in 20 seconds, the AbstractAsynchServlet times out the request.&nbsp; Then the client issues a new XHR and starts the process again.</p> <p><a href="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/AsynchronousServletArticleExtrasPushEven_A314/firefoxWithFirebug_2.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="484" alt="firefoxWithFirebug" src="http://dev2dev.bea.com/blog/jbayer/WindowsLiveWriter/AsynchronousServletArticleExtrasPushEven_A314/firefoxWithFirebug_thumb.jpg" width="638" border="0"></a> </p> <p>I've seen some fairly neat examples and demos built with the AbstractAsynchronousServlet in WebLogic Portal such as a dash-board portlet that sends out messages and alerts.&nbsp; So if you have use-cases that would benefit from having events virtually pushed to web clients, consider using this approach as it is very effective and does not tie up threads on the server.</p>]]>
        
    </content>
</entry>
<entry>
    <title>WebLogic Scheduling - A polling approach to implement a DB event generator for ALSB</title>
    <link rel="alternate" type="text/html" href="http://dev2dev.bea.com/blog/jbayer/archive/2007/11/weblogic_schedu.html" />
    <id>http://dev2dev.bea.com/blog/jbayer/archive/2007/11/weblogic_schedu.html</id>
    
    <published>2007-11-01T17:58:40Z</published>
    <updated>2007-11-01T18:07:45Z</updated>
    
    <summary>Scheduling tasks for Java environments seem to come up fairly often.  Often times cron or Windows&apos;s Scheduled Tasks might be used, but that&apos;s not necessarily ideal if your application servers are spread across multiple machines because your scheduling mechanism could now have a single point of failure on that particular OS instance.  In this post, I&apos;ll review a customer situation that is well-suited for a scheduled polling solution and discuss the various options that I researched in WebLogic to implement it.</summary>
    <author>
        <name>jbayer</name>
        
    </author>
            <category term="Product: AquaLogic Data Services Platform" />
            <category term="Product: AquaLogic Service Bus" />
            <category term="Product: WebLogic Server" />
    
    <content type="html" xml:lang="" xml:base="http://dev2dev.bea.com/blog/jbayer/">
        <![CDATA[<p>Scheduling tasks for Java environments seem to come up fairly often.&nbsp; Often times <a href="http://en.wikipedia.org/wiki/Cron">cron</a> or <a href="http://support.microsoft.com/kb/308558">Windows's Scheduled Tasks</a> might be used, but that's not necessarily ideal if your application servers are spread across multiple machines because your scheduling mechanism could now have a single point of failure on that particular OS instance.&nbsp; In this post, I'll review a customer situation that is well-suited for a scheduled polling solution and discuss the various options that I researched in WebLogic to implement it.</p> <h2>The Use Case - A Database Event Generator</h2> <p>One of my customers recently purchased <a href="http://www.bea.com/framework.jsp?CNT=index.htm&amp;FP=/content/products/aqualogic/service_bus/">AquaLogic Service Bus</a> (ALSB) and <a href="http://www.bea.com/framework.jsp?CNT=index.htm&amp;FP=/content/products/aqualogic/data_services/">AquaLogic Data Services Platform</a> (ALDSP).&nbsp; One of their main use cases is to be able to monitor database tables for new records.&nbsp; This particular customer has an aversion to database triggers, which is probably the most common solution to this type of problem.&nbsp; Therefore, we need to rely on something external to the database to detect these events.&nbsp; Unfortunately, this is not an out-of-the-box feature of either ALSB or ALDSP today, although it is a feature of <a href="http://www.bea.com/framework.jsp?CNT=index.htm&amp;FP=/content/products/weblogic/integrate/">WebLogic Integration</a> (WLI).&nbsp; One of the options for WLI's event generator is to use a query-based polling approach, which executes a select statement that returns new records, publishes the events, and updates each record to indicate it has been processed.&nbsp; It does this on a schedule.&nbsp; I thought that a similar approach could be implemented fairly easily in a regular J2EE application.&nbsp; For example, a session bean method called on a regular basis that we could deploy to the ALSB server since it has WLS underneath the covers.&nbsp; </p> <h2></h2> <h2>Timer Options in WebLogic Server</h2> <p>So the question now becomes, what mechanism can be used to schedule the invocation of the session bean on a regular basis?&nbsp; A key requirement is that the solution should work well in a clustered environment such that it will fail-over to another server in a cluster, yet doesn't redundantly execute on each server in the cluster.&nbsp; I searched around and came up with several options for scheduling with timers in WebLogic.</p> <ol> <li>EJB 2.1 Timer Service  <li>Workshop Timer Control  <li>CommonJ Timer Manager</li></ol> <h3></h3> <h3>EJB 2.1 Timer Service</h3> <p>The EJB 2.1 Timer Service is <a href="http://edocs.bea.com/wls/docs92/ejb/implementing.html#wp1191405">supported in WLS 9.2</a> and <a href="http://edocs.bea.com/wls/docs100/ejb/implementing.html#wp1191405">WLS 10</a> and initially seemed like a good solution since it is a J2EE standard.&nbsp; However, upon a little more investigation I ruled it out mainly because the timer object <a href="http://edocs.bea.com/wls/docs100/ejb/implementing.html#wp1193410">cannot be migrated from server to server</a>.&nbsp; Of course, it can take advantage of <a href="http://edocs.bea.com/wls/docs100/cluster/migration.html">Whole Server Migration</a>, but that is not