Get Data Moving 1
Results 1 to 7 of 7

Thread: Setting up the Attunity Java Connector (JCA) with OC4J

  1. #1
    Adeeb Mass'ad is offline Support Manager
    Join Date
    Aug 2006
    Location
    Jaffa of Nazareth
    Posts
    169
    Rep Power
    14

    HOW TO: Setup the Attunity Java Connector (JCA) with Oracle Application Server (OC4J)

    DESCRIPTION

    Attunity Connect products provides peer-to-peer distributed data and application access infrastructure, enabling applications to access and integrate data from heterogeneous data sources and from other applications.

    The Attunity ThinkClient Kit (JCA) contains the Attunity Connector-Architecture implementation for J2EE.

    This Kit enables enterprises to unite applications and data from more than 30 data sources on more than 20 computing platforms, including OS/390, OS/400, HP (Compaq) NonStop, OpenVMS, UNIX and Windows, using J2EE Connector Architecture (JCA).

    REQUIREMENTS
    • Oracle9iAS Containers for J2EE (OC4J) -- or higher.
    • Sun's Java 2 Platform, Standard Edition (J2SE) v1.4.x -- or higher.
    • Attunity ThinClient Kit
    DEPLOYMENT

    1. Create a new directory, called "attunity", under the Connectors directory, located at:
    OC4JROOT\j2ee\home\connectors
    2. Extract the attunityResourceAdapter.rar to this directory.

    3. Extract the attunityResourceAdapter.jar to the OC4JROOT\j2ee\home\lib directory.

    4. Add the following to the OC4JROOT\j2ee\home\confiig\oc4j-connectors.xml file:

    HTML Code:
    <OC4J-CONNECTORS><CONNECTOR name="attunity" path="attunityResourceAdapter.rar"/>
    </OC4J-CONNECTORS>
    5. Run the Oracle AS to install the Attunity Resource Adapter.
    c:\OracleAS\j2ee\home> java -jar oc4j.jar

    Auto-unpacking C:\OracleAS\j2ee\home\connectors\attunity\attunity ResourceAdapter.rar... done.
    Auto-deploying file:/C:/OracleAS/j2ee/home/default-web-app/ (New server version detected)...
    Oracle9iAS (9.0.3.0.0) Containers for J2EE initialized
    6. Close the Oracle AS server.

    7. Extract the lib/log4j-1.2.8.jar to the following directory:
    OC4JROOT\j2ee\home\connectors\attunity\attunityRes ourceAdapter
    8. Extract samples/log4j.properties to the follow directory:
    OC4JROOT\j2ee\home\lib
    9. Creating deployment configuration

    After the deployment of the new adapter, a directory called "attunity" is automatically created by the OC4J server, under the "application-deployments":
    OC4JROOT\j2ee\home\application-deployments\default\attunity
    The directory contains a default deployment descriptor for the newly deployed Attunity Resource Adapter.

    Add the following connector factory definition to the oc4j-ra.xml:

    HTML Code:
    <CONNECTOR-FACTORY connector-name="Attunity Connect Legacy Adapter" location="eis/attunityQUERY"><CONFIG-PROPERTY value="" name="userName" /> 
    <CONFIG-PROPERTY value="nav" name="password" /> 
    <CONFIG-PROPERTY value="query" name="eisName" /> 
    <CONFIG-PROPERTY value="myserver" name="serverName" /> 
    <CONFIG-PROPERTY value="Navigator" name="workspace" /> 
    <CONFIG-PROPERTY value="2551" name="portNumber" /> 
    <CONFIG-PROPERTY value="true" name="persistentConnection" /> 
    <CONFIG-PROPERTY value="true" name="keepAlive" />
    <CONFIG-PROPERTY value="" name="firewallProtocol" /> 
    <CONFIG-PROPERTY value="" name="connectTimeout" /> 
    <CONFIG-PROPERTY value="" name="encryptionProtocol" />
    <CONFIG-PROPERTY value="" name="encryptionKeyName" /> 
    <CONFIG-PROPERTY value="" name="encryptionKeyValue" /> 
    <CONFIG-PROPERTY value="false" name="fakeXA" /> </CONNECTOR-FACTORY>
    This creates a new EIS connection called "eis/attunityQUERY", which connects to an Attunity Connect daemon on the "myserver" machine at port number 2551.

    The connection is created for the "Query" adapter of Attunity Connect, which provides access to all of the product SQL capabilities.

    Getting a Connection

    Getting a connection from your JCA application is a matter of looking up the JNDI name of the connector-factory, defined in the previous section.

    To get a connection:
    Context ic = new InitialContext();

    // Lookup connection
    String name = "eis/attunityQUERY";

    AttuConnectionFactory cf = (AttuConnectionFactory)ic.lookup(name);
    Query Sample

    The attached Query Sample, is a simple JSP application, which uses the connector-factory defined previously in this document, and allows the user to execute any Select query against the Attunity Connect server "myserver".

    Copy the sample files:
    • connectQuery.jsp
    • connectRun.jsp
    to the following directory:
    OC4JROOT\j2ee\home\default-web-app
    To run the demo, start the OC4J server, and point your web browser to the following URL (assuming default settings, and the OC4J running locally):
    HTML Code:
     http://localhost:8888/connectQuery.jsp
    Enter the SQL Query and hit [Execute]. Here is an example:-
    Last edited by Adeeb Mass'ad; 02-23-2007 at 08:31 AM.
    To Find Out more About Attunity Technology:
    Attunity
    or:
    Contact Us

  2. #2
    Adeeb Mass'ad is offline Support Manager
    Join Date
    Aug 2006
    Location
    Jaffa of Nazareth
    Posts
    169
    Rep Power
    14

    Attunity JCA oc4j-ra.xml properties

    Here are the details of each oc4j-ra.xml connection factory configuration property:
    • location is set to the location specified in Oracle Application Server.
    • userName is set to a valid user who can access the server machine where the adapter runs.
    • password is set to a valid password for that user.
    • eisName is set to the adapter to use. You must provide a value for this field.
    • serverName is set to the server machine TCP/IP host name. The host name is the name of the machine where the daemon runs. You must provide a value for this field.
    • workspace is set to the name of a server workspace to use. The default workspace is Navigator.
    • portNumber is set to the TCP/IP port where the daemon is running. The default port is 2551.
    • persistentConnection is set to true or false. When set to true, connections can persist across multiple requests or connection context changes. The value should be set to true.
    • keepAlive is set to true or false. When set to true, the socket used for the connection is always kept open. The value should be set to true.
    • firewallProtocol is set to the firewall protocol used: either none or fixedNat (the Nat protocol using a fixed address for the daemon). The default is none.
    • connectTimeout is set to the connection timeout in seconds. The default is 0, meaning that there is no connection timeout.
    • encryptionProtocol is set to the name of encryption protocol to use. The default is null. The RC4 protocol is supported.
    • encryptionKeyName is set to the name of the symmetric encryption key to use.
    • encryptionKeyValue is set to the value of the symmetric encryption key to use.
    • fakeXa is set to true or false. When set to true, The XA APIs are converted internally to local transaction APIs.
    To Find Out more About Attunity Technology:
    Attunity
    or:
    Contact Us

  3. #3
    Adeeb Mass'ad is offline Support Manager
    Join Date
    Aug 2006
    Location
    Jaffa of Nazareth
    Posts
    169
    Rep Power
    14

    Deployment steps for the newer attunityResourceAdapter

    DESCRIPTION

    The newer versions of the attunityResourceAdapter is packaged differently than described in the article.

    The adapter is now separated into two JAR files:
    • attunityCoreResourceAdapter.jar
    • attunityResourceAdapter.jar
    The Core package includes all of the common interfaces to the different variations of the attunity Connector.

    SOLUTION

    Read the main article and wherever it mentions to copy the attunityResourceAdapter.rar to some directory, also copy the attunityCoreResourceAdapter.jar. When installing as instructed:
    • oc4jROOT\j2ee\home\connectors\attunity\attunityRes ourceAdapter
    • oc4jROOT\j2ee\home\lib
    If you are using an older version of the OC4J product make sure to copy the log4j-1.2.8.jar which comes with the Attunity adapter to the sub-directories listed previously.

    Attached is the modified sample, where we now include the imports from the Core package as follows:

    HTML Code:
    <%@ page import="com.attunity.adapter.*" %>
    <%@ page import="com.attunity.adapter.core.*" %>
    <%@ page import="com.attunity.adapter.core.acp.*" %>
    And modified the code to use the DomRecord/DOMWriter from the Core package as well:
    CoreDomRecord domOut = (CoreDomRecord)oRecOut;
    CoreDOMWriter domWriter = new CoreDOMWriter(false);
    Last edited by Adeeb Mass'ad; 03-20-2007 at 01:24 PM.
    To Find Out more About Attunity Technology:
    Attunity
    or:
    Contact Us

  4. #4
    sjcurt01 is offline Junior Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Log4j configuration problem

    I've run into a problem using the jca-legacy-adapter connector along with a project that also utilizes log4j. If I include the log4j library in my project and run, log4j will exit with the following exception:

    oracle.classloader.util.AnnotatedLinkageError: duplicate class definition: org/apache/log4j/Logger

    Invalid class: org.apache.log4j.Logger
    Loader: current-workspace-app.web.Application1-Project2-webapp:0.0.0
    Code-Source: /C:/Data/maven/repository/log4j/log4j/1.2.8/log4j-1.2.8.jar
    Configuration: <classpath> in C:\Program Files\jdevj2eebase10134\jdev\mywork\Application1\P roject2\public_html

    Dependent class: _index
    Loader: current-workspace-app.web.Application1-Project2-webapp.jsp5138683:0.0.0
    Code-Source: /C:/Program Files/jdevj2eebase10134/jdev/mywork/Application1/Project2/classes/.jsps/
    Configuration: *.jsp in C:\Program Files\jdevj2eebase10134\jdev\mywork\Application1\P roject2\classes\.jsps

    The original class instance was defined in the shared-library jca-legacy-adapter:0.0.0, and current-workspace-app.web.Application1-Project2-webapp.jsp5138683:0.0.0 does import that loader. This may be a search-order problem.

    If I don't include the log4j library in my project, the project will run fine using the log4j classes from the library packaged with the jca-legacy-adapter, but will not compile because log4j is not included in the project. Is there a way to include log4j at compile time but to exclude it at runtime in the JDeveloper project configuration?

  5. #5
    sjcurt01 is offline Junior Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Found alternative solution

    To date I have not found a way to specify different classpaths for build vs run time, but with help from a colleague, a solution to my specific situation was stumbled upon. Even though the connector is not a JDev project, the dependent project can reference the log4j jar file that is packaged and loaded with it. That effectively mimics the behavior at runtime, for both standalone as well as embedded oc4j container deployment, in which the web application and associated application code link to the log4j instance loaded by the 3rd party JCA connector's classloader. I did not think this would work assuming that a log4j library loaded by two different classloaders would still appear to be two distinct instances of the library with respect to log4j's static initializers. (That is what I am presuming motivates log4j to throw an exception if it finds another instance of itself in the classloader hierarchy.) Apparently this is not the case, at least for the embedded scenario. I do not have to test this for the standalone container since the Maven build knows not to include a copy of the log4j library jar in the application EAR file via the "provided" scope specification in the build file. The embedded OC4J container now loads the JCA connector, the associated log4 library instance, deploys the application, and allows both to use the log4j classes from the same log4j library file. Not entirely sure of how the connector and web applications classloaders interact, but it works now.

  6. #6
    smilicevics@gmx.net is offline Junior Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Tuxedo Attunity NullPointerException

    we are using Attunity resource adapter for tuxedo for the last three years (outbound and inbound). We used it in conjuction with our BPEL-processes.

    But now we want to use it directly from EJB using CCI. I installed locally Oracle AS 10.1.3.5 and deployed attunity resource adapter, copied both .jar (Core and Resource) to .../home/applib and copied log4j.properties in the same directory. Define connection factory and interaction with Oracle Connect Studio.

    The problem is that we keep getting NullPointerException in call to AttuInteractionSpec.setLogger method. Does anybody know what is the solution here.

    Hier is our source code:

    Context context = new InitialContext();

    ConnectionFactory connectionFactory = (ConnectionFactory)context.lookup("eis/legacy/TUX_MTA");

    Connection connection = connectionFactory.getConnection();
    Interaction interaction = connection.createInteraction();

    String routing = "1";
    String target = "ADS_IF20";
    String payload = "<xml><author>el2_sm</author>";

    // here we got NullPointerException
    AttuInteractionSpec spec = new AttuInteractionSpec("SMBK_MTA", InteractionSpec.SYNC_SEND_RECEIVE, 60);

    RecordFactory recordFactory = connectionFactory.getRecordFactory();

    MappedRecord input = recordFactory.createMappedRecord("input_fml");

    input.put(ROUTING_INST, "1");
    input.put(ROUTING_DIS, target);
    input.put(FI_DATUM, payload);

    Record output = interaction.execute(spec, input);
    interaction.close();
    connection.close();

  7. #7
    Costi Zaboura is offline World Wide Support Manager
    Join Date
    Aug 2006
    Posts
    300
    Rep Power
    14
    Please verify that you have copied also the log4j.jar to your environment.

    thx
    Costi
    To Find Out more About Attunity Technology:
    Attunity
    or:
    Contact Us

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •