我有两个Pentaho插件。 GWT中的一种可以在5.0-5.2中使用,并返回我需要的所有尺寸。现在,我需要没有gwt的重构。我在新的REST服务中添加了联合代码,并且代码在pentaho 5.0中运行良好,但在5.2中失败。我相信问题不在代码中,但我试图理解为什么如果在gwt服务中正常运行会失败。

    MondrianProperties pr = MondrianProperties.instance();

    // Customize Mondrian to get connection
    pr.setProperty("mondrian.rolap.ignoreInvalidMembers", "true");
    pr.setProperty("mondrian.rolap.ignoreInvalidMembersDuringQuery", "true");
    pr.DataSourceResolverClass.setString("org.pentaho.platform.web.servlet.PentahoDataSourceResolver");

    Properties props = MondrianPropertyLoader.loadProperties();
    for(String property: props.stringPropertyNames()) {
        pr.setProperty(property, props.getProperty(property));
    }

    url = "jdbc:mondrian:Catalog=" + catalogDefinition + ";Datasource=" + dataSource; // + props;
    Class.forName("mondrian.olap4j.MondrianOlap4jDriver");

    // In Pentaho 5.2 RESTService fail
    // ---------------------------------
    OlapConnection connection = (OlapConnection) DriverManager.getConnection(url, "", "");
    // ---------------------------------

    final OlapWrapper wrapper = connection;
    OlapConnection tmpolapConnectionStx = (OlapConnection) wrapper.unwrap(OlapConnection.class);
    olapConnection = tmpolapConnectionStx;

    //Roles stuff
    setRoles(connection.getAvailableRoleNames());

    connection = null;
    Class.forName("mondrian.olap4j.MondrianOlap4jDriver");

    url += ";Role=" + getStringRoles();
    connection = (OlapConnection) DriverManager.getConnection(url, "", "");
    final OlapWrapper wrapper2 = connection;
    tmpolapConnectionStx = null;
    tmpolapConnectionStx = (OlapConnection) wrapper2.unwrap(OlapConnection.class);
    if (tmpolapConnectionStx == null) {
        throw new Exception("Connection is null");
    }
    olapConnection = tmpolapConnectionStx;
    this.initialized = true;


两者的先前代码相同,但是Pentaho 5.2中的新服务

OlapConnection连接=(OlapConnection)DriverManager.getConnection ...

失败并使用此网址引发以下异常

jdbc:mondrian:Catalog = mondrian:/ SampleData; Datasource = SampleData; Provider:mondrian; EnableXmla:false

jdbc:mondrian:Catalog = mondrian:/ SampleData; Datasource = SampleData

ERROR [PentahoDataSourceResolver] PentahoXmlaServlet.ERROR_0002 - IDatasourceService.UNABLE_TO_INSTANTIATE_OBJECT
org.pentaho.platform.api.data.DBDatasourceServiceException: DatasourceService.ERROR_0003 - Unable to get jndi datasource
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.NonPooledOrJndiDatasourceService.retrieve(NonPooledOrJndiDatasourceService.java:69)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.BaseDatasourceService.getDataSource(BaseDatasourceService.java:69)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.DynamicallyPooledOrJndiDatasourceService.resolveDatabaseConnection(DynamicallyPooledOrJndiDatasourceService.java:37)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.NonPooledOrJndiDatasourceService.retrieve(NonPooledOrJndiDatasourceService.java:51)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.BaseDatasourceService.getDataSource(BaseDatasourceService.java:69)
    at org.pentaho.platform.web.servlet.PentahoDataSourceResolver.lookup(PentahoDataSourceResolver.java:43)
    at mondrian.rolap.RolapConnection.createDataSource(RolapConnection.java:429)
    at mondrian.rolap.RolapConnection.<init>(RolapConnection.java:135)
    at mondrian.rolap.RolapConnection.<init>(RolapConnection.java:91)
    at mondrian.olap.DriverManager.getConnection(DriverManager.java:113)
    at mondrian.olap.DriverManager.getConnection(DriverManager.java:69)
    at mondrian.olap4j.MondrianOlap4jConnection.<init>(MondrianOlap4jConnection.java:157)
    at mondrian.olap4j.FactoryJdbc4Plus$AbstractConnection.<init>(FactoryJdbc4Plus.java:323)
    at mondrian.olap4j.FactoryJdbc41Impl$MondrianOlap4jConnectionJdbc41.<init>(FactoryJdbc41Impl.java:118)
    at mondrian.olap4j.FactoryJdbc41Impl.newConnection(FactoryJdbc41Impl.java:32)
    at mondrian.olap4j.MondrianOlap4jDriver.connect(MondrianOlap4jDriver.java:134)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:215)
    at com.olaphelper.provider.HelperConnection.connect(HelperConnection.java:101)
    at com.olaphelper.provider.HelperConnection.isConnected(HelperConnection.java:55)
    at com.olaphelper.api.rest.OlapResources.getCubeDimensions(OlapResources.java:98)
    at com.olaphelper.api.rest.OlapResources$$FastClassByCGLIB$$767f2eeb.invoke(<generated>)
    . . .
Caused by: org.pentaho.platform.api.data.DBDatasourceServiceException: javax.naming.NameNotFoundException: El nombre SampleData no este asociado a este contexto
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.PooledDatasourceHelper.getJndiDataSource(PooledDatasourceHelper.java:378)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.BaseDatasourceService.getJndiDataSource(BaseDatasourceService.java:99)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.NonPooledOrJndiDatasourceService.retrieve(NonPooledOrJndiDatasourceService.java:67)
    ... 108 more
Caused by: javax.naming.NameNotFoundException: El nombre SampleData no este asociado a este contexto
    at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.PooledDatasourceHelper.getJndiDataSource(PooledDatasourceHelper.java:339)
    ... 110 more
