Bug 1038317 - Use of remote client API results in error/warning messages regarding indirectly referenced JPA annotations not being resolvable
Summary: Use of remote client API results in error/warning messages regarding indirect...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Operations Network
Classification: JBoss
Component: CLI
Version: JON 3.2
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ER04
: JON 3.3.0
Assignee: Thomas Segismont
QA Contact: Jeeva Kandasamy
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-12-04 21:51 UTC by Larry O'Leary
Modified: 2018-12-04 16:33 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
The JON CLI did not ship with the Hibernate Core and Hibernate JPA jars because they were not used when running the JON CLI. When JON remote Java client developers used the content of the CLI "lib" directory as their list of dependencies they would see errors/warnings such as "The type javax.persistence.GenerationType cannot be resolved. It is indirectly referenced from required .class files". The JON CLI now ships with the Hibernate Core and Hibernate JPA JARs. JON remote Java clients now compile without the previously reported warnings and errors.
Clone Of:
Environment:
Last Closed: 2014-12-11 14:01:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 634923 0 None None None Never

Description Larry O'Leary 2013-12-04 21:51:09 UTC
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.

Comment 1 Larry O'Leary 2014-01-07 19:49:33 UTC
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).

Comment 2 Jay Shaughnessy 2014-09-05 18:52:50 UTC
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.

Comment 3 Larry O'Leary 2014-09-08 20:08:23 UTC
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.

Comment 4 Thomas Segismont 2014-09-17 16:32:39 UTC
(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

Comment 5 Thomas Segismont 2014-09-24 12:00:36 UTC
Pull request sent:
https://github.com/rhq-project/rhq/pull/129

Comment 8 Thomas Segismont 2014-09-25 12:25:31 UTC
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...

Comment 9 Thomas Segismont 2014-09-25 12:25:55 UTC
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>

Comment 10 Simeon Pinder 2014-10-01 21:33:18 UTC
Moving to ON_QA as available for test with build:
https://brewweb.devel.redhat.com/buildinfo?buildID=388959

Comment 12 Jeeva Kandasamy 2014-10-15 12:26:34 UTC
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


Note You need to log in before you can comment on or make changes to this bug.