org.eclipse.birt.report.service.api.ReportServiceException:运行报表时发生错误

时间:2013-05-06 23:04:43

标签: initialization birt naming

我的应用中有一个BIRT报告,它使用hibernate作为数据源。它一直给我一个像上面这样的错误。这些报告在我的队友工作站上运行,所以我不确定我的情况。我尝试重新检查整个报告项目,但仍无用。

我一整天都在挣扎,已经尝试了很多东西,但它不会消失。我重新连接了我的db.jar,认为它看不到它但仍然没用。 我已经读过我需要设置上下文但我不确定在哪里可以修改它。每当我创建一个报告时,我都不会使用hibernate,只会查询所以这将是第一次。任何人都可以指出我正确的方向让我去?

以下是我的报告代码/脚本: DataSet - 打开事件

 sessionUtil = new  Packages.com.irondata.icm.reports.server.generator.data.SessionUtil();
sessionUtil.openCurrentSession();

caseHome = new Packages.com.irondata.icmdb.database.CmCaseHome();
clientHome = new Packages.com.irondata.icmdb.database.ClientHome();

count = 0;

取:

    returnValue = false;

if(count == 0)
{

    cmCase = caseHome.getByCaseReference(params["Case Number"].value);
    client = cmCase.getClient();

    if(client!=null){
        row["clientId"] = client.getClientId();
        row["clientLastName"] = client.getClientLastName();
        row["clientFirstName"] = client.getClientFirstName();
        row["clientSSN"] = client.getClientSocSecNbr();
        row["clientFileNumber"] = client.getClientVAFileNumber();
    }

    returnValue = true;
    count++;
}

return returnValue;

接近:

sessionUtil.closeSessionWithCommit();

herer是xml源

<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
    <property name="createdBy">Eclipse BIRT Designer Version 3.7.2.v20120213 Build &lt;3.7.2.v20120214-1408></property>

    <property name="odaDriverClass">com.mysql.jdbc.Driver</property>
            <property name="odaURL">jdbc:mysql://localhost:3306/vsodb</property>
            <property name="odaUser">admin</property>
            <encrypted-property name="odaPassword" encryptionID="base64">YWRtaW4=</encrypted-property>
            <property name="odaJndiName">java:comp/env/jdbc/icm</property>

    <parameters>
        <scalar-parameter name="Case Number" id="9">
            <property name="hidden">true</property>
            <text-property name="helpText">Case Number</text-property>
            <property name="valueType">static</property>
            <property name="dataType">integer</property>
            <property name="distinct">true</property>
            <simple-property-list name="defaultValue">
                <value type="constant">100004</value>
            </simple-property-list>
            <list-property name="selectionList"/>
            <property name="paramType">simple</property>
            <property name="controlType">text-box</property>
            <structure name="format">
                <property name="category">Unformatted</property>
            </structure>
        </scalar-parameter>
    </parameters>
    <data-sources>
        <script-data-source name="MySQL Hibernate Data Source" id="7"/>


    </data-sources>

以下是正在使用的类的代码:

public CmCase getByCaseReference(String reference)
    {
        CmCase cmCase = null;
        Criteria criteria = InitSessionFactory.getCurrentSession().createCriteria(CmCase.class)
                .add(Restrictions.eq("caseReference", reference));
        List<CmCase> returnList = criteria.list();
        if (returnList != null && returnList.size() == 1)
        {
            cmCase = returnList.get(0);
        }

        return cmCase;
    }

这是stacktrace:

    org.eclipse.birt.report.service.api.ReportServiceException: Error happened while running the report.
   at org.eclipse.birt.report.service.ReportEngineService.throwDummyException(ReportEngineService.java:1107)
   at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:935)
   at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973)
   at org.eclipse.birt.report.service.actionhandler.BirtGetPageAllActionHandler.__execute(BirtGetPageAllActionHandler.java:131)
   at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90)
   at org.eclipse.birt.report.soapengine.processor.AbstractBaseDocumentProcessor.__executeAction(AbstractBaseDocumentProcessor.java:47)
   at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.executeAction(AbstractBaseComponentProcessor.java:143)
   at org.eclipse.birt.report.soapengine.processor.BirtDocumentProcessor.handleGetPageAll(BirtDocumentProcessor.java:183)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.process(AbstractBaseComponentProcessor.java:112)
   at org.eclipse.birt.report.soapengine.endpoint.BirtSoapBindingImpl.getUpdatedObjects(BirtSoapBindingImpl.java:66)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
   at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
   at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
   at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.doPost(BirtSoapMessageDispatcherServlet.java:265)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
   at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.service(BirtSoapMessageDispatcherServlet.java:122)
   at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
   at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
   at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
   at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
   at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:317)
   at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
   at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
   at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
   at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
   at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
   at org.mortbay.jetty.Server.handle(Server.java:326)
   at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
   at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:939)
   at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
   at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
   at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
   at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
   at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.eclipse.birt.report.engine.api.EngineException: Error happened while running the report.
   at org.eclipse.birt.report.engine.api.impl.EngineTask.handleFatalExceptions(EngineTask.java:2265)
   at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:190)
   at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
   at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:929)