mondrian.olap.MondrianException: Mondrian Error:Internal error: Error while looking up data source (SampleData)
    at mondrian.resource.MondrianResource$_Def0.ex(MondrianResource.java:977)
    at mondrian.olap.Util.newInternal(Util.java:2404)
    at mondrian.rolap.RolapConnection.createDataSource(RolapConnection.java:431)
    at mondrian.rolap.RolapConnection.<init>(RolapConnection.java:135)
    at mondrian.rolap.RolapConnection.<init>(RolapConnection.java:91)
    at mondrian.olap.DriverManager.getConnection(DriverManager.java:113)
    at mondrian.olap.DriverManager.getConnection(DriverManager.java:69)
    at mondrian.olap4j.MondrianOlap4jConnection.<init>(MondrianOlap4jConnection.java:157)
    at mondrian.olap4j.FactoryJdbc4Plus$AbstractConnection.<init>(FactoryJdbc4Plus.java:323)
    at mondrian.olap4j.FactoryJdbc41Impl$MondrianOlap4jConnectionJdbc41.<init>(FactoryJdbc41Impl.java:118)
    at mondrian.olap4j.FactoryJdbc41Impl.newConnection(FactoryJdbc41Impl.java:32)
    at mondrian.olap4j.MondrianOlap4jDriver.connect(MondrianOlap4jDriver.java:134)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:215)
    at com.olaphelper.provider.HelperConnection.connect(HelperConnection.java:101)
    at com.olaphelper.provider.HelperConnection.isConnected(HelperConnection.java:55)
    at com.olaphelper.api.rest.OlapResources.getCubeDimensions(OlapResources.java:98)
    at com.olaphelper.api.rest.OlapResources$$FastClassByCGLIB$$767f2eeb.invoke(<generated>)
    . . .
Caused by: org.pentaho.platform.api.data.DBDatasourceServiceException: DatasourceService.ERROR_0003 - Unable to get jndi datasource
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.NonPooledOrJndiDatasourceService.retrieve(NonPooledOrJndiDatasourceService.java:69)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.BaseDatasourceService.getDataSource(BaseDatasourceService.java:69)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.DynamicallyPooledOrJndiDatasourceService.resolveDatabaseConnection(DynamicallyPooledOrJndiDatasourceService.java:37)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.NonPooledOrJndiDatasourceService.retrieve(NonPooledOrJndiDatasourceService.java:51)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.BaseDatasourceService.getDataSource(BaseDatasourceService.java:69)
    at org.pentaho.platform.web.servlet.PentahoDataSourceResolver.lookup(PentahoDataSourceResolver.java:43)
    at mondrian.rolap.RolapConnection.createDataSource(RolapConnection.java:429)
    ... 102 more
Caused by: org.pentaho.platform.api.data.DBDatasourceServiceException: javax.naming.NameNotFoundException: El nombre SampleData no este asociado a este contexto
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.PooledDatasourceHelper.getJndiDataSource(PooledDatasourceHelper.java:378)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.BaseDatasourceService.getJndiDataSource(BaseDatasourceService.java:99)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.NonPooledOrJndiDatasourceService.retrieve(NonPooledOrJndiDatasourceService.java:67)
    ... 108 more
Caused by: javax.naming.NameNotFoundException: El nombre SampleData no este asociado a este contexto
    at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at org.pentaho.platform.engine.services.connection.datasource.dbcp.PooledDatasourceHelper.getJndiDataSource(PooledDatasourceHelper.java:339)
    ... 110 more


这两个插件是相同的pentaho,具有相同的mondrian属性,所以我不明白为什么会发生。

最佳答案

最近,我检查了我的旧代码,并删除了我在plugin.spring.xml中不需要的一些行,并且我的插件正常工作。

引起问题的行如下

<context:property-placeholder location="config/jdbc.properties"/>
<!-- import rest="lib/hibernate.cfg.xml"/ -->

<bean id="dataSource"
      class="org.apache.commons.dbcp.BasicDataSource"
      destroy-method="close"
      p:driverClassName="${jdbc.driverClassName}"
      p:url="${jdbc.url}"
      p:username="${jdbc.username}"
      p:password="${jdbc.password}"
      p:maxActive="${dbcp.maxActive}"
      p:maxIdle="${dbcp.maxIdle}"
      p:maxWait="${dbcp.maxWait}"
        />

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
      p:dataSource-ref="dataSource"
      p:configurationClass="org.hibernate.cfg.AnnotationConfiguration"
      p:packagesToScan="com.stratebi.stx.console.model">

    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            <prop key="hibernate.hbm2ddl.auto">${schema.generation}</prop>
            <prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
            <prop key="hibernate.connection.url">${jdbc.url}</prop>
            <prop key="hibernate.connection.driver_class">${jdbc.driverClassName}</prop>
            <prop key="hibernate.connection.username">${jdbc.username}</prop>
            <prop key="hibernate.connection.password">${jdbc.password}</prop>
        </props>
    </property>

    <!--property name="annotatedPackages" value="com.stratebi.stx.console" />
    <property name="configLocation" value="config/hibernate.cfg.xml" / -->

    <property name="eventListeners">
        <map>
            <entry key="merge">
                <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>
            </entry>
        </map>
    </property>
    <property name="annotatedClasses">
        <list>

        </list>
    </property>

</bean>

<tx:annotation-driven transaction-manager="txnManager"/>

<!-- Hibernate transaction manager -->
<bean id="txnManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"
      p:sessionFactory-ref="sessionFactory"/>


但是我认为真正的问题是由事务管理器或休眠模式产生的,它与Pentaho自己的库产生了冲突,我需要稍后进行检查,但现在该错误消失了。

10-05 18:28