I'm trying to use Scalatra with AkkaSupport and the newly introduced (2.2.0 RC2) GZipSupport. It fails and I'm trying to figure out if I'm doing something wrong, before I file a bug report. The code is the default Scalatra/Akka example, including the GZipSupport trait:
package com.myapp
import _root_.akka.dispatch._
import _root_.akka.actor._
import org.scalatra._
import org.scalatra.akka.AkkaSupport
class myappServlet extends ScalatraServlet with AkkaSupport with GZipSupport {
implicit val system = ActorSystem()
get("/"){
Future {
<html><body>Hello Akka</body></html>
}
}
}
I'm getting the following stack trace:
[ERROR] [01/08/2013 17:41:42.274] [default-akka.actor.default-dispatcher-2] [akka.dispatch.Dispatcher] STREAM
java.lang.IllegalStateException: STREAM
at org.eclipse.jetty.server.Response.getWriter(Response.java:699)
at org.scalatra.servlet.RichResponse.writer(RichResponse.scala:80)
at org.scalatra.ScalatraBase$$anonfun$renderPipeline$1.apply(ScalatraBase.scala:301)
at scala.PartialFunction$$anon$3.apply(PartialFunction.scala:97)
at scala.PartialFunction$$anon$3.apply(PartialFunction.scala:96)
at org.scalatra.ScalatraBase$class.loop$1(ScalatraBase.scala:275)
at org.scalatra.ScalatraBase$class.renderResponseBody(ScalatraBase.scala:277)
at org.scalatra.ScalatraServlet.renderResponseBody(ScalatraServlet.scala:50)
at org.scalatra.ScalatraBase$class.renderResponse(ScalatraBase.scala:245)
at com.myapp.myappServlet.org$scalatra$akka$AkkaSupport$$super$renderResponse(triptaoServlet.scala:9)
at org.scalatra.akka.AkkaSupport$$anonfun$renderResponse$1$$anonfun$apply$1.apply(AkkaSupport.scala:61)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
at org.scalatra.DynamicScope$class.withResponse(DynamicScope.scala:50)
at org.scalatra.ScalatraServlet.withResponse(ScalatraServlet.scala:50)
at org.scalatra.servlet.AsyncSupport$$anonfun$withinAsyncContext$1.apply(AsyncSupport.scala:25)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
at org.scalatra.DynamicScope$class.withRequest(DynamicScope.scala:41)
at org.scalatra.ScalatraServlet.withRequest(ScalatraServlet.scala:50)
at org.scalatra.servlet.AsyncSupport$class.withinAsyncContext(AsyncSupport.scala:24)
at com.myapp.myappServlet.withinAsyncContext(triptaoServlet.scala:9)
at org.scalatra.akka.AkkaSupport$$anonfun$renderResponse$1.apply(AkkaSupport.scala:58)
at org.scalatra.akka.AkkaSupport$$anonfun$renderResponse$1.apply(AkkaSupport.scala:56)
at akka.dispatch.Future$$anonfun$onSuccess$1.apply(Future.scala:484)
at akka.dispatch.Future$$anonfun$onSuccess$1.apply(Future.scala:483)
at akka.dispatch.DefaultPromise.akka$dispatch$DefaultPromise$$notifyCompleted(Future.scala:943)
at akka.dispatch.DefaultPromise$$anonfun$onComplete$1.apply$mcV$sp(Future.scala:937)
at akka.dispatch.Future$$anon$4$$anonfun$run$1.apply$mcV$sp(Future.scala:386)
at akka.dispatch.Future$$anon$4$$anonfun$run$1.apply(Future.scala:378)
at akka.dispatch.Future$$anon$4$$anonfun$run$1.apply(Future.scala:378)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
at akka.dispatch.Future$$anon$4.run(Future.scala:378)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:94)
at akka.jsr166y.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1381)
at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259)
at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975)
at akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1479)
at akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
Is this some bug or am I missing something? Thanks in advance!
This was a bug that was acknowledged by core Scalatra developers, it was announced as fixed in v2.2.1.
Related
I use RN version: "0.61.5"
The problem is that I installed react-native-beacons-manager 1.0.7 (note that the npm version the last time was updated a long time ago, but I tried the last Github version as well) but I can't use it as when I try to run my application the app crashes. Moreover, it doesn't show the red screen with an error stack trace. I looked into logs and found out that the problem is connected with WrittableArray, here's logs
2020-05-05 06:20:49.500 5218-5306/com.freeline E/AndroidRuntime: FATAL EXCEPTION: IntentService[BeaconIntentProcessor]
Process: com.freeline, PID: 5218
java.lang.NoSuchMethodError: No interface method putArray(Ljava/lang/String;Lcom/facebook/react/bridge/WritableArray;)V in class Lcom/facebook/react/bridge/WritableMap; or its super classes (declaration of 'com.facebook.react.bridge.WritableMap' appears in /data/app/com.freeline-BgN5GbjFCm9weblBl35oBw==/base.apk)
at com.mackentoch.beaconsandroid.BeaconsAndroidModule.createRangingResponse(BeaconsAndroidModule.java:299)
at com.mackentoch.beaconsandroid.BeaconsAndroidModule.access$300(BeaconsAndroidModule.java:37)
at com.mackentoch.beaconsandroid.BeaconsAndroidModule$2.didRangeBeaconsInRegion(BeaconsAndroidModule.java:280)
at org.altbeacon.beacon.BeaconIntentProcessor.onHandleIntent(BeaconIntentProcessor.java:68)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:76)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.os.HandlerThread.run(HandlerThread.java:65)
I found the function that caused the crashes, here it is:
private WritableMap createRangingResponse(Collection<Beacon> beacons, Region region) {
WritableMap map = new WritableNativeMap();
map.putString("identifier", region.getUniqueId());
map.putString("uuid", region.getId1() != null ? region.getId1().toString() : "");
WritableArray a = new WritableNativeArray();
for (Beacon beacon : beacons) {
WritableMap b = new WritableNativeMap();
b.putString("uuid", beacon.getId1().toString());
b.putInt("major", beacon.getId2().toInt());
b.putInt("minor", beacon.getId3().toInt());
b.putInt("rssi", beacon.getRssi());
b.putDouble("distance", beacon.getDistance());
b.putString("proximity", getProximity(beacon.getDistance()));
a.pushMap(b);
}
map.putArray("beacons", a); // <- The line that produces the exception
return map;
}
Then I read a bunch of posts and understand that the problem is in the implementation of WritableMap in new versions of RN.
So, my question is: Is there any method to resolve it, I've already addressed the issue here. I'm aware of the possibility of downgrading the RN version to ^60, but I'd keep it as the last possible method.
Appreciate your help
I solved the problem simply by downgrading to the version 60.6 of RN.
JavaParser.CallContext and JavaParser.FunctionDeclContext do not seem to be able to resolve. This is modeled after page 139 in the definitive antlr reference.
Am I missing a Lib?
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.MultiMap;
import org.antlr.v4.runtime.misc.OrderedHashSet;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.*;
import org.stringtemplate.v4.ST;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Set;
static class FunctionListener extends JavaBaseListener {
Graph graph = new Graph();
String currentFunctionName = null;
public void enterFunctionDecl(JavaParser.FunctionDeclContext ctx) {
currentFunctionName = ctx.ID().getText();
graph.nodes.add(currentFunctionName);
}
public void exitCall(JavaParser.CallContext ctx) {
String funcName = ctx.ID().getText();
// map current function to the callee
graph.edge(currentFunctionName, funcName);
}
}
I think I have seen this one, and I dont have enough points to "comment", but let me ask a question first; It looks like you are trying to produce an external version of the AST on page 137, You took the examples and renamed them to the grammar you had generated already. I'm going to assume that the rest of it is working or you would have had a lot more errors than this one ! Is that the goal ? Are you after just the calling methods/classes or are you after the full homogeneous AST ?
This depends on the grammar entry points. That's not as obvious in the book as it seems. You referenced functionDecl, which looks to be an entry in the Cymbol.g4, but doesn't exist in Java.g4 So rather than JavaParser.FunctionDeclContext I suggest JavaParser.classOrInterfaceDeclarationContext. It should should pull up the right method. I will also confess that I don't know what the exitCall would map to. I could use the illumination on that myself.
Were you after the whole AST or only the call graph ? If the whole AST, I think you can use enterEveryRule or ExitEveryRule for that as well, but confirmation would be good.
So start by regenerating your grammar, change your program to reference the rule entry point in the .g4 files, then see if it all works.
Thanks
So I am trying to make a minecraft mod that has a randomly generated ore. I have run into a problem in this part of the code.
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.ConfiguredPlacement;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.registries.ForgeRegistries;
public class ModOreGen {
public static void generateOre() {
for (Biome biome : ForgeRegistries.BIOMES) {
if (biome == Biomes.BAMBOO_JUNGLE) {
ConfiguredPlacement<CountRangeConfig> customConfig = Placement.COUNT_RANGE
.func_227446_a_(new CountRangeConfig(9, 10, 10, 0));
biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES,Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, blockinit.chocolate_ore.getDefaultState(), 10)).withPlacement(customConfig));
}
}
}
}
Where it says .withConfiguration it gives me the error:
The method withConfiguration(OreFeatureConfig) is undefined for the type Feature<OreFeatureConfig>
I have already tried updating my mappings and such, but nothing helped. This has been a problem that has really irritated me for days now. What is happening?
I just had this same problem with my code and finally fixed it. Try this out!
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.ConfiguredPlacement;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.registries.ForgeRegistries;
public class ModOreGen {
public static void generateOre() {
for (Biome biome : ForgeRegistries.BIOMES) {
if(biome == Biomes.BAMBOO_JUNGLE) {
ConfiguredPlacement<?> customConfig = Placement.COUNT_RANGE
.configure(new CountRangeConfig(9, 10, 10, 0));
biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(newOreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,BlockInit.chocolate_ore.getDefaultState(), 10)).withPlacement(customConfig));
}
}
}
}
The obvious thing Sammerson did was to remove the strong typing for CountRangeConfig:
ConfiguredPlacement<?> , but that doesn't matter.
What you can't see is updating Forge to 1.15.2.
This is most likely your best fix. In your build.gradle, somewhere near the top (mine is line 28) you've probably already updated your mappings to:
mappings channel: 'snapshot', version: '20200409-1.15.1'
But you also want to go down and update the Forge version also (this is around line 90 for me).
dependencies {
minecraft 'net.minecraftforge:forge:1.15.2-31.1.0'
}
You need to do the same
gradlew genEclipseRuns
gradlew eclipse
just like updating the mappings.
(You can check the Forge page, there may be a newer version than 1.15.2 by the time someone else reads this. And I hope anyone using IntelliJ can figure out how to update your own mappings/forge.))
I am testing out the following code snippet that I found here.
Eclipse Oxygen Version: Oxygen.2 Release (4.7.2) - if that matters
import org.junit.jupiter.api.Assertions;
....
#Test
void exceptionTesting() {
Executable closureContainingCodeToTest = () -> {throw new IllegalArgumentException("a message");};
Assertions.assertThrows(IllegalArgumentException.class, closureContainingCodeToTest, "a message");
}
However, the code doesn't compile.
I am getting the error below:
The method assertThrows(Class, Executable, String) in the type Assertions is not applicable for the arguments (Class, Executable, String) DbHandlerTest.java line 96 Java Problem
Of course my goal is not just to test the above snippet but to write a test for my code. Please help.
I figured out the problem ...
Thanks somuras for the right question.
Following import was wrong
import org.junit.jupiter.api.Executable;
It should have been this:
import org.junit.jupiter.api.function.Executable;
I have a method marked with #HystrixCommand that has a fallback method defined. I'm trying to add a hystrix property to it so that in case of a timeout it degrades gracefully into a fallback method.
But when I add the #HystrixProperty it shows an error in the STS IDE (3.8.2 Release) saying #HystrixProperty cannot be resolved to a type.
Here is what I'm trying to do:
#HystrixCommand(fallbackMethod="fallbackPerformOperation",
commandProperties={#HystrixProperty(name="execution.isolation.thread.timeoutInMilliseconds",value="5000")})
public Future<Object> performOperation(String requestString) throws InterruptedException {
return new AsyncResult<Object>() {
#Override
public Object invoke() {.......
}}}
and this is the error being shown in the IDE:
I'm unable to figure out what the problem is.
Do I need to clear the STS Cache? If so how do I do it?
Thank You.
With in the IDE it is not obvious to suggest the import HystrixProperty class, thus you need to manually import this
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
Then the error should be gone