... 49 more
Caused by: java.lang.ExceptionInInitializerError
   at com.irondata.icmdb.database.InitSessionFactory.(InitSessionFactory.java:106)
   at com.irondata.icm.reports.server.generator.data.OverDueTaskDataBuilder.getOverDueTasks(OverDueTaskDataBuilder.java:45)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
   at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:247)
   at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
   at org.mozilla.javascript.gen.c4._c1(/report/data-sets/script-data-set[@id="8"]/method[@name="open"]:3)
   at org.mozilla.javascript.gen.c4.call(/report/data-sets/script-data-set[@id="8"]/method[@name="open"])
   at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
   at org.mozilla.javascript.gen.c5._c0(/report/data-sets/script-data-set[@id="8"]/method[@name="open"]:0)
   at org.mozilla.javascript.gen.c5.call(/report/data-sets/script-data-set[@id="8"]/method[@name="open"])
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
   at org.mozilla.javascript.gen.c5.call(/report/data-sets/script-data-set[@id="8"]/method[@name="open"])
   at org.mozilla.javascript.gen.c5.exec(/report/data-sets/script-data-set[@id="8"]/method[@name="open"])
   at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateRawScript(JavascriptEvalUtil.java:95)
   at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateScript(JavascriptEvalUtil.java:134)
   at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:992)
   at org.eclipse.birt.data.engine.script.JSMethodRunner.runScript(JSMethodRunner.java:138)
   at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:90)
   at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.handleJS(DataSetScriptExecutor.java:256)
   at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleOpen(ScriptDataSetScriptExecutor.java:98)
   at org.eclipse.birt.data.engine.impl.ScriptDataSetRuntime.open(ScriptDataSetRuntime.java:80)
   at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor$CustomDataSet.open(PreparedScriptDSQuery.java:247)
   at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor.executeOdiQuery(PreparedScriptDSQuery.java:223)
   at org.eclipse.birt.data.engine.impl.QueryExecutor.execute(QueryExecutor.java:1134)
   at org.eclipse.birt.data.engine.impl.ServiceForQueryResults.executeQuery(ServiceForQueryResults.java:232)
   at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:177)
   at org.eclipse.birt.report.engine.data.dte.QueryResultSet.(QueryResultSet.java:98)
   at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:168)
   at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:267)
   at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1939)
   at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80)
   at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62)
   at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
   at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
   at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)
   at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)
   at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
   at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
   at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:180)
... 51 more
Caused by: org.hibernate.HibernateException: Could not find datasource
   at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:79)
   at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
   at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)
   at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:448)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
   at com.irondata.icmdb.database.InitSessionFactory.(InitSessionFactory.java:95)
... 94 more
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(NamingManager.java:662)
   at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
   at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
   at javax.naming.InitialContext.lookup(InitialContext.java:411)
   at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
... 101 more

1 个答案:

答案 0 :(得分:2)

这曾经是配置(JNDI)。文件位于src(/db/src/hibernate.cfg.xml)

下的数据库中
<!-- <property name="hibernate.connection.datasource">java:comp/env/jdbc/icm</property>
        <property name="hibernate.transaction.factory_class">
            org.hibernate.transaction.JDBCTransactionFactory
        </property>
        <property name="hibernate.current_session_context_class">
            thread
    </property>-->

然后我用它修改了它:

      <property name="connection.url">jdbc:mysql://localhost:3306/**</property>
  <property name="connection.username">**</property>
  <property name="connection.password">**</property>
  <property name="connection.driver_class">com.mysql.jdbc.Driver </property>
  <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
  <property name="hibernate.current_session_context_class">thread</property>
 <property name="hibernate.default_schema">**</property>
  <property name="hibernate.show_sql">true</property>
  <property name="hibernate.connection.autoReconnect">true</property> 
  <property name="hibernate.connection.autoReconnectForPools">true</property>

我们部署的应用程序是JNDI配置的,因此每当我签入时,我都不包含此文件,因为它不起作用或我必须取消注释上面的代码并评论下面的代码。非JNDI连接仅用于“预览”报告目的。