tizone Posted June 22, 2009 Share Posted June 22, 2009 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 Link to comment Share on other sites More sharing options...
tizone Posted July 2, 2009 Author Share Posted July 2, 2009 So, nobody uses iReports plugin for NetBeans with JPA connections?.Thanks! Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted July 20, 2009 Share Posted July 20, 2009 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 Link to comment Share on other sites More sharing options...
tizone Posted August 12, 2009 Author Share Posted August 12, 2009 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 Link to comment Share on other sites More sharing options...
fpiragibe Posted August 20, 2009 Share Posted August 20, 2009 With iReports 3.0.0 standalone application (not the plugin), I've managed to make it work doing the stated below: 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. 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. 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). Make sure you JASPERREPORTS library, in Netbeans, include iReports.jar and barbecueXXX.jar (if you intend to print barcodes). 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. 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. Link to comment Share on other sites More sharing options...
javydreamercsw Posted January 9, 2010 Share Posted January 9, 2010 Is there a documented approach to using JPA and iReports? I'm planning on use such approach in my project. Link to comment Share on other sites More sharing options...
tizone Posted January 12, 2010 Author Share Posted January 12, 2010 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?. Link to comment Share on other sites More sharing options...
zeva Posted January 20, 2010 Share Posted January 20, 2010 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. Link to comment Share on other sites More sharing options...
Species8372 Posted February 3, 2010 Share Posted February 3, 2010 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.jarehcache-1.2.3.jarhibernate-annotations.jarhibernate-commons-annotations.jarhibernate-entitymanager.jarhibernate-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 projectHint:C:\<Docs and settings folder>\<username>\.ireport\3.7.1\var\logcontains 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 Link to comment Share on other sites More sharing options...
klaudia_ru Posted February 15, 2010 Share Posted February 15, 2010 Hi,I try to resolve this like you guys, but don't work. I am working whit Apache OpenJPA, any solution??Thks Link to comment Share on other sites More sharing options...
xcdemon Posted March 29, 2010 Share Posted March 29, 2010 I'm also having some issues.By following the steps above. I was able to get iReport to successfully test the connection. So I thought I was in the clear at that point.However whenever I try to either get Fields when building a report query, or if I try to preview a report that was essentially hand coded to work I get an error saying "The user must supply a JDBC connection" Does the Test Connection not get a JDBC connection, and if so why can't the same connection work when trying to preview the report etc?it seems like hibernate is lacking something to get the connection, but I think I have any relevant data in the persistence.xml. The following is my persistence.xml. I had to create it seperate from the Seam Project that it came from since that used JNDI etc.Any help/ideas would be appreciated. Not being able to use iReport with ejbql is really putting a damper on it's effectiveness for our purposes.Code:<properties> <property name="hibernate.show_sql" value="false" /> <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider" /> <property name="hibernate.cache.use_second_level_cache" value="true" /> <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" /> <property name="hibernate.default_schema" value="OPS$USER" /> <property name="hibernate.jdbc.url" value="jdbc:oracle:thin@dbserv:1521/DBDEV" /> <property name="hibernate.jdbc.driver_class" value="oracle.jdbc.driver.OracleDriver" /> <property name="hibernate.jdbc.username" value="user" /> <property name="hibernate.jdbc.password" value="pwd" /> <property name="hibernate.search.autoregister_listeners" value="false"/> </properties> Link to comment Share on other sites More sharing options...
xcdemon Posted March 29, 2010 Share Posted March 29, 2010 Thanks for this post. I've got a working test connection, but it doesn't appear to actually test the connection to the DB. Is your persistence.xml pointing at a jndi datasource, or does it define the db connection setting in it? Are you able to successfully preview a report, even with a simple query like select m from Account m. I keep getting an error "the user must supply a JDBC connection" but I'm not sure where and what needs to be present for iReport to find the connection since it's ignoring the db specific connection details in my persistence.xml. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now