Description of problem: A Java client that uses domain objects from the JON client API reports errors in the IDE indicating that JPA objects can not be resolved: - The type javax.persistence.GenerationType cannot be resolved. It is indirectly referenced from required .class files - The type javax.persistence.FetchType cannot be resolved. It is indirectly referenced from required .class files - The type javax.persistence.CascadeType cannot be resolved. It is indirectly referenced from required .class files Version-Release number of selected component (if applicable): 3.2.0.CR1 How reproducible: Always Steps to Reproduce: 1. In JBoss Developer Studio, create a new Java project. 2. Create new class Main.java with the following source: import org.rhq.enterprise.clientapi.RemoteClient; public class Main { static final String HOST_NAME = "localhost"; //$NON-NLS-1$ static final Integer HOST_PORT = 7080; static final String ADMIN_USER = "rhqadmin"; //$NON-NLS-1$ static final String ADMIN_PASSWORD = "rhqadmin"; //$NON-NLS-1$ public static void main(String[] args) throws Exception { RemoteClient rc = new RemoteClient(HOST_NAME, HOST_PORT); rc.connect(); rc.login(ADMIN_USER, ADMIN_PASSWORD); } } 3. Add all JAR files from rhq-remoting-cli-4.9.0.JON320CR1/lib directory to projects build path. 4. Perform a clean/build of the project in the IDE. Actual results: Compile/build is successful using OpenJDK 1.6 but Main.java contains an error marker on line 13 "rc.login(ADMIN_USER, ADMIN_PASSWORD);" reporting: Multiple markers at this line - The type javax.persistence.FetchType cannot be resolved. It is indirectly referenced from required .class files - The type javax.persistence.CascadeType cannot be resolved. It is indirectly referenced from required .class files - The type javax.persistence.GenerationType cannot be resolved. It is indirectly referenced from required .class files Expected results: No error or warning markers. Additional info: This is a direct result of the return type of `rc.login` being Subject. As with many (all?) the domain objects, they use JPA annotations and are marked as entity beans. This also occurs when executing methods that return other domain objects such as Resource or ResourceType or Availability, etc.
Targeting for review in 3.3 as any change to fix this issue may result in refactoring the client API packages or JARs. See https://access.redhat.com/site/solutions/634923 for an easy workaround (if one is even needed).
I'm not sure what if anything we can do about this. I'll drop it in ER04 for someone with more expertise to maybe look at, but I think this may be unavoidable fallout from our choice to use domain objects in the API.
The best solution would be to fix the remote API so that entity beans aren't being passed around. Or perhaps a local vs. remote interface can separate the persistence annotation? However, as that is not something that can be done easily, the only solution I can think of is to include the required libraries with our remote API. Basically, JPA is needed. I do not think the user should be expected to go find the required libraries on their own to make our remote API work. Instead, we may have to bite the bullet and bring in the JEE packages. The only other alternative I came up with was to strip the annotations from the domain objects. This would require JPA persistence configuration and object mapping to be provided in XML form. Perhaps someone else has a better idea.
(In reply to Larry O'Leary from comment #3) > The best solution would be to fix the remote API so that entity beans aren't > being passed around. Or perhaps a local vs. remote interface can separate > the persistence annotation? I don't think we'll ever create a separate model for the remote API > > However, as that is not something that can be done easily, the only solution > I can think of is to include the required libraries with our remote API. > Basically, JPA is needed. I do not think the user should be expected to go > find the required libraries on their own to make our remote API work. > Instead, we may have to bite the bullet and bring in the JEE packages. +1. Simeon, do you know which changes are needed for shipping the additional jars? > > The only other alternative I came up with was to strip the annotations from > the domain objects. This would require JPA persistence configuration and > object mapping to be provided in XML form. Too much risk
Pull request sent: https://github.com/rhq-project/rhq/pull/129
Fixed in master commit ac39e3ecf67d8c6fb9a43a0f1c7f03d2c767ad0c Merge: d1f320f 71ea032 Author: spinder <simeonpinder> Date: Wed Sep 24 13:30:54 2014 -0400 Merge pull request #129 from tsegismont/bug/1038317 Bug 1038317 - Use of remote client API results in error/warning messages...
Cherry-picked over to release/jon3.3.x (approved by Simeon) commit d01a75e411048b9b974cc3169eb2bdd1dd311482 Author: Thomas Segismont <tsegismo> Date: Wed Sep 24 13:58:38 2014 +0200 Bug 1038317 - Use of remote client API results in error/warning messages regarding indirectly referenced JPA annotations not being resolvable Added Hibernate Core (for CascadeType enum) and Hibernate JPA Annotations to the CLI distribution Tested with the wiki remote API example https://docs.jboss.org/author/display/RHQ/Java+Client+Sample+Class (Only 1 warning remains at compilation, because the sample class uses a deprecated method from the Remote API) (cherry picked from commit 71ea0328237bc737559c6f88c24e48d58bad7704) Signed-off-by: Thomas Segismont <tsegismo>
Moving to ON_QA as available for test with build: https://brewweb.devel.redhat.com/buildinfo?buildID=388959
Version: JBoss Operations Network Version : 3.3.0.ER04 Build Number : 99d2107:d7c537e GWT Version : 2.5.0 SmartGWT Version : 3.0p JBoss Developer Studio: Version: 7.1.0.GA Build id: GA-v20131208-0703-B592 Build date: 20131208-0703 There is no exception. Works as expected. I used the same code used from the comment#0 Files list: rhq-remoting-cli-4.12.0.JON330ER04/lib/ |-- commons-logging-1.1.0.jboss.jar |-- concurrent-1.3.4-jboss-update1.jar |-- endorsed |-- hibernate-core-4.2.14.SP1-redhat-1.jar |-- hibernate-jpa-2.0-api-1.0.1.Final-redhat-2.jar |-- i18nlog-1.0.10.jar |-- java-getopt-1.0.13.redhat-4.jar |-- javassist-3.18.1-GA-redhat-1.jar |-- jboss-common-core-2.2.17.GA-redhat-2.jar |-- jboss-logging-3.1.4.GA-redhat-1.jar |-- jboss-remoting-2.5.4.SP5.jar |-- jline-0.9.94.jar |-- log4j-1.2.16.jar |-- opencsv-1.8.jar |-- rhq-core-domain-4.12.0.JON330ER04.jar |-- rhq-core-util-4.12.0.JON330ER04.jar |-- rhq-enterprise-comm-4.12.0.JON330ER04.jar |-- rhq-enterprise-server-4.12.0.JON330ER04-client.jar |-- rhq-remoting-cli-4.12.0.JON330ER04.jar |-- rhq-remoting-client-api-4.12.0.JON330ER04.jar |-- rhq-script-bindings-4.12.0.JON330ER04.jar |-- rhq-scripting-api-4.12.0.JON330ER04.jar |-- rhq-scripting-javascript-4.12.0.JON330ER04.jar `-- rhq-scripting-python-4.12.0.JON330ER04.jar 1 directory, 23 files