如何在 ireport 上设置 jdni.properties
7.2 使用 ejbql 连接我的问题是,当我测试连接时,失败,因为找不到数据源,日志中显示:
Caused by: org.hibernate.HibernateException: Could not find datasource
Caused by: javax.naming.NoInitialContextException: Need to在环境或系统属性中指定类名,或者作为小程序参数,或者在应用程序资源文件中指定: java.naming.factory.initial
我猜可能是 jndi.properties 在错误的目录中,我尝试放入 java_home/lib但不起作用
7.2 with ejbql connection my problem is that when i test the connection, fails because Could not find datasource, in the log says:
Caused by: org.hibernate.HibernateException: Could not find datasource
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
I guees can be the jndi.properties that in the wrong directory, i tried put into java_home/lib but doesn't work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,经过大量工作,我与 ireport 建立了 ejbql 连接。按照这个步骤就可以了!!
1)我使用的是jboss 4.2.3,所以如果您使用glashfish或其他服务器,请找到与我正在使用的jboss匹配的库
2)您需要在jboss目录server/default/lib中找到以下内容库:
3) 复制先前命名的库,并将 ireport 安装目录复制到此路径 \Jaspersoft\iReport-3.7 .2\ireport\modules\ext 并替换它,注意库调用 hibernate-common-annotation 和 jpa.jar 需要从该路径中删除。您需要这样做,因为该库会与 hibernate-annotations 和 ejb3-persistence.jar 产生冲突。
4) 获取项目的 jar 并将其复制到本例中名为 example-core.jar 的安装目录中的路径 \Jaspersoft\iReport-3.7.2\ireport\libs
5) 修改 jar 的持久性。您的项目的 xml(在我们的例子中为“example.jar”)并设置下一个属性,
<坚持
xmlns =“http://java.sun.com/xml/ns/persistence”
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
版本=“1.0”>
<属性>
<属性名称=“hibernate.dialect”值=“org.hibernate.dialect.Oracle9Dialect”/>
6) 进入 ireport 并将库添加到类路径中,在类路径选项卡中的工具、选项中
7) 进入 ireport 的安装目录,路径为 Jaspersoft\iReport3.7.2\ireport \modules 用 winrar 或其他工具打开名为 com-jaspersoft-ireport 的 jar,然后转到 Class-Path 部分的 META-INF/MANIFEST.INF 修改库的名称“hibernate-common-annotation.jar”(记得你删除这个库)为“hibernate-annotations.jar”
8)转到Jboss_home/server/default/deploy并修改项目的数据源xml并放置此配置,(记得在本示例中该项目称为“example " 并且数据源应称为 example-ds.xml)
<本地-tx-数据源>
<连接 URL>jdbc:oracle:thin:@localhost:1521:XE
<驱动程序类>oracle.jdbc.driver.OracleDriver
<用户名>示例
<密码>示例
<异常排序器类名称>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
<元数据>
<类型映射>Oracle9i
请注意, false 中的 usa-java-context 属性允许您从 ireport 访问 jboss 之外的数据源
9) 转到 ireport 并添加以下库进入 ireport 类路径
10) 设置你的 jndi.properties 并将其放入 jar 中hibernate-entitymanager.jar
11) 现在运行 jboss,转到 ireport 并创建 ejql 连接,在持久性单元名称中设置位于安装目录 Jaspersoft\iReport-3.7.2 中的 jar 的 persistence.xml 中的名称\ireport\libs,在这种情况下,持久性单元名称是“example”,不带引号
我希望这对某人或某人有帮助jeje,我知道这很难,对不起我的英语,它不是我的母语
Finally after a lot of work i made the ejbql connection with ireport. Follow this steps to do it!!
1) i'm using jboss 4.2.3, so if you using glashfish or other server, find the libraries that match with the jboss that i'm using
2) You need to find in your jboss directory server/default/lib the follow libraries:
3) copy the libraries previously named and copy your ireport installation directory in this path \Jaspersoft\iReport-3.7.2\ireport\modules\ext and replace it, note that the library call hibernate-common-annotation and jpa.jar need to be erase from that path. You need to do it because this library creates conflicts with hibernate-annotations and ejb3-persistence.jar.
4) get the jar of your project and copy it in your in this example let's called example-core.jar to the installation directory in the path \Jaspersoft\iReport-3.7.2\ireport\libs
5) modify the jar the persistence.xml of your project (in our case "example.jar") and sets with this next properties,
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="example" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>/jdbc/example</non-jta-data-source>
<properties>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
</properties>
</persistence-unit>
</persistence>
6)Go to ireport and add the libraries to the classpath, in tools, options in the tab of classpath
7) go to the installation directory of ireport in the path Jaspersoft\iReport3.7.2\ireport\modules open the jar called com-jaspersoft-ireport with winrar or other tool , and go to META-INF/MANIFEST.INF in the part of Class-Path modify the name of the library "hibernate-common-annotation.jar" (renember you erase this library) for the "hibernate-annotations.jar"
8)Go to Jboss_home/server/default/deploy and modify the datasource xml of your project and put this configuration, (renember in this example the project is call "example" and the datasource should be called example-ds.xml)
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/example</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>jdbc:oracle:thin:@localhost:1521:XE</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>example</user-name>
<password>example</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Note that the property usa-java-context in false is that allow you to access to the data source outside of the jboss in our case from ireport
9)go to the ireport and add the follow libraries into the ireport classpath
10) sets your jndi.properties and put it into the jar hibernate-entitymanager.jar
11) Now run the jboss, go to ireport and create the ejql connection, in the persistence unit name sets the name that place in the persistence.xml of the jar located in installation directory Jaspersoft\iReport-3.7.2\ireport\libs, in this case the persistence unit name is "example" without the quotes marks
I hope that this help to somebody or someone jeje, i know that's pretty hard, and sorry for my english its not my first language