Hej.
First of all: sorry for maybe asking a very simple question, I am very new to Java.
Here is my problem: I updated the dependenciy of an ancient code from using net.sourceforge.htmlunit version 2.8 to 2.37.0 (this was recommended by the Github security bot).
Now my code is not compiling and throws two errors.
Here is the relevant code:
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;
...
WebClient webClient = new WebClient(FIREFOX_3);
webClient.setTimeout(50000);
HtmlPage page = webClient.getPage("http://king.smith.man.ac.uk/mcpred/");
First error:
[ERROR] ./MissedCleavageAnalysisAdaptor.java:[64,53] cannot find symbol
[ERROR] symbol: variable FIREFOX_3
Second error:
[ERROR] ./MissedCleavageAnalysisAdaptor.java:[65,26] cannot find symbol
[ERROR] symbol: method setTimeout(int)
I managed to avoid the first error by simply deleting the "FIREFOX_3". Using "FIREFOX" (= newest version of firefox) or "FIREFOX_78" instead did not work and threw the same error.
With the second error, I cannot see the problem. I tried other integers or first defining an integer int timeout = 50000; and webClient.setTimeout(timeout);. Always the same error occurs. It seems like the method setTimeout was not imported. However, this should be imported together with WebClient, shouldn't it?
Can you please give me a hint how to tackle these errors?
Thanks a lot!
Wow thats a huge jump 2.8 was released Aug 5, 2010 and 2.37 in January 28, 2020.
The current version is 2.46.0 rom January 2, 2021 - maybe it makes sense to directly migrate to this one.
If you have a look at the release notes you will find this line:
WebClient: deprecated setTimeout() and getTimeout(). Use webClient.getOptions() instead.
for the release 2.11. Means - you have to change your code like this:
webClient.getOptions().setTimeout(50000);
The whole release notes are available here https://htmlunit.sourceforge.io/changes-report.html
Related
Getting below error when I am trying to run gatling.sh file. From my understanding getting compilation issue in RecorderSimulation.scala file while doing gatling.sh. Please see the below Error and help me
JAVA = "java"
11:51:37.496 [ERROR] i.g.c.ZincCompiler$ - Error while emitting
RecordedSimulation
Method too large: RecordedSimulation.<init> ()V
11:51:37.520 [ERROR] i.g.c.ZincCompiler$ - one error found
11:51:37.531 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed
sbt.internal.inc.CompileFailed: null
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77)
at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215)
at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:77)
at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:146)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:343)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:343)
at sbt.internal.inc.Incremental$.doCompile(Incremental.scala:120)
at sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:100)
at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:180)
at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:98)
at sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:102)
at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:155)
at sbt.internal.inc.Incremental$.compile(Incremental.scala:92)
at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:75)
at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:348)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:301)
at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:168)
at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:248)
at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:74) at io.gatling.compiler.ZincCompiler$.doCompile(ZincCompiler.scala:211)
at io.gatling.compiler.ZincCompiler$.delayedEndpoint$io$gatling$compiler$ZincCompiler$1(ZincCompiler.scala:216)
at io.gatling.compiler.ZincCompiler$delayedInit$body.apply(ZincCompiler.scala:39)
at scala.Function0.apply$mcV$sp(Function0.scala:39)
at scala.Function0.apply$mcV$sp$(Function0.scala:39)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
at scala.App.$anonfun$main$1$adapted(App.scala:80)
at scala.collection.immutable.List.foreach(List.scala:392)
at scala.App.main(App.scala:80)
at scala.App.main$(App.scala:78)
at io.gatling.compiler.ZincCompiler$.main(ZincCompiler.scala:39)
at io.gatling.compiler.ZincCompiler.main(ZincCompiler.scala)
Choose a simulation number:
[0] computerdatabase.BasicSimulation
[1] computerdatabase.advanced.AdvancedSimulationStep01
[2] computerdatabase.advanced.AdvancedSimulationStep02
[3] computerdatabase.advanced.AdvancedSimulationStep03
[4] computerdatabase.advanced.AdvancedSimulationStep04
Please suggest solution
This error is due to the size of the scala file being too large. You need to keep number of requests in a method to under 100. I faced the same issue and resolved it by splitting the script into two methods.
You've managed to generate some piece of code that's too large with regard to the Scala language spec.
Please make sure you're using latest Gatling version (3.3.1 as of now) and upgrade if not.
If problem still happens, please reach out on Gatling community mailing list and provide your code.
The Oracle Tutorial page for the Temporal Query show this example code.
- Code
TemporalQueries query = TemporalQueries.precision();
System.out.printf("LocalDate precision is %s%n",LocalDate.now().query(query));
When I compile this segment code, the Compiler throws the error:
- Error
TemporalQueryExample.java:8: error: incompatible types: TemporalQuery<TemporalUnit> cannot be converted to TemporalQueries
TemporalQueries query = TemporalQueries.precision();
^
TemporalQueryExample.java:10: error: no suitable method found for query(TemporalQueries)
LocalDate.now().query(query));
^
I don't know this java 8 documentation tutorial example is correct or not but I copy this code segment and paste my IDE then IDE throw the Error.
There is an error in the code. Look at what Lokesh has mentioned.
To further learn coding, make sure you understand the error properly. It will make your life easier. In this example, the error says: TemporalQuery<TemporalUnit> cannot be converted to TemporalQueries
If you check your code, <TemporalUnit> is not there, which is an indication that you have to place it somewhere and the right place to have it is mentioned by Lokesh.
You can go through this tutorial
Change this line TemporalQueries query = TemporalQueries.precision(); to this TemporalQuery<TemporalUnit> query = TemporalQueries.precision();
You can check this Java 9 documentation
I'm trying to fix errors which are reported by forbiddenapis. I had that line:
paramMap.put(Config.TITLEBOOST.toUpperCase(), titleBoost);
So, its been reported as error as usual. I've tried that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.getDefault()), titleBoost);
and that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.ROOT), titleBoost);
also that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.ENGLISH), titleBoost);
However none of them fixed the error:
[forbiddenapis] Forbidden method invocation:
java.lang.String#toUpperCase() [Uses default locale]
What I miss?
Double-check that the bytecode you are analyzing is actually your most recent build output, and that you're looking at the same line forbiddenapis is :) . This looks to me like your source/bytecode/analysis are falling out of sync — the relevant rule shouldn't flag an error on String.toUpperCase(Locale).
Disclaimer: I haven't used forbiddenapis myself --- I wrote this answer based on the repo and on a blog post I found.
I'm trying the quickstart from here: http://datafu.incubator.apache.org/docs/datafu/getting-started.html
I tried nearly everything, but I'm sure it must be my fault somewhere. I tried already:
exporting PIG_HOME, CLASSPATH, PIG_CLASSPATH
starting pig with -cpdatafu-pig-incubating-1.3.0.jar
registering datafu-pig-incubating-1.3.0.jar locally and in hdfs => both succesful (at least no error shown)
nothing helped
Trying this on pig:
register datafu-pig-incubating-1.3.0.jar
DEFINE Median datafu.pig.stats.StreamingMedian();
data = load '/user/hduser/numbers.txt' using PigStorage() as (val:int);
data2 = FOREACH (GROUP data ALL) GENERATE Median(data);
or directly
data2 = FOREACH (GROUP data ALL) GENERATE datafu.pig.stats.StreamingMedian(data);
I get this name-resolve error:
2016-06-04 17:22:22,734 [main] ERROR org.apache.pig.tools.grunt.Grunt
- ERROR 1070: Could not resolve datafu.pig.stats.StreamingMedian using imports: [, java.lang., org.apache.pig.builtin.,
org.apache.pig.impl.builtin.] Details at logfile:
/home/hadoop/pig_1465053680252.log
When I look into the datafu-pig-incubating-1.3.0.jar it looks OK, everything in place. I also tried some Bag functions, same error then.
I think it's kind of a noob-error which I just don't see (as I did not find particular answers for datafu in SO or google), so thanks in advance for shedding some light on this.
Pig script is proper, the only thing that could break is that while registering datafu there were some class dependencies that coudn't been met.
Try to run locally (pig -x local) and see a detailed log.
Check also the version of pig - it should be newer than 0.14.0.
The following error appear when I'm using NavigableSet to get the decending key set of a TreeMap:
[ERROR] [workflow] - Line 159: No source code is available for type java.util.NavigableSet<E>; did you forget to inherit a required module?
[ERROR] [workflow] - Line 159: The method descendingKeySet() is undefined for the type TreeMap<Integer,String>
Here is the code I use:
NavigableSet<Integer> nmap = selectedRow.descendingMap();
Does someone know where the error comes from ?
(For information i've imported the right class: java.util.NavigableSet )
I don't have enough rep for a comment... sorry. What version of GWT are you using? It looks like there is a bug here:
https://code.google.com/p/google-web-toolkit/issues/detail?id=4236
Fixed in 2.7.0 RC1