pentaho / mondrian

Mondrian is an Online Analytical Processing (OLAP) server that enables business users to analyze large quantities of data in real-time.
http://mondrian.pentaho.com/
Other
1.13k stars 720 forks source link

olap4j driver can't work with Olap4jXmlaServlet - (MondrianOlap4jConnection)$Proxy7 #123

Open m-khl opened 11 years ago

m-khl commented 11 years ago

Good day!

I'm trying to play with this great project (having zero insight in it). Let me share my observations. The desired architecture is:

xmla4js ---xmla---> Olap4jXmlaServlet ---olap4j---> MondrianOlap4jDriver

it turns to

Caused by: java.lang.ClassCastException: com.sun.proxy.$Proxy7 cannot be cast to mondrian.olap4j.MondrianOlap4jConnection at mondrian.olap4j.MondrianOlap4jExtra.getDataSources(MondrianOlap4jExtra.java:278) at mondrian.xmla.RowsetDefinition$DiscoverDatasourcesRowset.populateImpl(RowsetDefinition.java:1596) at mondrian.xmla.Rowset.populate(Rowset.java:221) at mondrian.xmla.Rowset.unparse(Rowset.java:193)

I dig into a little here is my finding

MondrianOlap4jExtra naively casts reference connection to MondrianOlap4jConnection, but Olap4jXmlaServlet wraps it by proxy in createDelegatingOlapConnection().

I feel like I'm watching thoroughly made mosaic but one piece is broken. I could fix this particular failure by using unwrap() instead of cast (or just by using DefaultXmlaServlet), but I want to provide a proper fix and/or find a test. It wasn't easy - ant and ivy, it's not my nowaday tools.

Nevertheless, I've found a test MetadataTest.testDatabaseMetaDataGetDatasources from olap4j-tck. How surprised I was when RowsetDefinition$DiscoverDatasourcesRowset.populateImpl obtains concrete MondrianConnection class instead of that proxy. Such lack of coverage makes me nervous. Don't you think it's necessary to introduce new "proxy" TestContext.Wrapper to cover Olap4jXmlaServlet like behavior?

I'm confused a little by overlap between all these projects, perhaps I need to create issue in another one.

Thanks for your time.

m-khl commented 11 years ago

i found the way to reproduce

firstly I enabled XmlaTester, but still the real connection is passed where the proxy was. Then, I've found that mondrian/tui/XmlaSupport.java is used to instantiate the test servlet. When I put Olap4jXmlaServlet there bug is reproduced. please find codechange, properties and failed test output.

https://github.com/m-khl/mondrian-sandbox/commit/8ebd0fdc6b95a28a7caa4be23a80ac98085c56a6

m-khl commented 10 years ago

Hi, once again, using mondrian.xmla.impl.Olap4jXmlaServlet with mondrian.olap4j.MondrianOlap4jDriver leads to the trivial issues:

Caused by: java.lang.ClassCastException: com.sun.proxy.$Proxy20 cannot be cast to mondrian.olap4j.MondrianOlap4jConnection
    at mondrian.olap4j.MondrianOlap4jExtra.getDataSources(MondrianOlap4jExtra.java:278)
    at mondrian.xmla.RowsetDefinition$DiscoverDatasourcesRowset.populateImpl(RowsetDefinition.java:1596)
    at mondrian.xmla.Rowset.populate(Rowset.java:221)
    at mondrian.xmla.Rowset.unparse(Rowset.java:193)
    at mondrian.xmla.XmlaHandler.discover(XmlaHandler.java:2861)
    ... 30 more

and

Caused by: java.lang.ClassCastException: com.sun.proxy.$Proxy20 cannot be cast to mondrian.olap4j.MondrianOlap4jConnection
    at mondrian.olap4j.MondrianOlap4jExtra.setPreferList(MondrianOlap4jExtra.java:56)
    at mondrian.xmla.XmlaHandler.executeQuery(XmlaHandler.java:1692)
    at mondrian.xmla.XmlaHandler.execute(XmlaHandler.java:751)
    at mondrian.xmla.XmlaHandler.process(XmlaHandler.java:666)
    at mondrian.xmla.impl.DefaultXmlaServlet.handleSoapBody(DefaultXmlaServlet.java:505)
    ... 28 more

@julianhyde please meet the trivial cure: https://github.com/m-khl/mondrian-sandbox/commit/1af873c844613f5ab03354fe90ddc2976da43e1a

lucboudreau commented 10 years ago

@m-khl Thanks for reporting this. I've filed this case to fix it:

http://jira.pentaho.com/browse/MONDRIAN-2108