I am having trouble teaching JAXB to locate classes in a .jar file located in an other Eclipse project.
We are developing several web applications. Each application is a separate Eclipse project which eventually is packaged as a separate OSGi plugin which is then deployed to our server runtime.
The services that each application provides is specified using WSDLs. Since all services are using several common data structures, we moved those definition into a separate schema which is located in a "Shared" project and all WSDLs import that schema using an import statement like:
...
<xsd:schema>
<xsd:import namespace="SharedTypes.v1_1.xsd"
schemaLocation="../Shared/SharedTypes.v1.1.xsd">
</xsd:import>
</xsd:schema>
...
i.e. they reach out of their own project ('..') and peak into the "Shared" project to import that schema.
The XML<=> Java bindings generated from that shared schema are saved to a .jar called "xsd.v1.1.sharedtypes.jar" which is placed in the /libs-folder of project "Shared".
That jar contains all classes corresponding to the types defined in the schema. An element, say, 'X' is compiled into a corresponding class "xsd.v1.1.sharedtypes.X". This .jar is declared as being exported from the "Shared" OSGi bundle.
The referencing OSGi bundles import this bundle, i.e. they declare "Shared" as a dependency.
The problem arises, when we try to generate the XML<=> Java bindings from the WSDL's in each project. There we always get a compile error in which the Eclipse JAXB wizard declares that it can't compile the classes it just generated from the WSDLs because it cannot find the classes that are contained in that shared .jar file.
But that .jar DOES contain the missing classes. It is also declared as being exported by the "Shared" plugin. And that plugin is being imported into the Applications' plugins. So these class should be visible at compile time, but obviously the JAXB-compiler sees that differently!
Any idea, how one can teach JAXB to include the exported .jar's of referenced OSGi plugins into the compilation's classpath when creating the XML-binding code?
Hope I could make myself clear...
M.
Related
In a RCP osgi based application, i want to load classes from disc at runtime. This loading is independent from OSGI infrastructure.
I have a custom classloader, which can do this and works in general (without the AspectJ).
Now these loaded classes shall have aspects applied.
But the aspect code is not called.
I have the .class files build with Ant iajc compiler. Do I need load-time weaving?
When load-time weaving is needed, is it sufficient to add the dependency "org.aspectj.weaver" and make the classloader extend WeavingURLClassLoader?
If it is WeavingURLClassLoader, can i use this URL to point to an aspect, located in another plugin? "platform:/plugin/myplugin/my_package/Aspect.aj". Or without the .aj extension?
How can debug this?
Frank
.
I have got it working now.
using the ctor WeavingURLClassLoader( classesUrls, aspectUrls, parent ).
Where classesUrls needed to be a URLs to folder or Jar. This must include the aspectj runtime jar.
aspectUrls needed to be a URLs to folder or Jar. This must not include the aspectj runtime jar.
URL pointing to specific aspect files within the jars do not work. The trial to use a OSGI bundle URL, did not work. For me, i needed find the JAR files directly on the file system.
My entities objects are scattered in multiple jars.
In jar A I have a base class name MyBase which is annotated with #MappedSuperclass.
In jar B there is an entity class which derives from MyBase.
The problem is that because the weaving is done in the context of the jar file (I'm using the maven plugin) the base class (MyBase) isn't instrumented (although it should).
If I move the derived class from jar B to A then the weaving process will handle the base as well.
Since I'm working on a large project it is critical for me to develop in a modular way.
Doesn't EclipseLink support such methodology?
The only way I found to override this limitation is to add a temporary entity class to the jar where the #MappedSuperclass base class is defined and remove it after the weaving procedure.
Sad, but true ;-)
I'm not sure on the maven plugin, but you should be able to use the static weaver on both jars, you will need to call it twice to weave both, and will need both jars on the weavers classpath for both calls.
Alternatively you can specify the jar containing your superclass as inpath - as explained here and here:
Managing multiple projects
Building AspectJ source code requires two distinct phases; compiling
the source in .java and .aj files to generate .class files, and then
applying the aspects to the generated .class files. This second phase,
known as weaving, is the key difference between AspectJ and Java
compilers. The Java compilation process is controlled by the classpath
setting, which makes types available for resolution by the compiler.
The same classpath setting is used by the AspectJ compilation process
and it is configured in exactly the same way in Eclipse. However, this
setting is not sufficient to control both the compilation and weaving
steps in all situations. This is why there are two extra settings
available for AspectJ projects.
First, there is the inpath setting. Anything specified here will be
made available to the weaver and so any aspects that apply will be
woven in. Entries can be added to a project's inpath by right-clicking
on the project, selecting Properties, then going to the AspectJ InPath
section. Entries can be either JAR files or directories (class
folders), such as the bin directory of another project. Anything on
the inpath is sent to the project's output, after potentially being
woven with aspects.
The second additional setting is the aspectpath. Whereas the inpath
controls the list of things that get woven, the aspectpath controls
what is woven into that list. In other words, any aspects specified on
the aspectpath are made available to the weaving process, just as if
they were present in source form in the project. This setting is
controlled from the AspectJ Aspect Path property page and can contain
either JAR files or directories.
An output JAR setting is also present in the AspectJ section of each
project's property page. This setting causes the compiler to output
class files directly to a JAR file, instead of to the project's output
folder.
Drove me crazy just like you - hope this helps. ;)
I'm wanting to use some java code as a reusable component jar in my GWT 2.4 application.
I need access to that code on the client side, so I've read that the steps involved are to
add an entry in the main projects gwt.xml file pointing to this project,
include a gwt.xml file in the jar
and put the java code under a client folder.
I assume that this has to be a gwt project itself, otherwise there would be no need to add the inherits entry or is it not possible to use a regular java project client-side?
Is there anything else I need to do for this (other than ensure the libraries in the jar fall under the JRE Emulation Reference list)?
We don't use the plugin functionality in Eclipse, but to use another project in your GWT project all you need to do is define a .gwt.xml module file in your project that you want to use in your GWT project and reference that module file with <inherits.../> in your main GWT project. You will also obviously need to add that project as a reference in the build path in Eclipse, so you don't get compilation errors. And all of that is besides the fact that your referenced project has to comply to the JRE emulation reference so it can be fully GWT compilable.
I created a module to share code across a couple of projects.
I created a GWT project: Framework. I then created a module com.framework.Framework within the project. The Framework project contains both client code, in the com.framework.client packages, and server code in the com.framework.server packages.
I try to consume this by
- Adding the project to the Java Build Path
- Adding to the module's definition
When I run the consuming project, I get NoClassDefFoundErrors for Framework classes I use in the module's server code.
What am I missing?
If I jar up the Framework project's WEB-INF\classes contents and put it into the consuming project's WEB-INF\lib folder, as well as add it to the Build Path it seems to work, but I don't see a way to keep the framework classes up to date in the consuming project(s).
Please make sure that you create gwt.xml file via menu New->Module, and in this gwt.xml file, you must declare your entry point class.
I'm creating a JAR file in Eclipse and for some reason classes are missing. The classes that are not included are referenced in other JAR files included on my build path. What doesn't make sense is that the behavior is not consistent. Some classes on the build path get included while others do not. Any ideas?
The step I take to create my JAR file, is to export all the source folders.
JAR files are libraries, and that means - thinking object oriented:
If the classes are referenced in other JAR that included in your build, so they have to be part of the included JAR files and not part on your new JAR.
That's the whole idea of a library - If I understand your question right.
If your JAR uses those external classes, so you have to include those classes's JAR files in your project.
I hope I understood you correctly.
When I need to distribute something for internal use, I use the Maven assembly plugin: it allows you to create jars with dependencies. This is very useful if you only want to pass around one single jar: http://maven.apache.org/plugins/maven-assembly-plugin/usage.html