Saturday 22 February 2014

Maven Jdeveloper plugin

If you work with Maven and Jdeveloper 11 this plugin is a MUST for you.
Just add to your POM the following:

      <plugin>
        <groupId>org.apache.myfaces.trinidadbuild</groupId>
        <artifactId>maven-jdev-plugin</artifactId>
        <version>1.2.6</version>
      </plugin>


Then run:

mvn jdev:jdev

and magically Maven it will create the Jdeveloper PRJ file with all the library needed!!!

Maven and Archiva setup

Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central place.
I've found Maven very useful in many situation, for example for building up a project downloaded from internet and compile it straight away. With Maven it takes 2 minutes only!!!

Here a brief guide about how to setup Maven+Archiva


Maven Installation

1. Download Maven 2.2.1 Maven Download

2. Unpack the archive where you would like to store the binaries. A directory called "apache-maven-2.x.y" will be created.

3. Add the bin directory to your PATH, eg:

      set PATH="c:\apache-maven-2.x.y\bin";%PATH%

4. Make sure JAVA_HOME is set to the location of your JDK

5. Run "mvn --version" to verify that it is correctly installed.


Archiva Installation

1. The quickest way to install Archiva is to download archiva standalone and use this distribution. This includes a bundled Jetty server which can be easily started.

2. Unpack the archive where you would like to store the binaries. A directory called "apache-archiva-2.x.y" will be created.

3. Archiva can be run by executing, bin/archiva, or bin\archiva.bat for Windows (select the one for your environment). The argument can be console to run interactively, or start to run in the background (in this case, run the script with stop to later stop the server). The logs are available in the logs directory where Archiva is installed.

Maven Configuration

Maven configuration occurs at 3 levels:

-Project - most static configuration occurs in pom.xml
-Installation - this is configuration added once for a Maven installation
-User - this is configuration specific to a particular user (${user.home}/.m2/settings.xml)

The separation is quite clear - the project defines information that applies to the project, no matter who is building it, while the others both define settings for the current environment.

The localRepository is the path to the local repository maven will use to store artifacts. It has to be configured using a local folder like here:

<localRepository>C:\apache-maven\localRepo</localRepository>

Repositories are declared inside a project, which means that if you have your own custom repositories, those sharing your project easily get the right settings out of the box. However, you may want to use an alternative mirror for a particular repository without changing the project files.

If you would like Archiva to serve as the only repository used by your Maven installation, you can use the Maven mirror settings to force this behaviour.
First, you need to select the default repository to use when none is configured by adding the following to the settings.xml file:


  
  <mirrors>
    <mirror>
      <id>archiva.default</id>
      <url>http://repo.mycompany.com:8080/repository/internal/</url>
      <mirrorOf>external:*</mirrorOf>
    </mirror>
  </mirrors>

Archiva Configurations

You can now browse the web administration of Archiva. There will be a few basic setup tasks to get started.

The first step is to setup your administration user. The password requires a numerical character and must not be longer than 8 chars. You'll then need to log in. Use 'admin' as the username and the password you've entered.

At this point, Archiva is fully functional - you can use it with the default repositories and guest user. You might like to explore the user and administrator guides to find other functionality.

The default configuration for Archiva configures two repositories:

  • internal - a repository for containing released artifacts. This is connected by proxy to the central repository, so requests here will automatically retrieve the remote artifacts.
  • snapshots - a repository for storing deployed snapshots. This is not proxied to any remote repositories by default.
In addition, the guest user has read access to these repositories, so you can make anonymous requests to either. To try this out, point a web browser at the following URL: http://localhost:8080/repository/internal/junit/junit/3.8.1/junit-3.8.1.jar. Though the artifact is not present locally, you will see in the Archiva logs that it is downloaded from the central repository, and then handed back to the browser and downloaded from Archiva. Future requests for the artifact will be much faster as they need not be downloaded from the central repository

Wednesday 19 February 2014

JDEV Preferences: ADF object and package naming Best Practice

From the JDeveloper menu, select
Tools > Preferences > Business Components > Object Naming
In the dialog box, set suffixes as follows:

Entity EO
View Object VO
Application Module AM



Select Packages in the list at the left and set the following values:

Entityentity
View Objectview
Application Modulemodule




