|
|
|
|
|
|
iReport
 
Forums >  iReport Discussion/Help >  iReports, NetBeans and JPA  >
   
Go to bottom
iReport Discussion/Help Topic:
#58817
iReports, NetBeans and JPA 06/22/2009 16:19  

Hi there,

I am using the iReports plugin (iReport-nb-3.5.2.nbm) for NetBeans (6.5). It works perfect for JDBC connections, but I am having an issue with JPA ones. Here is how can the problem be reproduced:

  • Create a new report with the wizard.
  • Create a new Connection / Data Source.
  • Choose an EJBQL connection.
  • Enter an arbritary name for the connection, and the name of the Persistence Unit, of which file persistence.xml is in a jar of an EJB module, that is configured in the classpath of iReports (Tools - Options - iReports).

Here is where I have my first question. Where iReports is supposed to look for the Data Source of the Persistence Unit?. I mean, for configuring the Persistence Unit, NetBeans seems to look it in my GlassFish server for development. And during execution of the EJB, of course is taken from the GlassFish server. But, what about iReports?. Is it looking in the GlassFish server too?. Should I have to have GlassFish up to design a report with EJBQL?.

Anyway, when I press Test button to test the connection, it says "No Persistence provider for EntityManager named MyPersistenceUnitName".

I have made some more test with another options:

  • If I enter a name of a Persistence Unit that does not exist, the result is the same.
  • If I add the TopLink libraries to the iReports classpath (toplink-essentials-agent.jar and toplink-essentials.jar), then the result is "oracle.toplink.essentials.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider".

Any help will be appreciated. Thanks very much,

tizo

 

tizone
user photo
Project Roles
Posts: 4
graphgraph
Karma: 0
graphgraph
 
#59382
RE:iReports, NetBeans and JPA 07/02/2009 12:53  

So, nobody uses iReports plugin for NetBeans with JPA connections?.

Thanks!

tizone
user photo
Project Roles
Posts: 4
graphgraph
Karma: 0
graphgraph
 
#60593
RE:iReports, NetBeans and JPA 07/20/2009 21:48  

iReport executes:

Persistence.createEntityManagerFactory( "PersistenceUnitName"), null)

where PersistenceUnitName is the name of your persistence unit.

When Persistence.createEntityManagerFactory() is called, the persistence implementation will search your classpath for any META-INF/persistence.xml files using the ClassLoader.getResource("META-INF/persistence.xml") method. Actually the Persistence class will look at all the Persistence Providers available in the classpath and ask each of them if they are responsible for the creation of the entity manager factory PersistenceUnitName.

Giulio

 

giulio
user photo
Project Roles
Project Owner
Posts: 1036
graphgraph
Karma: 127
graphgraph
 
#61875
RE:iReports, NetBeans and JPA 08/12/2009 16:56  

Giulio,

Thanks for your response. I have tried "Persistence.createEntityManagerFactory( "PersistenceUnitName"), null);" in a main class in the same project that I am trying to test Jaser reports. It works in the following way:

  • If the Persistence Unit exist in the project:
    • If I have the libraries of TopLink in the project, it works. I have tried with both toplink-essentials-agent.jar and toplink-essentials.jar, and with each one separately, and it works in all the ways.
    • If I do not have such libraries in the project, the message of the exception is "No Persistence provider for EntityManager named ..."
  • If the Persistence Unit does not exist in the project, the message of the exception is always "No Persistence provider for EntityManager named ...".

So, I am guessing that the classpath of my project, is well configured, and the problem is and issue with the iReports plugin. Anyway, I have tried add the TopLink libraries to iReport classpath (Tools - Options - iReport - Classpath), with the following results at the moment of creating a new EJBQL connection with the wizard:

  • If the library added is toplink-essentials.jar, the message exception is always "oracle.toplink.essentials.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider", whatever the Persistent Unit exists or not.
  • If the library added is toplink-essentials-agent.jar (instead of toplink-essentials.jar), the message exception is always "No Persistence provider for EntityManager named ...", whatever the Persistent Unit exists or not.
  • I have also tried adding the jar of the project, and the source folder of the project (where "META-INF/persistence.xml" resides) in the classpath of iReport, and the results are the same as above.

I really don't know what to try next. I would appreciate any tip on that.

Thanks very much,

tizo

 

tizone
user photo
Project Roles
Posts: 4
graphgraph
Karma: 0
graphgraph
 
#62397
RE:iReports, NetBeans and JPA 08/20/2009 06:17  

