Ant/Maven: "javadoc: warning - Error fetching URL" - java

I recently set up my build server (Jenkins) to generate Javadocs for Ant builds. However, no matter what I do, I can't get it to include links to external libraries. When I attempt to use an online link, Ant returns:
[javadoc] javadoc: warning - Error fetching URL: http://docs.oracle.com/javase/6/docs/api/package-list
When I use an offline link and reference a local copy of a package list, it gives no warnings, but doesn't generate links either. This occurs for every library I attempt to link, not just Java SE. Here are the respective lines for links in my build.xml:
<link offline="true" href="http://docs.oracle.com/javase/6/docs/api/" packagelistLoc="javadoc/javase6/package-list" />
and:
<link href="http://docs.oracle.com/javase/6/docs/api/" />
It's worth mentioning that the internet connection of the server doesn't have a particularly unusual configuration. After a bit of research, I found that the warning I received is common when using a proxy, but I couldn't find any cases where it was returned on a server with a direct connection.
I'd also like to mention that I've verified that my offline package list is in the proper location and accessible via a relative path from the build file.
Edit #1: This is apparently an issue on Maven as well, suggesting that the Javadoc tool itself is broken.
Edit #2: It's worth mentioning that I'm using JDK 1.6 update 45 to compile.

<link offline="true" href="http://docs.oracle.com/javase/6/docs/api/"
packagelistLoc="javadoc/javase6/package-list" />
should be:
<link offline="true" href="http://docs.oracle.com/javase/6/docs/api/"
packagelistLoc="javadoc/javase6/" />
packagelistLoc is a path to directory containing package-list file.

It works fine, but for clarity, you need to download the package-list file from the Oracle website first, e.g. http://docs.oracle.com/javase/6/docs/api/package-list, and save that file to the folder you specified.

Related

Deploying app skips resource files

I'm banging my head off the wall on this one...I have a (so far fairly simple) google app engine project. During runtime I want to read in some XML files (resource file, not servable-static file) for processing. Having done a bit of research, I settled on reading the resource file through the servlet context (similar to the following). Works just fine on the dev server.
final InputStream inputStream1 = servletContext.getResourceAsStream("/" + pathToXmlFile);
Problem: Doesn't work in the cloud. First I thought the way how I am loading the resource is wrong, but I have noticed that the XML file in question doesn't appear to be uploaded at all. It is currently located here:
src/main/webapp/data/stuff.xml and
src/main/webapp/WEB-APP/data/stuff.xml
(I wasn't sure where to place the XML file, so I duplicated it into two locations.) The deploy log shows how the files are skipped:
2017-08-10 13:13:42,451 DEBUG root Skipping upload of [data/stuff.xml]
2017-08-10 13:13:42,461 DEBUG root Skipping upload of [WEB-INF/data/stuff.xml]
I have tried a number of things, without success, to get the file deployed. Things I tried:
Clear out the temp staging directory
Manually clean the build
Renamed directory / files
Include the file within the classes directory
Playing around with the resource-files section in the appengine-web.xml file (removing it, using various syntaxes)
Removing older versions of the app from the cloud
Restart Eclipse
FYI, current content of appengine-web.xml
<resource-files>
<include path="/data/*.xml" />
<include path="data/*.xml" />
</resource-files>
(Not sure if the slash is required....)
Note that the deploy does work for changed/new .class files, so my changes to Java classes are uploaded just fine. Somehow the deploy mechanism doesn't recognize that the XML file must also be uploaded.
FYI - Windows, Eclipse 4.7, Java 8, Cloud Tools 1.2.0.201706082053
Any help appreciated, especially if anybody knows how the deploy mechanism decides which files to deploy!
Try this:
<resource-files>
<include path="/data/**.xml" />
</resource-files>
This should include all xml files in data/ and its subdirectories.
Their documentation on include and exclude syntax, as I'm sure you're aware, is pretty skimpy. I'm pretty sure you want the double asterisk there though, and a bit more sure that you want the leading slash. I'm trying to find more info on it now, and will post a link if I do.
Thanks Brendan, the ** did the trick. FYI, the setup is now as follows:
<resource-files>
<include path="/data/**.xml" />
</resource-files>
<static-files>
<exclude path="/data/**.xml" />
</static-files>
Just using a single * was not good enough for "any XML file", it had to be **. As side-effect of the resource-files entry, the XML file now suddenly was also available as static file, accessible through the browser. So the exclude section inside static-files prevents the exposure of this. Not sure if this is overly elegant or the easiest/cleanest way to do it, but it works...
FYI, the "data" directory is contained directly underneath "webapp", and to access the resource the code is: servletContext.getResourceAsStream("/data/stuff.xml");
Note I also had to manually "touch" the XML file in order to get it to upload.
Thanks again.

Why aren't images found in Google App Engine project (Java, not using GWT)

I've found other questions using Python and app.yaml, but I'm working in Java using Eclipse. I've tried every permutation I could possibly think of including forward slashes, backslashes, opening with dots. I've tried putting the image itself in the root directory of the project. I've found similar questions on here, but they usually referenced an app.yaml. I know this should be very simple, but nothing I've tried has worked. I'm sure that I'm missing something in a configuration file somewhere. This is the first App Engine app I've tried, so I'm still feeling my way around it.
This tag:
<img src="images/CTT_placeholder.png" />
Yields this warning:
Jun 03, 2014 12:53:13 PM om.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /images/CTT_placeholder.png
The images folder is in the root of the project.
You need to create images directory in the war directory of your project
/war/images
and put your images there. Then your tag will work:
<img src="images/CTT_placeholder.png" />

Smart GWT app displays nothing because nocache.js file not found error

I have a smart GWT app example called AwesomesmartGWTUIProject from
javacodegeeks
Its package is com.javacodegeeks.smartgwt.appui
In eclipse when i try to run it as a web application I get the following error
In order for your application to run correctly, you will need to include these tags in your host page directly. In order to avoid this error, you will need to remove the script tags from the gwt.xml file, or add this property to the gwt.xml file: <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>
[ERROR] shell failed in doSlowStartup method
Mar 31, 2014 10:07:41 PM com.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /awesomesmartgwtuiproject/com.javacodegeek.smartgwt.appui.awesomesmartgwtuiproject.nocache.js
It simply doesn't display anything when I try to run it in my browser. Am new to smartGwt so am not so conversant with the configurations. Any ideas ?
Have you compiled your GWT project?
Is there nocache.js file generated in your project at correct location?
You have to read about Understanding the GWT Compiler.
Every thing is defined at above link including project structure, GWT compilation etc.
Use rename-to attribute in your module gwt.xml file.
Directly from the above link:
You may have noticed that one of the generated files is named after your module, followed by a .nocache.js suffix. This is the GWT bootstrap file. Similar to the output subdirectory war/, the name of this file is also controlled by the rename-to attribute in your module XML file.

adding external js in gwt

I writed and checked my js code in GWT.
For checking I added my js code in (projectName).html file and it is worked.
But when I try added external js file I get an error:
WARN] 404 - GET <path to js file>someJsFile.js (127.0.0.1) 1452 bytes
Request headers
I added this line to (projectName).gwt.xml file:
<script src="src/main/resources/<projectName>/someJsFile.js"></script>
To use this technique you have to place your someJsFile.js in your public folder so as the gwt compiler copy it to the final folder where it places the html and js stuff.
If you are using maven you have to check if the resources plugin is copying this file to the war and in which path.
By the way, there are other techniques to insert external javascript in your document:
Placing the script tag in your .html file.
Using ScriptInjector.fromUrl().
A better approach is to use a TextResource and ScriptInjector.fromString() so as the compiler reads the javascript file and includes the content in the final compiled file.
You can use gwtquery Ajax.getScript to get the script via ajax and inject it in the dom.
A new way, recently added to gwtquery, allows you to include your javascript as a JSNI block, so as the compiler can optimize and obfuscate it.
I'd rather the last one because it offers much more advantages.
You can define in your_project.gwt.xml which folders to include as public. The paths should be relative to the xml:
resources/
|-your_project.gwt.xml
|-subfolder/
|-stuff/
|-images/
|-js/
|-someJsFile.js
In your xml add:
<public path="subfolder/stuff" />
This should copy images/ and js/ folders into your webapp directory and you can use sth like this for the js file
<script src="js/someJsFile.js"></script>