Thursday 13 February 2014

Configuring BPM for sending email notification with GMAIL

Step 1 : Import certificates from gmail and add it to your server trust store. Any email server uses two protocols to send/receive messages.

SMTP for sending mails
    You can download the certificates using an opensource software called openssl. First, you need to download and install it. Downloading SMTP certificate (needed to SEND email)
    Open command prompt and cd to openssl_install_folder/bin
    Give the below command to view the smtp certificate
    openssl s_client -connect smtp.gmail.com:465

    Import of the certificate into the JDK with:

    <JAVA_HOME>/bin/keytool -import -alias smtp.gmail.com -keystore <JAVA_HOME>/jre/lib/security/cacerts -file <JAVA_HOME>/jre/lib/security/gmail.cer
    
    

    Comment out the option in the field EXTRA_JAVA_PROPERTIES for the setDomainEnv script to avoid the certificate to be loaded from the DemoTrust


    -Djavax.net.ssl.trustStore=${WL_HOME}/server/lib/DemoTrust.jks

    Then the following configurations has to be made through the EM




    Restart the Domain and after that send a test notification as below





    Configuring Oracle BPM and SOA Suite 11g with a SQL Authentication Provider

    Login to integrated weblogic server with admin user (weblogic) and password

    click on security realms and select my realm option

    click on new provider to create a new SQLAuthenticator

    provide the name of the SQLAuthenticator and set the control flag as sufficient.

    Provide the data source to the database.
    The table USERS, GROUPS and GROUPS_MEMBER have to be already created
    into the database. For instance this script uses the default table and column
    names.
    Using the attached script the query to access to the users and groups don't need to be
    modified. Otherwise, using a custom DB the query needs to be changed.


    Reorder the providers and keep the SQL one at the top
    Change the control flag of default authenticator from required to sufficient.

    Restart WLS and check that users and groups from the database have been
    imported into WLS.
    For the SOA/BPM environment there is a known issue (Logon To Oracle Workspace Failed With Users Of SQL Authenticator (Doc ID 1499679.1)). I followed this approach as a workaround as suggested by oracle to being able to see the accounts in BPM. Here are the steps to apply it

    • Download the DBProvider
    • Copy dbprovider.jar to MW_HOME/user_projects/domains/{soa_domain}/lib
    • Shutdown SOA and Admin Server
    • Navigate to MW_HOME/user_projects/domains/{domain_name}/config/fmwconfig
    • Take a backup of jps-config.xml
    • Edit jps-config.xml and make the following modifications
    In the section starting with <jpsContext name="default" 
    modify <serviceInstanceRef ref="idstore.ldap"/> to 
    <serviceInstanceRef ref="idstore.custom"/>

    Within the <serviceInstances>...</serviceInstances> section, 
    add the following (change the db_* parameters as per the environment): 
    <serviceInstance name="idstore.custom" provider="custom.provider" location="dumb"> 
    <description>Custom Identity Store Service Instance</description> 
    <property name="idstore.type" value="CUSTOM"/> 
    <property name="ADF_IM_FACTORY_CLASS" value="org.sample.providers.db.DBIdentityStoreFactory"/> 
    <property name="DB_SERVER_NAME" value="db_host_name"/> 
    <property name="DB_DATABASE_NAME" value="db_sid"/> 
    <property name="ST_SECURITY_PRINCIPAL" value="db_user"/> 
    <property name="ST_SECURITY_CREDENTIALS" value="db_passwd"/>
    </serviceInstance>
    

    Within the <serviceProviders>...</serviceProviders> section,
    add the following 
    <serviceProvider type="IDENTITY_STORE" name="custom.provider" 
    class="oracle.security.jps.internal.idstore.generic.GenericIdentityStoreProvider"> 
    <description>Custom IdStore Provider</description> </serviceProvider>
    

    • Start SOA/Admin server





    Oracle Case Management 11g EURENT Configuration


    Case Management is a new addition to Oracle BPM in release 11.1.1.1.7 (PS6). This new release contains the Case Management engine, see blog Léon for more details.
    However, currently this release does not contain a case portal.
    The case management API's, just like the already existing Oracle BPM API's, help in developing a portal page with relative ease.

    In this post I will show how to install, configure and fix common issues for the EURent case management application and portal application developed by Oracle.

    Downloads all the files:
    Case MGM UI
    EurRent
    Demo Community
    Patches for Case Mgm

    Then starts unzipping the EURENT dowloaded file Sample PDF and follow the steps indicated within.

    • Pre-requirements
      • Patch installation for WLS and Java if needed
    • Depoly EURENT
      • Make sure in the property the admin has to point to the ADMIN server and the SERVER has to point to the SOA_SERVER
      • If needed the workflow-001-DemoCommunitySeedApp can be found here
    • Running ANT to create and configure the users and groups, it may happen:
    BUILD FAILED
    C:\oracle\Middleware\11.1.1.7-JDEV\workspace\EURent\case-permission-grant-build.xml:28: The following error occurred while executing this line:
    C:\oracle\Middleware\11.1.1.7-JDEV\workspace\workflow-001-DemoCommunitySeedApp\build.xml:38: The following error occurred while executing this line:
    C:\oracle\Middleware\11.1.1.7-JDEV\workspace\workflow-001-DemoCommunitySeedApp\build.xml:42: Problem: failed to create task or type if
    Cause: The name is undefined.
    Action: Check the spelling.
    Action: Check that any custom tasks/types have been declared.
    Action: Check that any / declarations have taken place.
    

    This only happens because some Target used in this script are not part of the default ANT installation, which then needs to be imported using the following:
    <taskdef resource="net/sf/antcontrib/antlib.xml">
      <classpath>
        <pathelement location="your/path/to/ant-contrib-${version}.jar">
      </pathelement></classpath>
    </taskdef>
    


    Another issue which may happen is that the groups are not correctly associated to the users because the users are not already defined in the LDAP. At the end of the ANT script you may note the following:

    seedDemoCommunity:
         [echo] Invoking seeding servlet to start seeding demo community...
         [echo] seed.server.url : http://localhost:8001, seed.admin.url : t3://localhost:7001 seed.admin.name : weblogic 
         [java] URL : http://localhost:8001/integration/SOADemoCommunity/DemoCommunitySeedServlet
         [java] inputFile=C:\oracle\Middleware\11.1.1.7-JDEV\workspace\EURent\CasePermissionRoleGrants.xml&adminServer=localhost&adminPort=7001&adminUser=weblogic
         [java] <html>
         [java] <head>
         [java] <title>Demo User Community</title>
         [java] <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
         [java] </head>
         [java] <body>
         [java] <table border="1" style="background-color:#C8C8C8" align="center" width="70%">
         [java] <tr>
         [java] <td>
         [java] <H1 ALIGN="CENTER">Seed Demo Community</H1>
         [java] <BR><B>App-Role Grants : </B>
         [java] </td>
         [java] </tr>
         [java] </table>
         [java] </body>
         [java] </html>
    


    In "App-Role Grants :" we should see the list of Users-Roles granted. As you can see in the Server log:

    user:jcooper User (jcooper) specified as grantee for app role EURent.CONFIDENTIA
    L.READ.Role does not exist. Please modify the XML input file to create the user
    and rerunuser:jstein User (jstein) specified as grantee for app role EURent.CONF
    IDENTIAL.READ.Role does not exist. Please modify the XML input file to create th
    e user and rerunuser:sfitzger User (sfitzger) specified as grantee for app role
    EURent.CONFIDENTIAL.READ.Role does not exist. Please modify the XML input file t
    o create the user and rerunJMXAppRoleGranter.getMembersForApplicationRole() : IN
     : appStripe : OracleBPMProcessRolesApp, appRole : EURent.CONFIDENTIAL.UPDATE.Ro
    le
    


    Too fix it the users defined in the CasePermissionRoleGrants.xml have to be manually created in the WLS realm, then the script ANT can be re-run again

    the result has to be like this:


    seedDemoCommunity:
         [echo] Invoking seeding servlet to start seeding demo community...
         [echo] seed.server.url : http://localhost:8001, seed.admin.url : t3://localhost:7001 seed.admin.name : weblogic
         [java] URL : http://localhost:8001/integration/SOADemoCommunity/DemoCommunitySeedServlet
         [java] inputFile=C:\oracle\Middleware\11.1.1.7-JDEV\workspace\EURent\CasePermissionRoleGrants.xml&adminServer=localhost&adminPort=7001&adminUser=weblogic
         [java] <html>
         [java] <head>
         [java] <title>Demo User Community</title>
         [java] <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
         [java] </head>
         [java] <body>
         [java] <table border="1" style="background-color:#C8C8C8" align="center" width="70%">
         [java] <tr>
         [java] <td>
         [java] <H1 ALIGN="CENTER">Seed Demo Community</H1>
         [java] <BR><B>App-Role Grants : </B>
         [java] EURent.PUBLIC.READ.Role is granted to user mmitch.
         [java] EURent.PUBLIC.READ.Role is granted to user jausten.
         [java] EURent.PUBLIC.READ.Role is granted to user wfaulk.
         [java] EURent.PUBLIC.READ.Role is granted to user wshake.
         [java] EURent.PUBLIC.READ.Role is granted to user jcoope.
         [java] EURent.PUBLIC.READ.Role is granted to user jstein.
         [java] EURent.PUBLIC.READ.Role is granted to user sfitzger.
         [java] EURent.PUBLIC.UPDATE.Role is granted to user mmitch.
         [java] EURent.PUBLIC.UPDATE.Role is granted to user jausten.
         [java] EURent.PUBLIC.UPDATE.Role is granted to user wfaulk.
         [java] EURent.PUBLIC.UPDATE.Role is granted to user wshake.
         [java] EURent.PUBLIC.UPDATE.Role is granted to user jcooper.
         [java] EURent.PUBLIC.UPDATE.Role is granted to user jstein.
         [java] EURent.PUBLIC.UPDATE.Role is granted to user sfitzger.
         [java] EURent.PUBLIC.INVOKE.Role is granted to user mmitch.
         [java] EURent.PUBLIC.INVOKE.Role is granted to user jausten.
         [java] EURent.PUBLIC.INVOKE.Role is granted to user wfaulk.
         [java] EURent.PUBLIC.INVOKE.Role is granted to user wshake.
         [java] EURent.PUBLIC.INVOKE.Role is granted to user jcooper.
         [java] EURent.PUBLIC.INVOKE.Role is granted to user jstein.
         [java] EURent.PUBLIC.INVOKE.Role is granted to user sfitzger.
         [java] EURent.CONFIDENTIAL.READ.Role is granted to user jcooper.
         [java] EURent.CONFIDENTIAL.READ.Role is granted to user jstein.
         [java] EURent.CONFIDENTIAL.READ.Role is granted to user sfitzger.
         [java] EURent.CONFIDENTIAL.UPDATE.Role is granted to user jcooper.
         [java] EURent.CONFIDENTIAL.UPDATE.Role is granted to user jstein.
         [java] EURent.CONFIDENTIAL.UPDATE.Role is granted to user sfitzger.
         [java] EURent.CONFIDENTIAL.INVOKE.Role is granted to user jcooper.
         [java] EURent.CONFIDENTIAL.INVOKE.Role is granted to user jstein.
         [java] EURent.CONFIDENTIAL.INVOKE.Role is granted to user sfitzger.
         [java] </td>
         [java] </tr>
         [java] </table>
         [java] </body>
         [java] </html>
    
    

    • At this stage the UI has to be deployed. Just configure the deploy script with your environment variable and run it. It creates the EAR which can be manually deployed through the WLS console. Deploy it to the SOA_SERVER, if different than the ADMIN. The console can be tested at this point accessing as a granted user (mitch jstein, ...)
    • Now all has been deployed and configured, it is time to start a case! Open the SampleInput XML and call the EURENT.service (note that in some case it may be good to comment "<ns2:updatedDate></ns2:updatedDate>", I got some issue because of this field). The service can be called:
      • through the EM (accessing to the service in SOA-infra)
      • accessing to http://<host>:<port>/soa-infra selecting EURENT.service


    • Now connecting to the sample UI as a mitch, in case you don't see any record it maybe because the Groups in the BPM/workspace have not been configured correctly

    Access to the BPM Console and check if the highlighted groups have been granted to someone.
    In my case they weren't, then I granted all of them to weblogic.



    Then accessing to the CMSampleUI again as weblogic user I see the created records.


    • asas