How to create a gwt.xml file for an external jar? - java

I have an external JAR signpost-core-1.2.1.1.jar (from http://code.google.com/p/oauth-signpost/), that I want to include into my Java GWT project.
So I add this external JAR file to my build path in Eclipse and put theese imports to my Class:
import oauth.signpost.basic.DefaultOAuthConsumer;
import oauth.signpost.exception.OAuthCommunicationException;
import oauth.signpost.exception.OAuthExpectationFailedException;
import oauth.signpost.exception.OAuthMessageSignerException;
While compiling I got theese error messages:
[ERROR] Line 130: No source code is available for type oauth.signpost.basic.DefaultOAuthConsumer; did you forget to inherit a required module?
[ERROR] Line 133: No source code is available for type oauth.signpost.exception.OAuthMessageSignerException; did you forget to inherit a required module?
[ERROR] Line 135: No source code is available for type oauth.signpost.exception.OAuthExpectationFailedException; did you forget to inherit a required module?
[ERROR] Line 137: No source code is available for type oauth.signpost.exception.OAuthCommunicationException; did you forget to inherit a required module?
So I put the following line in my Admin.gwt.xml file:
<inherits name='oauth.signpost.Signpost' />
And now I'm getting this message:
Loading inherited module 'oauth.signpost.Signpost'
[ERROR] Unable to find 'oauth/signpost/Signpost.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
Unfortunately the Signpost does not seam provide a gwt.xml file, since it consists only of a jar file.
So how can I write it?
And where do I have to place it?
Or do I just need to set some additional paths?

I don't know Signpost library but I suppose that you want to use it in your client side. Unfortunately oauth-signpost is only provided for traditional web services. Anyway if you want to use it, its possible only on server side where you have full support of jre 6. On client side you can use only provided gwt modules that use only emulated gwt-jre environment.

Related

LibGDX GWT/HTML with Kotlin: "No source code is available for type <XYZ>, did you forget to inherit a required module?"

I generated a simple libGDX project with no dependencies. When I tried to build it as HTML app with Gradle (./gradlew html:dist), I get the following error message:
Tracing compile failure path for type 'xjcl.downgradius.client.HtmlLauncher'
[ERROR] Errors in 'file:/home/jan/Dropbox/py/AndroidStudioProjects/Downgradius_Android/html/src/xjcl/downgradius/client/HtmlLauncher.java'
[ERROR] Line 49: No source code is available for type xjcl.downgradius.DowngradiusGame; did you forget to inherit a required module?
I think the problem is caused by me using Kotlin in this project, and libGDX being intended for Java development. I observed that when I made a new main Game class in Java, that class was found by GWT, but not the Kotlin classes it imports.
I know Kotlin does some re-packaging (for example, if you put funA and funB in file Foo, they will be re-packaged as part of a new FooKt package, I think), but it should be able to find it as
it is declared in the right package (xjcl.downgradius)
it is declared as the only class in its file
I get no IDE warnings about importing it from Java.
I also tried converting Kotlin to Java code but the resulting Java code was full of errors.
Your assumptions are correct. GWT compiler works on Java sources. The error message it gives you is correct: There are no Java source code files to be found, you say it yourself that you used Kotlin.
If you want to use GWT, convert to correct Java source code.

Compiling application with Tika with Java 13 - problems loading modules

I'm trying to migrate a Java application that uses Tika from OracleJDK 1.8 to OPenJDK 13.
My IDE is Eclipse.
I have created the file module-info.java to indicate the required modules for my application.
In order to be able to use Tika classes such as AbstractParser, Detector, etc., I have added requires org.apache.tika.core; in module-info.java.
My code also uses the class org.apache.tika.parser.pdf.PDFParserConfig to extract embedded images:
PDFParserConfig pdfConfig = new PDFParserConfig();
pdfConfig.setExtractInlineImages(true);
context.set(PDFParserConfig.class, pdfConfig);'
I get the compilation error:
PDFParserConfig cannot be resolved to a type
Eclipse suggests to add requires org.apache.tika.parsers; to module-info.java: Eclipse suggestion screenshot.
When I add this module requirement to module-info.java, the application compiles properly.
That is, at this stage we have included in module-info.java:
module myapp {
/** others ... */
requires org.apache.tika.core;
requires org.apache.tika.parsers;
}
However, when trying to execute the compiled application, we get the error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\Admin\.m2\repository\org\apache\tika\tika-parsers\1.24\tika-parsers-1.24.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.tika.parser.onenote.OneNoteParser not in module
Inspecting the project Libraries in Eclipse, I can see that tika-core and tika-parsers (v1.24) are both modular: Eclipse Java Build Path
In conclusion: If I don't add org.apache.tika.parsers as a required module, the application won't compile, and if I add it I get the runtime error saying org.apache.tika.parser.onenote.OneNoteParser is not in the module.
I have inspected the JAR files for these packages to see the dependencies they have. The core packages seems to be right:
$ jar --file=tika-core-1.24.jar --describe-module
No module descriptor found. Derived automatic module.
org.apache.tika.core#1.24 automatic
requires java.base mandated
contains org.apache.tika
contains org.apache.tika.concurrent
contains org.apache.tika.config
contains org.apache.tika.detect
contains org.apache.tika.embedder
contains org.apache.tika.exception
contains org.apache.tika.extractor
contains org.apache.tika.fork
contains org.apache.tika.io
contains org.apache.tika.language
contains org.apache.tika.language.detect
contains org.apache.tika.language.translate
contains org.apache.tika.metadata
contains org.apache.tika.mime
contains org.apache.tika.parser
contains org.apache.tika.parser.digest
contains org.apache.tika.parser.external
contains org.apache.tika.sax
contains org.apache.tika.sax.xpath
contains org.apache.tika.utils
...but the 'parsers' jar gives an error:
$ jar --file=tika-parsers-1.24.jar --describe-module
Unable to derive module descriptor for: tika-parsers-1.24.jar
Provider class org.apache.tika.parser.onenote.OneNoteParser not in module
Does this mean the jar package for parsers is not well formed?
Is there any workaround for this?
Thank you.
EDIT:
If I try with version 1.24.1, I get the execution error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\Admin\.m2\repository\org\apache\tika\tika-parsers\1.24.1\tika-parsers-1.24.1.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.tika.parser.external.CompositeExternalParser not in module
That is: the failing class is CompositeExternalParser instead of OneNoreParser.
Inspecting META-INF/services/org.apache.tika.parser.Parser of tika-parsers-1.42.1.jarI can see the entryorg.apache.tika.parser.external.CompositeExternalParser` but the package does not contain this class.
So, it seems to be an error in this META-INF file. Id this due to an error when compiling the package and submitting it to Maven Central?
I've found a JIRA issue, TIKA-2929, where they say "Apache Tika needs to be on the Java Classpath, not the module path". I've tried this, but, as explained before, I get a compilation error if I don't add it to the module path and set requires org.apache.tika.parsers;.
This is a hard puzzle...
Ran into the same issues.
Also found the faulty entries in
org.apache.tika.parser.Parser (and also org.apache.tika.parser.Detector) in META-INF/services/
A quick fix is to ...
Unpack those files
delete the lines that seem to reference non existing classes
pack them back into the jar
My project compiled after that.
For sure no longterm solution, but since even older versions i tried ran into that problem, it might help out some people.

did you forget to inherit a required module?

I know there is already a lot of topic about this issue (did you forget to inherit a required module?) but my problem is a little bit special.
Let me explain it:
I have an existing package that contains my models classes(the name of the package is model). All my models were located into that package. But I made a change in my application and now part of the models that I am using in my application is now pulled from another application named "MyAppModel". I have added the dependency to this MyAppModel application in my pom.xml file. I have no compilation error (mvn compile is successful) but when I do maven install: I have the following error:
[ERROR] Line 130: No source code is available for type com.data.service.models.Product; did you forget to inherit a required module?
[INFO] [ERROR] Line 588: No source code is available for type com.data.service.models.Order; did you forget to inherit a required module?
These 2 models:com.data.service.models.Order.java and com.data.service.models.Product.java are from the MyAppModel application but I am not authorized to add them manually to the existing model package of my application.
It seems like it can not find those 2 models Product and Order.
Here is the content of my gwt.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module>
<inherits name='com.google.gwt.user.User'/>
<source path='model'/>
</module>
The source path is only pointing to he existing model package. My question is: how can I do to modify this gwt.xml file to take into account both models packages(the model package of the existing application and also the model package of the external application "MyAppModel")
I need to keep my existing source path='model' and should add an access to my external models in my MyAppModel application
Thank you very much for your help
I think this is one of those few cases where the error is exactly what it says.
If you have part of those models in another artifact just make sure you also have the sources available and not just class files, for that artifact.
You need to either package a -sources artifact or include sources in the same artifact as compiled classes.
In case of GWT, sometimes we see this error if we refer server side classes in client side code.

GWT - Compilation error: No source code is available for type

I am building GWT application by Maven.
When compiling get the following message:
Validating newly compiled units
At first there is this warning:
[WARNING] Don't declare gwt-dev as a project dependency. This may introduce complex dependency conflicts
Then there is this error:
[ERROR] Line 19: No source code is available for type org.apache.commons.lang.StringUtils did you forget to inherit a required module?
Despite this build does not fall and Dev mode works properly.
How can I get rid of these error messages?
Perhaps a reason is in your module file. You should to identify packages that is to be compiled. This is configured in .gwt.xml module.
<source path="packagename">
And GWT compiler will compile packages gwtxmlmodulepath.packagename.
See more
The error means that some of the client code (to be compiled as javascript) contains a reference to the StringUtils class from Apache Commons. This is not allowed because this library contains code that is not GWT-client compatible.

Can't deploy to google apps engine

I have a little application which is working fine when testing is on localhost.
But when I want to deploy it to google app engine server, I have thoses errors :
Compiling module org.magnetik.semola.Org_magnetik
Validating newly compiled units
Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Finding entry point classes
[ERROR] Errors in 'file:/C:/Users/magnetik/git/semola-rdf/org.magnetik/src/org/magnetik/semola/client/RDFServlet.java'
[ERROR] Line 13: No source code is available for type javax.servlet.http.HttpServlet; did you forget to inherit a required module?
[ERROR] Line 16: No source code is available for type javax.servlet.http.HttpServletRequest; did you forget to inherit a required module?
[ERROR] Line 16: No source code is available for type javax.servlet.http.HttpServletResponse; did you forget to inherit a required module?
[ERROR] Line 25: No source code is available for type com.hp.hpl.jena.rdf.model.Model; did you forget to inherit a required module?
[ERROR] Line 25: No source code is available for type com.hp.hpl.jena.rdf.model.ModelFactory; did you forget to inherit a required module?
[ERROR] Line 37: No source code is available for type java.io.ByteArrayInputStream; did you forget to inherit a required module?
[ERROR] Unable to find type 'org.magnetik.semola.client.RDFServlet'
[ERROR] Hint: Previous compiler errors may have made this type unavailable
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
Usefull files (I think) are here : http://pastebin.com/zuELG18u
Does your project use GWT for the client side? Your deployment is failing when it is trying to do a special GWT compliation step.
I believe your problem is that your RDFServlet class is part of a GWT module, which is not what you are intending.
The default Eclipse project for GAE comes preconfigured to work with GWT. The package is structure in the example is like this:
client/ <--- GWT code (for client side, compiled to JavaScript)
shared/ <--- Code necessary on both the client and server
server/ <--- Server side code
When GWT compiles client/ down to JavaScript, it needs the full source of all its dependencies, and there are many classes that should not be referenced. However, it seems that you have a servlet (RDFServlet) in the "client" package.
You probably want to either disable GWT in your project, or move RDFServlet into a package that is not part of a GWT module. (For example, if you are using the Eclipse sample project, Servlets would be put somewhere under the 'server' package.

Categories

Resources