US and Worldwide: +1 (866) 660-7555
Results 1 to 2 of 2

Thread: Need to develop a client java app that can connect to Mondrian server

  1. #1
    Join Date
    Jun 2013
    Posts
    5

    Question Need to develop a client java app that can connect to Mondrian server

    Hi,

    I am new to Mondrian and working on developing a java client that can connect to Mondrian server (Mondrian version 3.5.x) and execute query. I am using olap4j.jar and referring to a PDF 'Olap4j_Introduction_An_end_user_perspective.pdf' for writing java client. The code that I have written so far is as follows:

    package test;
    import mondrian.olap.Connection;
    import mondrian.olap.DriverManager;
    import mondrian.spi.impl.CatalogLocatorImpl;

    public class InvokeMondrianXMLA {
    public static void main(String[] args) throws Exception {
    Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
    Connection connection = DriverManager.getConnection("jdbc:xmla:"
    + "Server=http://localhost:8080/mondrian/xmla;Catalog=SM2;DataSource=DynamicUpdateTest",
    new CatalogLocatorImpl());
    System.out.println("Connected!");
    connection.close();
    }
    }



    I get following exception:

    Exception in thread "main" mondrian.olap.MondrianException: Mondrian Error:Internal error: Error while looking up data source (DynamicUpdateTest)
    at mondrian.resource.MondrianResource$_Def0.ex(MondrianResource.java:967)
    at mondrian.olap.Util.newInternal(Util.java:2400)
    at mondrian.rolap.RolapConnection.createDataSource(RolapConnection.java:430)
    at mondrian.rolap.RolapConnection.<init>(RolapConnection.java:134)
    at mondrian.rolap.RolapConnection.<init>(RolapConnection.java:90)
    at mondrian.olap.DriverManager.getConnection(DriverManager.java:112)
    at mondrian.olap.DriverManager.getConnection(DriverManager.java:68)
    at mondrian.olap.DriverManager.getConnection(DriverManager.java:50)
    at test.InvokeMondrianXMLA.main(InvokeMondrianXMLA.java:12)
    Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at mondrian.spi.impl.JndiDataSourceResolver.lookup(JndiDataSourceResolver.java:32)
    at mondrian.rolap.RolapConnection.createDataSource(RolapConnection.java:428)
    ... 6 more

    Can somebody help me?

    ~ Reshma

  2. #2
    Join Date
    Jan 2013
    Posts
    495

    Default

    The error indicates the DataSource isn't found. You could try leaving off the Catalog and DataSource from the connection string. Then (assuming the connection succeeds), you can check what databases and catalogs are available with

    OlapConnection olapConnection = connection.unwrap(OlapConnection.class);
    olapConnection.getOlapDatabases()
    olapConnection.getOlapCatalogs()

Tags for this Thread

Posting Permissions

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