Howto use ActiveX made in VB in LabView

Hi,
In LabView you can make a container for an ActiveX object.
I have made an ActiveX component in Visual Basic. How can I access this in
LabView. If I make an ActiveX dll I cannot find the functions in LabView. If
I make and ActiveX ocx I cannot find the object in the object list in
LabView.
What are the constraints in LabView regarding ActiveX components?
Thanks
Leif H

Leif,
I previously used ActiveX containers created in VB (most are) in a LabVIEW project. If memory serves, all I did was to place the OCX in a file, and manually browse to it using the Active X browser. I had trouble with registering due to some bug or "feature" that wouldn't update the OCX from the registry in LabVIEW. Everytime we updated the OCX, it would break all of our code. Our solution was to NOT register it, and browse to it manually. That worked great.
So, drop in a container open or invoke node on your diagram, right click to open the browser, and choose "Browse" to the right of the name. This will allow you to browse directly to an OCX.
I strongly recommend placing your OCXs in an embedded file within your deployment file structure.
That will make it much easier when you deploy your project.

Similar Messages

  • How can i use activeX Control in labview?

    how can i use activeX Control in labview?
    please describe me step by step.
    thanks.

    Well..that was quite helpful..but now I'm encountering certain problems. I've attached the VI I've made.
    I don't need sound at the moment so I dropped it. (Although I tried to play it..but all I could hear was a very annoying sound.) Secondly I don't want to display any date or time..so i dropped that property too.
    Now when I run this Vi...the webcam turns on, the screen of videocapx pops up..then the webcam light goes off..and another pop up appears saying..labview is not responding..and i have to close it reluctantly.
    I haven't placed the stop capture property in this vi. i checked it by placing it too..but that doesn't work.
    I would like to notify that my actual task is to acquire image and then compare it with another one already present on my pc. I want you to please help me out..solve my first query then I'll proceed with the latter part.
    Attachments:
    activexvideocaps.vi ‏20 KB

  • How to create a table in MS Access from Labview using ActiveX?

    I want to transfer datas from Labview to Access using activeX method. My only problem is to find out how to create a new table (array) in Access from the Labview program.
    Remarks: I use Labview 6i and MS Access 2000.
    For the moment I can write and read datas of Access from Labview.
    If someone could help me... that would be grate!

    This is off the Microsoft MSDN site "creating an external table". I think you can drop the last step.:
    Open the database you want to create the table in. If it is the current database, use the CurrentDb function to return an object variable that represents the current database. If it isn�t the current database, use the OpenDatabase method to open the database you want.
    Use the CurrentDb function to create a Database object that points to the current database.
    Use the CreateTableDef method of the Database object to create a table definition for the Microsoft Access table.
    Use the CreateField method of the TableDef object to create one or more fields in the Microsoft Access table.
    Use the Append method of the Fields collection to add the new field or fields t
    o the Microsoft Access table.
    Use the Append method of the TableDefs collection to create the Microsoft Access table.
    Use the TransferDatabase method to create the external table in the specified folder.
    Use the Delete method of the TableDefs collection to delete the Microsoft Access table definition.

  • Read an AutoCAD drawing In Labview using ActiveX

    I want to read an AutoCAD drawing (.dwg) in the LabVIEW using Activex
    plz send me the procedure for it & the Library files that will be required to get the objects.

    Had to change the labview background color. Here is an image of a dwg file inside the activex control.
    Attachments:
    autocad dwg document inside labview.PNG ‏113 KB

  • Exporting figures to word from labview using activex??

    Does anybody know how to export figures into MS Word, XP edition from LabVIEW using activex. I am not using the report generation toolkit...dont have it....help wld be appreciated
    kuttu

    Here are some examples you can use. they all use activeX. One is even a toolkit I got from somewhere.Try these and if you have any more questions let me know.
    Joe.
    "NOTHING IS EVER EASY"
    Attachments:
    word.zip ‏1226 KB

  • LabView interface with DLL that uses ActiveX

    I've written a DLL using Microsoft Visual Studio 2005. This DLL uses ActiveX (MSXML4.0). It works fine being called from other applications created in Microsoft Visual Studio. It crashes being called from LabView 7.1. By commenting out everything, I've figured out that it crashes on the call to ActiveX (no problems if this call is commented out). What should I do to make it work?
    I've tried using CoInitialize at the initialization of DLL; it didn't solve the problem.
    Additional information: DLL is using MFC in a Static Library, not using ATL, Character set = Not Set.
    The functions are defined in C calling convention (not __stdcall).
    Please help.
    Thank you.
    Irina Kaliniouk

    Thank you for your answer, but that is not the case. There is no UI in this DLL, but it is using some convinenient MFC classes, like threads, CString, etc. The threading really was not even involved in the example that crashed. The function that crashed was
    selectNodes on MSXML2::IXMLDOMNodePtr. Here is the code:
    MSXML2::IXMLDOMNodeListPtr selectNodes (LPCTSTR expression, MSXML2::IXMLDOMNodePtr pStartNode)
    CComBSTR quesryBstr (expression);
    return pStartNode->selectNodes (quesryBstr.m_str); //_bstr_t(expression));
    where the pStartNode was a root node of
    MSXML2::IXMLDOMDocument2Ptr m_pXMLDoc;
    hr = m_pXMLDoc.CreateInstance ("Msxml2.DOMDocument.4.0", NULL, CLSCTX_INPROC_SERVER);
    I commented out really everything except this function, so there was nothing to corrupt the memory or any other problems.  
    What can be of a problem?
    Thanks.

  • How would I embed NetMeeting in Labview 6i using ActiveX?

    I would like to use my USB Webcam through netmeeting to run in Labview.I initially wanted to use a Java Applet and looked at Webcam 32 but I thought a cheaper option would be to use ActiveX. I would also like to be able to use netmeetings controls. I have been trying to figure out a way for a while but I am easily confused with Labview!

    The original question is from a month ago but hopefully this will be helpful still to you.
    You can definitely control NetMeeting using ActiveX and LabVIEW. All you need is to have NetMeeting and its ActiveX control installed on your machine. Then use the following method to get the NetMeeting controls on your LabVIEW VI Front Panel.
    1. Place an ActiveX Container on the Front Panel (Controls Palette >> ActiveX >> Container)
    2. Right click inside of the container and select Insert ActiveX Object...
    3. Select from the list the ActiveX Control named NetMeeting.
    The container will then have an instance of NetMeeting in the ActiveX container. I followed these exact steps above and created this VI which is just a NetMeeting control i
    n an ActiveX container.
    Hopefully this information is helpful. I created the example in LabVIEW 6i.
    -scraggs99
    Attachments:
    NetMeeting_in_LabVIEW.vi ‏9 KB

  • Calling LabVIEW from C# Using ActiveX?

    Hi,
    I try to call LabVIEW VI's from C# using ActiveX/COM, but I am not
    successful. I was able to do this from C++ and there are nice articles on
    the NI site dealing with the C++ integration.
    I tried to follow the instructions of the C# help, using a wrapper for the
    LabVIEW application call. I included the TypeLib that I created with the
    tlbimp-tool in my project. Basically my code looks like this:
    LabView50TypeLib._Application myLV = new
    LabView50TypeLib.ApplicationClass() ;
    LabView50TypeLib.VirtualInstrument myVI = new
    LabView50TypeLib.VirtualInstrument();
    myVI = myLV.GetVIReference(,?,?);
    myVI.SetControlValue();
    myValue= myVI.GetControlValue();
    myLV.Quit();
    I even don't know if the fi
    rst line is correct. I know that the second line
    is not OK, because there is no class "VirtualInstrument" - but from what
    class should I derive my instance for the VirtualInstrument? And different
    from my C++ implementation, the GetVIReference now needs 3 parameters
    instead of 1 (the path).
    What am I doing wrong? Does anybody have a working example on this?
    Thanks a lot & best regards,
    Martin Schellenberger

    Hello
    After adding a reference to the LabVIEW type lib to the project (I just to o to Project >> Add Reference and I browse for the typelib myself), and including the labview namespace at the top,here is what I tried
    using LabVIEW;
    //form code here
    //Event for button code
    LabVIEW.Application lv = new LabVIEW.ApplicationClass();
    LabVIEW.VirtualInstrument vi= lv.GetVIReference(@"c:\a.vi","",false);
    vi.FPWinOpen=true;
    vi.Run(true);
    So all it does is it opens the VI and runs it, seems to work fine. Hope this helps
    Bilal Durrani
    NI
    Bilal Durrani
    NI

  • How does labVIEW use ActiveX controls?

    How does labVIEW use activeX controls?
    I recently wrote an activeX control in VB and noticed that it would not work if the control was set so that its properties could not be set in ambient mode. This may suggest that labVIEW uses some activeX controls only in ambient mode.
    Is this the case or are there more complexities?

    Dan,
    Which version of LabVIEW do you have?
    As per the KnowledgeBase bellow, in versions of LabVIEW prior to 5.1 you would get errors accessing the ambient properties.
    ActiveX Controls in LabVIEW 5.0.1 Containers Cannot Access Ambient Property
    Do your controls use the Ambient.UserMode to determine when the control is being used in a development environment? When embedding ActiveX controls into a container on the front panel, by default, the ActiveX control generates and responds to events, i.e. it is running, even when LabVIEW is in edit mode.
    Right-click an ActiveX container and select Advanced»Design Mode from the shortcut menu to display the container
    in design mode while you edit the VI. In design mode, events are not generated and event procedures do not run. The default mode is run mode, where you interact with the object as a user would.
    Information can be found in the LabVIEW help files
    Zvezdana S.

  • Problem using ActiveX for excel app to determine row/col no.s

    hello,
    I would like to develop an app, which would find out the total no. of rows and columns from a given excel sheet and read out the data in the same. I have made use of few vi's I found on forum, but having trouble runing them,
    can anyone please suggest me what could I be doing wrong? I have never used activex before...
    Now on LabVIEW 10.0 on Win7
    Solved!
    Go to Solution.
    Attachments:
    excel used range.vi ‏25 KB
    test.vi ‏19 KB
    read_excel_values.llb ‏382 KB

    Hi
    Yesterday I sent an email to a guy, explaining how to install it. Download the toolkit and the instructions I have attached and you should be fine.
    Regards,
    Even
    Certified LabVIEW Associate Developer
    Automated Test Developer
    Topro AS
    Norway
    Attachments:
    _Excel.zip ‏1393 KB
    Howto Install Excel Toolkit.pdf ‏1270 KB

  • Writing to Excel using ActiveX improvement?

    Hello,
    At my company we have Labview 2011 basic version with DAQmx. I am writing a program to get temperature data from thermocouples (16), dump it in an array and then store it in Excel using ActiveX. ActiveX seems only to allow writing element by element to my spreadsheet.  When you do acquisition for a long period of time it can be very long! I like using ActiveX because it allows some flexibility such as choosing which sheet and cell I can write my data. Is there a solution to dump the array in one operation using ActiveX?
    I know there is a block call write to spreadsheet which accept 1D and 2D array of data but doesn't allow the same flexibility. I also found report generation but is it made to write data? While waiting for your answer I'll try to dig a little more that blockset.
    Thank you very much and I hope to hear from the community really soon.
    Regards

    I have to appologize. The solution given by Electromecha was good but only outside a loop. Again, I have 16 thermocouples and when I use Electromecha's solution inside a For loop it will copy only the first element. I attached two pictures. One is the program and the second is the result in the spreadsheet. You will notice that inside my loop I added an indicator to read the array before writing it in Excel. The indicator shows the array perfectly with all elements in it. The only way I found to work around this issue is to use indexing and write element by element in Excel. That is way too long!
    For your information, the loop itteration is defined using the array size which is 16 (for 16 thermocouples). The subvi inside the loop allows me to get the column letter from the itteration number. Finally using the size of one full array of results I get the end cell row. 
    If more explanation is required please let me know. 
    Many thanks!
    Attachments:
    Excel.JPG ‏89 KB
    Program.JPG ‏69 KB

  • How do I get an activeX object reference from a LabVIEW ActiveXContainer ref?

    How do I get an activeX object reference from a LabVIEW ActiveXContainer ref?
    I'm trying to control an ActiveX object (a Web Browser) from another VI and need to get the object reference programmatically. I can get the LabVIEW ActiveXContainer reference, but am lost on how to get the reference for the object _inside_ the container.

    Hi Lee,
    The reference to the container is actually also accessing the object inside the container. Use the Property Node and Invoke Node to access properties and launch methods for the object. I've attached a small example that passes the reference to a SubVI and invokes a method inside the SubVI.
    - Philip Courtois, Thinkbot Solutions
    Attachments:
    WebContainer.zip ‏21 KB

  • How to control and display video from IP camera using ActiveX control over Internet.

    Hello,
    I need to control my IP cameras over the internet. I need to log into the cameras and then display the video.  There's an ActiveX control registered on the computer and works fine with IE to access and control the cameras. Controlling the cameras using IE works fairly well, but there are some quirks that I'd like to eliminate by using my own custom code.
    Has anyone created a vi that controls a Foscam FI8905W over the Internet? I’ve attempted, but I keep getting a catastrophic failure when I try to call ManagementConnect Method in the DVM_IPCam2 ActiveX Control Module V1.0. I'm not sure whether I need to establish an IP connection with the cameras first, or allow the ActiveX control to establish it for me.
    Some example code would be greatly appreciated. Running LabVIEW 2011 on a Win7 32bit.  Even some code used to control a similar device using ActiveX over Internet would be helpful.

    I have an example vi for interfacing to the foscam activex.
    I plan on using mouse click events within the activex window to trigger the PT function.
    I only have the basic up/down/right/left directions and not the down-right/down-left/up-right/up-left in the enum.  You can load the camera's web page and view the source to see the Java script code that uses the activex control.  There are definitions for the other directions.
    I had to mark the control as "Disabled" to keep click events from going to the activex control.  If I double click the control, it goes full screen.  If I then click on it to get out of full screen mode the video never returns or returns to the wrong spot in the VI.
    Attachments:
    Foscam Demo.vi ‏24 KB

  • How can I add excel pictures using activex

    I would like to be able to use activex to insert an image into an excel spreadsheet. I know how to read and write data, but the chart feature is too cunmbersome and when I updated excel to 2007 most of the calls stopped working. I see that there is a pictures property/method that lets me specify an image file, but I don't know which property/method(s) to call it from.

    2007 does take more time to draw the data on the chart. I am not having any problems with errors on the active X for 2007. I is much slower than 2003 I would agree. My IT group moved us to 2007 so I am stuck with it no matter how slow it is. I am trying to figure out how to get the help file back. I had these in 2003 myself. I know it has nothing to do with LabVIEW. It is an add in or some switch that you need to throw in excel to allow for this connection.
    Tim
    Johnson Controls
    Holland Michigan

  • HOWTO: Using a BC4J Application Module in an Stateless EJB Session Bean

    HOWTO: Using a BC4J Application Module in an Stateless EJB Session Bean
    by Steve Muench
    Overview
    BC4J provides automatic facilities for deploying any application module as a stateful EJB session bean. If you want to leverage the features of your BC4J application module from a stateless EJB session bean, it's not automatic but it is straightforward to implement. This howto article explains the details.
    For our example, we will create a stateless EJB session bean that uses a container-managed transaction. To keep things simple, let's assume the session bean has a single public method on its remote interface named createDepartment() with the following signature:
    public void createDepartment(int id, String name, String loc) throws AppException
    AppException is an example of an application-specific exception that our method will throw if any problems arise during its execution.The goal of this article is to illustrate how to use the BC4J application module named com.example.hr.HRApp as part of the implementation of this createDepartment method on our stateless enterprise bean. Let's assume that the HRApp application module has a view object member named Departments, based on the com.example.hr.DeptView view object, based on the familiar DEPT table and related to the com.example.hr.Dept entity object so our view can be updateable.
    Creating the Stateless Session Bean
    We can start by using the JDeveloper Enterprise Bean wizard to create a new stateless session bean called StatelessSampleEJB implemented by:[list][*]com.example.StatelessSampleEJBBean (Bean class)[*]com.example.StatelessSampleEJBHome (Home interface)[*]com.example.StatelessSampleEJB (Remote interface)[list]
    We then use the EJB Class Editor to add the createDepartment method to the remote interface of StatelessSampleEJB with the signature above. We edit the remote interface to make sure that it also reflects that the createDepartment method thows the AppException like this:
    package com.example;
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    public interface StatelessSampleEJB extends EJBObject {
      void createDepartment(int id, String name, String loc)
      throws RemoteException,AppException;
    }Before we start adding BC4J into the picture for our implementation, our StatelessSampleEJBBean class looks like this:
    package com.example;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    public class StatelessSampleEJBBean implements SessionBean {
      public void ejbCreate(){}
      public void ejbActivate(){}
      public void ejbPassivate(){}
      public void ejbRemove(){}
      public void setSessionContext(SessionContext ctx){
      public void createDepartment(int id, String name, String loc) 
      throws AppException {
        // TODO: Implement method here
    }We can double-click on the ejb-jar.xml file in our project to see the XML deployment descriptor for the bean we just created:
    <ejb-jar>
       <enterprise-beans>
          <session>
             <description>Session Bean ( Stateless )</description>
             <display-name>StatelessSampleEJB</display-name>
             <ejb-name>StatelessSampleEJB</ejb-name>
             <home>com.example.StatelessSampleEJBHome</home>
             <remote>com.example.StatelessSampleEJB</remote>
             <ejb-class>com.example.StatelessSampleEJBBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
          </session>
       </enterprise-beans>
    </ejb-jar>We need to add the extra <assembly-descriptor> section in this file to indicate that the createDepartment method will require a transaction. After this edit, the ejb-jar.xml file looks like this:
    <ejb-jar>
       <enterprise-beans>
          <session>
             <description>Session Bean ( Stateless )</description>
             <display-name>StatelessSampleEJB</display-name>
             <ejb-name>StatelessSampleEJB</ejb-name>
             <home>com.example.StatelessSampleEJBHome</home>
             <remote>com.example.StatelessSampleEJB</remote>
             <ejb-class>com.example.StatelessSampleEJBBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
          </session>
       </enterprise-beans>
       <assembly-descriptor>
          <container-transaction>
             <method>
                <ejb-name>StatelessSampleEJB</ejb-name>
                <method-name>createDepartment</method-name>
                <method-params>
                   <method-param>int</method-param>
                   <method-param>java.lang.String</method-param>
                   <method-param>java.lang.String</method-param>
                </method-params>
             </method>
             <trans-attribute>Required</trans-attribute>
          </container-transaction>
       </assembly-descriptor>
    </ejb-jar>
    Aggregating a BC4J Application Module
    With the EJB aspects of our bean setup, we can proceed to implementing the BC4J application module aggregation.
    The first thing we do is add private variables to hold the EJB SessionContext and the instance of the aggregated BC4J ApplicationModule, like this:
    // Place to hold onto the aggregated appmodule instance
    transient private ApplicationModule _am  = null;
    // Remember the SessionContext that the EJB container provides us
    private           SessionContext    _ctx = null;and we modify the default, empty implementation of the setSessionContext() method to remember the session context like this:
    public void setSessionContext(SessionContext ctx){ _ctx = ctx; }We add additional constants that hold the names of the J2EE datasource that we want BC4J to use, as well as the fully-qualified name of the BC4J application module that we'll be aggregating:
    // JNDI resource name for the J2EE datasource to use
    private static final String DATASOURCE = "jdbc/OracleCoreDS";
    // Fully-qualified BC4J application module name to aggregate
    private static final String APPMODNAME = "com.example.hr.HRApp";We expand the now-empty ejbCreate() and ejbRemove() methods to create and destory the aggregated instance of the BC4J application module that we'll use for the lifetime of the stateless session bean. When we're done, ejbCreate() it looks like this:
    public void ejbCreate() throws CreateException {
      try {
        // Setup a hashtable of environment parameters for JNDI initial context
        Hashtable env = new Hashtable();
        env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
        // NOTE: we want to use the BC4J app module in local mode as a simple Java class!
        env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
        env.put(PropertyConstants.INTERNAL_CONNECTION_PARAMS,DATASOURCE);
        // Create an initial context, using this hashtable of environment params
        InitialContext ic = new InitialContext(env);
        // Lookup a home interface for the application module
        ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(APPMODNAME);
        // Using the home, create the instance of the appmodule we'll use
        _am = home.create();
        // Register the BC4J factory to handle EJB container-managed transactions
        registerContainerManagedTransactionHandlerFactory();
      catch(Exception ex) {
         ex.printStackTrace();
        throw new CreateException(ex.getMessage());
    }and ejbRemove() looks like this:
    public void ejbRemove() {
      try {
        // Cleanup any appmodule resources before getting shutdown
        _am.remove();
      catch(JboException ex) { /* Ignore */ }
    }The helper method named reigsterContainerManagedTransactionHandlerFactory() looks like this:
    private void registerContainerManagedTransactionHandlerFactory() {
      SessionImpl session = (SessionImpl)_am.getSession();
      session.setTransactionHandlerFactory(
        new TransactionHandlerFactory() {
          public TransactionHandler  createTransactionHandler() {
            return new ContainerManagedTxnHandlerImpl();
          public JTATransactionHandler createJTATransactionHandler() {
            return new ContainerManagedTxnHandlerImpl();
    }The last detail is to use the BC4J appmodule to implement the createDepartment() method. It ends up looking like this:
    public void createDepartment(int id, String name, String loc)
    throws AppException {
      try {
        // Connect the AM to the datasource we want to use for the duration
        // of this single method call.
        _am.getTransaction().connectToDataSource(null,DATASOURCE,false);
        // Use the "Departments" view object member of this AM
        ViewObject departments = _am.findViewObject("Departments");
        // Create a new row in this view object.
        Row newDept = departments.createRow();
        // Populate the attributes from the parameter arguments.
        newDept.setAttribute("Deptno", new Number(id));
        newDept.setAttribute("Dname", name);
        newDept.setAttribute("Loc", loc);
        // Add the new row to the view object's default rowset
        departments.insertRow(newDept);
        // Post all changes in the AM, but we don't commit them. The EJB
        // container managed transaction handles the commit.
        _am.getTransaction().postChanges();
      catch(JboException ex) {
        // To be good EJB Container-Managed Transaction "citizens" we have
        // to mark the transaction as needing a rollback if there are problems
        _ctx.setRollbackOnly();
        throw new AppException("Error creating dept "+ id +"\n"+ex.getMessage());
      finally {
        try {
          // Disconnect the AM from the datasource we're using
          _am.getTransaction().disconnect();
        catch(Exception ex) { /* Ignore */ }
    Building a Test Client
    With the EJB-Tier work done, we can build a sample client program to test this new stateless EJB Session Bean by selecting the bean in the Oracle9i JDeveloper IDE and choosing "Create Sample Java Client" from the right-mouse menu.
    When the "Sample EJB Client Details" dialog appears, we take the defaults of connecting to embedded OC4J container. Clicking the (OK) button generates the following test class:
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import com.example.StatelessSampleEJB;
    import com.example.StatelessSampleEJBHome;
    public class SampleStatelessSampleEJBClient {
      public static void main(String [] args) {
        SampleStatelessSampleEJBClient sampleStatelessSampleEJBClient =
           new SampleStatelessSampleEJBClient();
        try {
          Hashtable env = new Hashtable();
          env.put(Context.INITIAL_CONTEXT_FACTORY,
                  "com.evermind.server.rmi.RMIInitialContextFactory");
          env.put(Context.SECURITY_PRINCIPAL, "admin");
          env.put(Context.SECURITY_CREDENTIALS, "welcome");
          env.put(Context.PROVIDER_URL,
                  "ormi://localhost:23891/current-workspace-app");
          Context ctx = new InitialContext(env);
          StatelessSampleEJBHome statelessSampleEJBHome =
               (StatelessSampleEJBHome)ctx.lookup("StatelessSampleEJB");
          StatelessSampleEJB statelessSampleEJB;
          // Use one of the create() methods below to create a new instance
          // statelessSampleEJB = statelessSampleEJBHome.create();
          // Call any of the Remote methods below to access the EJB
          // statelessSampleEJB.createDepartment( int id, java.lang.String name, java.lang.String loc );
        catch(Throwable ex) {
          ex.printStackTrace();
    }We uncomment the call to the create() method and add a few calls to the createDepartment() method so that the body of the test program now looks like this:
    // Use one of the create() methods below to create a new instance
    statelessSampleEJB = statelessSampleEJBHome.create();
    // Call any of the Remote methods below to access the EJB
    statelessSampleEJB.createDepartment( 13, "Test1","Loc1");
    System.out.println("Created department 13");
    statelessSampleEJB.createDepartment( 14, "Test2","Loc2");
    System.out.println("Created department 14");
    try {
      // Try setting a department id that is too large!
      statelessSampleEJB.createDepartment( 23456, "Test3","Loc3");
    catch (AppException ax) {
      System.err.println("AppException: "+ax.getMessage());
    }Before we can successfully run our SampleStatelessSampleEJBClient we need to first run the EJB bean that the client will try to connect to. Since Oracle9i JDeveloper supports local running and debugging of the EJB-Tier without doing through a full J2EE deployment step, to accomplish this prerequisite step we just need to right-mouse on the StatelessSampleEJB node in the System Navigator and select "Run". This starts up the embedded OC4J instance and runs the EJB right out of the current out path.Finally, we can run the SampleStatelessSampleEJBClient, and see the output of the test program in the JDeveloper log window:
    Created department 13
    Created department 14
    AppException: Error creating dept 23456
    JBO-27010: Attribute set with value 23456 for Deptno in Dept has invalid precision/scale
    Troubleshooting
    One error that might arise while running the example is that the database connection information in your data-sources.xml for the jdbc/OracleCoreDS datasource does not correspond to the database you are trying to test against. If this happens, then double-check the file .\jdev\system\oc4j-config\data-sources.xml under the JDeveloper installation home directory to make sure that the url value provided is what you expect. For example, to work against a local Oracle database running on your current machine, listening on port 1521, with SID of ORCL, you would edit this file to have an entry like this for jdbc/OracleCoreDS :
    <data-source
        class="com.evermind.sql.DriverManagerDataSource"
        name="OracleDS"
        location="jdbc/OracleCoreDS"
        xa-location="jdbc/xa/OracleXADS"
        ejb-location="jdbc/OracleDS"
        connection-driver="oracle.jdbc.driver.OracleDriver"
        username="scott"
        password="tiger"
        url="jdbc:oracle:thin:@localhost:1521:ORCL"
        inactivity-timeout="30"
    />This is the data-sources.xml file that gets used by the embedded OC4J instance running in JDeveloper.
    Conclusion
    Hopefully this article has illustrated that it is straightforward to utilize the full power of BC4J in local mode as part of your EJB Stateless Session Beans using container-managed transaction. This example illustrated a single createDepartment method in the enterprise bean, but by replicating the application module interaction code that we've illustrated in createDepartment, any number of methods in your stateless session bean can use the aggregated application module instance created in the ejbCreate() method.
    Code Listing
    The full code listing for the SampleStatelessEJB bean implementation class looks like this:
    * StatelessSampleEJB
    * Illustrates how to use an aggregated BC4J application module
    * in local mode as part of the implementation of a stateless
    * EJB session bean using container-managed transaction.
    * HISTORY
    * smuench/dmutreja 14-FEB-2002 Created
    package com.example;
    import oracle.jbo.*;
    import oracle.jbo.server.*;
    import javax.ejb.*;
    import oracle.jbo.domain.Number;
    import oracle.jbo.common.PropertyConstants;
    import java.util.Hashtable;
    import javax.naming.InitialContext;
    import oracle.jbo.server.ejb.ContainerManagedTxnHandlerImpl;
    public class StatelessSampleEJBBean implements SessionBean {
      // JNDI resource name for the J2EE datasource to use
      private static final String DATASOURCE = "jdbc/OracleCoreDS";
      // Fully-qualified BC4J application module name to aggregate
      private static final String APPMODNAME = "com.example.hr.HRApp";
      // Place to hold onto the aggregated appmodule instance
      transient private ApplicationModule _am  = null;
      // Remember the SessionContext that the EJB container provides us
      private           SessionContext    _ctx = null;
      public void ejbCreate() throws CreateException {
        try {
          // Setup a hashtable of environment parameters for JNDI initial context
          Hashtable env = new Hashtable();
          env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
          env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
          env.put(PropertyConstants.INTERNAL_CONNECTION_PARAMS,DATASOURCE);
          // Create an initial context, using this hashtable of environment params
          InitialContext ic = new InitialContext(env);
          // Lookup a home interface for the application module
          ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(APPMODNAME);
          // Using the home, create the instance of the appmodule we'll use
          _am = home.create();
          // Register the BC4J factory to handle EJB container-managed transactions
          registerContainerManagedTransactionHandlerFactory();
        catch(Exception ex) {
           ex.printStackTrace();
          throw new CreateException(ex.getMessage());
      public void ejbActivate(){}
      public void ejbPassivate(){}
      public void ejbRemove(){}
      public void setSessionContext(SessionContext ctx){ _ctx = ctx; }
      public void createDepartment(int id, String name, String loc)
      throws AppException {
        try {
          // Connect the AM to the datasource we want to use for the duration
          // of this single method call.
          _am.getTransaction().connectToDataSource(null,DATASOURCE,false);
          // Use the "Departments" view object member of this AM
          ViewObject departments = _am.findViewObject("Departments");
          // Create a new row in this view object.
          Row newDept = departments.createRow();
          // Populate the attributes from the parameter arguments.
          newDept.setAttribute("Deptno", new Number(id));
          newDept.setAttribute("Dname", name);
          newDept.setAttribute("Loc", loc);
          // Add the new row to the view object's default rowset
          departments.insertRow(newDept);
          // Post all changes in the AM, but we don't commit them. The EJB
          // container managed transaction handles the commit.
          _am.getTransaction().postChanges();
        catch(JboException ex) {
          // To be good EJB Container-Managed Transaction "citizens" we have
          // to mark the transaction as needing a rollback if there are problems
          _ctx.setRollbackOnly();
          throw new AppException("Error creating dept "+ id +\n"+ex.getMessage());
        finally {
          try {
            // Disconnect the AM from the datasource we're using
            _am.getTransaction().disconnect();
          catch(Exception ex) { /* Ignore */ }
      private void registerContainerManagedTransactionHandlerFactory() {
        SessionImpl session = (SessionImpl)_am.getSession();
        session.setTransactionHandlerFactory(
          new TransactionHandlerFactory() {
            public TransactionHandler createTransactionHandler() {
              return new ContainerManagedTxnHandlerImpl();
            public JTATransactionHandler createJTATransactionHandler() {
              return new ContainerManagedTxnHandlerImpl();

    Hi Steve, It4s me again;
    About the question I made, I tried with a single assembly-descriptor tag and a single container-transaction tag in the deployment descriptor of the session bean and these were the results.
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    Then I tried with multiple assembly-descriptor tags each with a single container-transaction tag and the results were:
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    Finally I tried with a single assembly-descriptor and multiple container tags and the results were:
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    How can I make my Stateless Session bean work out?

Maybe you are looking for

  • Jabber domain same as Webex Domain

    Hello my customer has the following CUCM 10.5.2 IM&P 10.5.2 Jabber 4 Windows 10.5.3 Expressway Core / Edge 8.5.1 Automatic discovery keeps defaulting to Webex. All the proper SRV records are in place for UDS / CUPlogin / CollabEdge but since Webex is

  • Can't get iTunes to open after upgrading

    After I downloaded the new version of iTunes (6.0.4) i couldn't get it to open. No matter what I do the application will not open. The iTunes.exe process shows up on my Windows Task Manager screen, but the application doesn't appear under the applica

  • Notification email not setn

    Hi, I am subscribing to a document and set to send notification on every event. Then I delete the document, but notification is not sent. From the log file I see it can connect to SMTP server, but cannot send email. The error is com.sapportals.wcm.se

  • Runtime error '2146232576 (80131700)

    Hi all, I am getting runtime error '2146232576 (80131700) Automation error While connecting BI Publisher in MS Word for that if i reinstall BI Publisher can i clear that error.(or) Is it need to reinstall MS Word Give me the conformation immediately

  • Refreshing jsp1 from jsp2

    how is that done? i have a list of systems which are listed according to their number of visits. when clicked, it opens in a new window and goes to a count page then redirects you to the system. the thing is, if you click that same link without refre