With iReports 3.0.0 standalone application (not the plugin), I've managed to make it work doing the stated below:

  1. Replace, in the iReports "lib" folder, the following JARs by the ones in the HIBERNATE distribution you're  using - don't bother doing this if you're not using HIBERNATE, of course: EJB3 PERSISTENCE, JAVASSIST, HIBERNATE VALIDATOR, ANTLR, COMMONS COLLECTION, DOM4J, COMMONS LOGGING, EHCACHE, JTA, LOG4J, XML-APIS, HIBERNATE3, HIBERNATE COMMONS ANNOTATIONS, HIBERNATE ANNOTATIONS and HIBERNATE ENTITY MANAGER.
  2. Generate a JAR for your  ORM EJB project (not for the WEB one) replacing, in PERSISTENCE.XML, "transaction-type=JTA" by "transaction-type=RESOURCE_LOCAL" and <jta-data-source> by <non-jta-data-source>. This JAR should be copied elsewhere, because your project won't run this way. After doing this JAR generation, you should undo these changes and recompile.
  3. Define the iReports CLASSPATH to: all JDBC drivers + any accessory JARs you have (if you have them) + the resource bundle folder of your web project (if you use resource bundles) + the JAR built on step 2 + all JARs relevant to your application server (in the case of GLASSFISH, they are APPSERV_RT, APPSERV_ADMIN, APPSERV_DEPLOYMENT_CLIENT, APPSERV_EXT, APPSERV_EE, J2EE, JAVAEE and install/applications/jmsra/ imgjmsra.jar).
  4. Make sure you JASPERREPORTS library, in Netbeans, include iReports.jar and barbecueXXX.jar (if you intend to print barcodes).
  5. Setup a properly formatted jndi.properties file, in you <JRE>/lib folder, so that it's possible to find your data sources from the JNDI names specified in the PERSISTENCE.XML.
  6. Keep your JNDI service running (just keep your container running when you're testing the reports).

After doing all this, I was able to develop reports using iReports and EJB/QL queries.

fpiragibe
user photo
Project Roles
Posts: 1
graphgraph
Karma: 0
graphgraph
 
#69418
RE:iReports, NetBeans and JPA 01/09/2010 03:24  

 Is there a documented approach to using JPA and iReports? I'm planning on use such approach in my project.

javydreamercsw
user photo
Project Roles
Posts: 186
graphgraph
Karma: 5
graphgraph
 
#69534
RE:iReports, NetBeans and JPA 01/12/2010 19:00  

I have tried some of the advices that fpiragibe wrote, but the problem is the same. Definetively, I can't make the iReports plugin for NetBeans works with JPA. Does anyone succeed on making that task?.

 

tizone
user photo
Project Roles
Posts: 4
graphgraph
Karma: 0
graphgraph
 
#69946
RE:iReports, NetBeans and JPA 01/20/2010 14:51  

 Hi there,

I think jasperreports is a great tool but i've been dealing with this problem for a long time, i cannot get it to work with a jpa connection, ireport can't read the persistence.xml properly. In my previous projects i just used a plain jdbc connection and sql queries, then passing the hibernate underlying jdbc connection to the JasperFillManager instance. But now i need to use a jpa connection and ejbql.

I added the "classes" folder  (where the META-INF subfolder with the persistence.xml file is located) to the ireport classpath but when i specify my persistence unit name i get always the same mentioned error.

I also added to the classpath the lib folder (with my current implementation of hibernate and jta) but i get the same result.

I tried by creating a separate folder with a different version of the persistence.xml file, without using a jndi connection and setting transaction-type="RESOURCE_LOCAL". The same result.

Any suggestion?

Thanks in advance.

Zeva.

 

zeva
user photo
Project Roles
Posts: 3
graphgraph
Karma: 0
graphgraph
 
#70499
RE:iReports, NetBeans and JPA 02/03/2010 11:55  

Today i tried IReport for Netbeans the first time, as seen in other threads, JPA wont work.  So i played around and found this solution for 3.7.1 :

- move your ejb3-persitence.jar to iReport-3.7.1\ireport\modules\ext\jpa.jar, overwrite the old

- remove all of the following files(if available) from iReport-3.7.1\ireport\modules\ext\

hibernate3.jar
ehcache-1.2.3.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-entitymanager.jar
hibernate-tools.jar

- create a folder with the above files from your project
- put all files from the folder in the jasper classpath, keeping the order from above

- add all jars containing the persistance.xml and the POJO-classes as well as needed dependent jars of the same project

Hint:

C:\<Docs and settings folder>\<username>\.ireport\3.7.1\var\log

contains errorlogs in case NB wont display the red sign in the bottom right corner.

<ireportfolder>/etc/ireport.conf allows to enable more logging options as described there.


Hope this will help ya!


Species8372
 

Species8372
user photo
Project Roles
Posts: 9
graphgraph
Karma: 1
graphgraph
 
#70875
RE:iReports, NetBeans and JPA 02/15/2010 21:22  

Hi,

I try to resolve this like you guys, but don't work. I am working whit Apache OpenJPA, any solution??

Thks

klaudia_ru
user photo
Project Roles
Posts: 3
graphgraph
Karma: 0
graphgraph
 
Go to top
 
 
JasperForge Quotes
"Expert Experience using JasperReports Mandatory."
 
Founding Member, Open Solutions Alliance       Hot Jasper Projects on SOURCEFORGE.NET       Powered by EssentiaESP