Why can't I instantiate DataImportHandler in Solr on JBoss?

I'm trying to set up Solr 3.5.0 on JBoss 5.1. Everything works quite fine. I copied war into deploy dir, all the dependencies from dist and contrib directories into the lib (or earlier deploy) directory.
I can start a server, everything works fine, but whenever I want to activate the DataImportHandler to index data in my DB, I get an error.
Basically what I do is I copy is I copy a core from example/example-DIH/solr/db (Or whole example, that doesn't matter), I register the core in solr.xml and at startup I get an error:
15:17:10,707 SEVERE [RequestHandlers] org.apache.solr.common.SolrException: Error Instantiating Request Handler, org.apache.solr.handler.dataimport.DataImportHandler is not a org.apache.solr.request.SolrRequestHandler
at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:427)
at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:461)
at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:157)
I'm pretty sure my request handler definition is correct, but just to be sure:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">dataimport.xml</str>
</lst>
As far as I can find, this error may be caused by DataImportHandler and SolrRequestHandler supposedly being hold different class loaders.
Whenever I start a Solr from the start.jar app in example (I think it starts a Jetty server) it works fine.
My question is: is this really because of the class loader issue, or some other thing? And, more importantly: how do I fix it?
This is a class loader issue and according to this post on the Lucene Developer Mailing List you need to do the following:
make sure that the dataimport jars are NOT in the classpath and not loaded by other classloaders but from the path specified in solrconfig.xml. This will ensure that the dataimport classes are loaded by the same classloader.
Please see the thread for more details.
Paige Cook's answer is correct, but I'd like to add some details. I think you put the dataimporthandler jar into the common lib directory of your application server, while all solr jars are inside the WEB-INF/lib of solr.war. This means you're loading the dataimporthandler jar from a different classloader. You can solve it by putting your solr libraries in a different lib (external) directory. Then in your solr.xml you should refer to that lib folder through the sharedLib attribute. Something like this:
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false" sharedLib="lib">
<cores adminPath="/admin/cores">
<core name="core1" instanceDir="core1" />
</cores>
</solr>
This way the Solr web application will load jars from that external location through its specific classloader.
As said by Paige Cook this is a class loader issue, you should add dataimport jars into a path used by Solr class loader. In order to define such lib path there are many options.
Old versions of Solr (4.x and older) accepts an attribute sharedLib in the tag :
<solr persistent="false" sharedLib="lib"></solr>
sharedLib - Path to a directory containing .jar files that are added to the classpath of every core. The path is relative to solr.home (where solr.xml sits).
Newer versions of Solr (5.x and newer) use sharedLib as a child node of solr element.
<?xml version='1.0' encoding='UTF-8'?>
<solr>
<str name='sharedLib'>lib</str>
</solr>
Even in this case the lib path is relative to solr.home (where solr.xml sits).
Another alternative is define a lib directive directly into the solrconfig.xml,

Categories

Resources