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.
Related
Case:
Writing a docx as pdf using WordprocessingMLPackage and setting the fontMapper using IdentityPlusMapper() from org.docx4j.fonts to map the fonts in the document we receive:
java.lang.NoClassDefFoundError: Could not initialize class org.docx4j.fonts.IdentityPlusMapper
at: getFontMapper()
This happens after upgrading from docx4j 11.2.8 to 11.4.6.
Dependencies in usage are:
org.docx4j:docx4j-core:11.4.6
org.docx4j:docx4j-export-fo:11.4.6
org.docx4j:docx4j-JAXB-ReferenceImpl:11.4.6
Is this a known issue already?
Looking forward to a possible reply!
Thanks in advance.
This assertion error is appearing from the static block of the IdentityPlusMapper or the BestMatchingMapper whatever we use. The exact line is:
PhysicalFonts.discoverPhysicalFonts();
The fix of the problem is to restrict fonts loading before the static block using font selection regex as stated in the javadoc of:
PhysicalFonts.setRegex()
The following way quickly solved the problem along with that it reduces memory utilization and the static block's execution time:
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
.load(new ByteArrayInputStream(os.toByteArray()));
String fontRegex = ".*(Courier New|Arial|Times New Roman|Comic Sans|Georgia|Impact|Lucida Console|Lucida Sans Unicode|Palatino Linotype|Tahoma|Trebuchet|Verdana|Symbol|Webdings|Wingdings|MS Sans Serif|MS Serif).*";
if(System.getProperty("os.name").startsWith("Windows")) {
fontRegex = ".*(calibri|cour|arial|times|comic|georgia|impact|LSANS|pala|tahoma|trebuc|verdana|symbol|webdings|wingding).*";
}
PhysicalFonts.setRegex(fontRegex);
wordMLPackage.setFontMapper(new BestMatchingMapper());
Docx4J.toPDF(wordMLPackage, outputStream);
This seems to be a font loading problem. I'm on a Mac (latest Monterey) and I'm getting the same exception in the contructor call:
java.lang.AssertionError:
Expecting code not to raise a throwable but caught
java.lang.AssertionError
at org.docx4j.fonts.fop.complexscripts.fonts.GlyphPositioningTable$DeviceTable.<init>(GlyphPositioningTable.java:1778)
at org.docx4j.fonts.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readPosDeviceTable(OTFAdvancedTypographicTableReader.java:1729)
at org.docx4j.fonts.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readPosAnchor(OTFAdvancedTypographicTableReader.java:2053)
at org.docx4j.fonts.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readMarkToLigaturePosTableFormat1(OTFAdvancedTypographicTableReader.java:2347)
at org.docx4j.fonts.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readMarkToLigaturePosTable(OTFAdvancedTypographicTableReader.java:2373)
at org.docx4j.fonts.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readGPOSSubtable(OTFAdvancedTypographicTableReader.java:3124)
at org.docx4j.fonts.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readLookupTable(OTFAdvancedTypographicTableReader.java:3193)
at org.docx4j.fonts.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readLookupList(OTFAdvancedTypographicTableReader.java:3220)
at org.docx4j.fonts.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readCommonLayoutTables(OTFAdvancedTypographicTableReader.java:3241)
at org.docx4j.fonts.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readGPOS(OTFAdvancedTypographicTableReader.java:3501)
at org.docx4j.fonts.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readAll(OTFAdvancedTypographicTableReader.java:88)
at org.docx4j.fonts.fop.fonts.truetype.OpenFont.handleCharacterSpacing(OpenFont.java:895)
at org.docx4j.fonts.fop.fonts.truetype.OpenFont.readFont(OpenFont.java:867)
at org.docx4j.fonts.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:121)
at org.docx4j.fonts.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:105)
at org.docx4j.fonts.fop.fonts.FontLoader.getFont(FontLoader.java:130)
at org.docx4j.fonts.fop.fonts.FontLoader.loadFont(FontLoader.java:114)
at org.docx4j.fonts.fop.fonts.autodetect.FontInfoFinder.find(FontInfoFinder.java:262)
at org.docx4j.fonts.PhysicalFonts.getPhysicalFont(PhysicalFonts.java:307)
at org.docx4j.fonts.PhysicalFonts.addPhysicalFonts(PhysicalFonts.java:246)
at org.docx4j.fonts.PhysicalFonts.addPhysicalFont(PhysicalFonts.java:236)
at org.docx4j.fonts.PhysicalFonts.discoverPhysicalFonts(PhysicalFonts.java:183)
at org.docx4j.fonts.IdentityPlusMapper.<clinit>(IdentityPlusMapper.java:74)
at foo(...)
open fun foo(...) {
...
val mlPackage = WordprocessingMLPackage.load(ByteArrayInputStream(input))
mlPackage.fontMapper = IdentityPlusMapper() //<-- boom
}
Update (August 29th 2022): I fixed the issue by upgrading Docx4j to 11.4.7 . Additionally I had to add the following code before the call to Docx4J.toFO(...):
val fopFactoryBuilder: FopFactoryBuilder = FORendererApacheFOP.getFopFactoryBuilder(foSettings)
FORendererApacheFOP.getFOUserAgent(foSettings, fopFactoryBuilder.build())
I have fixed the same by setting regex for fonts available in Mac which's recommened by PhysicalFonts class set regex method as well.
PhysicalFonts.regex = ".*(Courier New|Arial|Times New Roman|Comic Sans|Georgia|Impact|Lucida Console|Lucida Sans Unicode|Palatino Linotype|Tahoma|Trebuchet|Verdana|Symbol|Webdings|Wingdings|MS Sans Serif|MS Serif).*"
I am running the following java code (a very small modification on the example posted here https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-java.html) and getting a null pointer exception. I see the vertex is created in Neptune, but the driver seems to bomb on the response.
Am I doing something wrong here? Has anyone been successful in programmatically creating a vertex in Neptune using Java.
public class NeptuneMain {
public static void main(String[] args) {
Cluster.Builder builder = Cluster.build();
builder.addContactPoint("<enter cluster url here>");
builder.port(8182);
Cluster cluster = builder.create();
GraphTraversalSource g = EmptyGraph.instance().traversal().withRemote(DriverRemoteConnection.using(cluster));
GraphTraversal t = g.addV("Aspect");
t.forEachRemaining(
e -> System.out.println(e)
);
cluster.close();
}
}
Stack trace is :
Exception in thread "main" java.util.concurrent.CompletionException: java.lang.NullPointerException
at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1934)
at org.apache.tinkerpop.gremlin.driver.ResultSet.one(ResultSet.java:107)
at org.apache.tinkerpop.gremlin.driver.ResultSet$1.hasNext(ResultSet.java:159)
at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:166)
at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:153)
at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:142)
at
You might be using an older version (3.2.x) of the gremlin-driver package. Try upgrading to >= 3.3.2 and let us know if you still observe this problem.
I am trying to obtains list of broken constrains from a problem instance in OptaPlanner. I am using OptaPlanner version 7.0.0.Final and drools for rules engine (also 7.0.0.Final). The problem is solved correctly and without any error, but when I try to obtain broken constrains I get a NullPointer exception.
As far as I have researched, I found out, that this only happens, when I use drools accumulator without reverse operation (like max or min). Further I have made a custom accumulator, which is the exact copy from org.drools.core.base.accumulators.LongSumAccumulateFunction and everything works as expected, but as soon as I change the supportsReverse() function to return false, the NullPointer exception rises.
I have managed to reconstruct this problem in one of the provided examples - CloudBalancing. This is the change to CloudBalancingHelloWorld, it's only purpose is to obtain list of broken constraints as mentioned in this post.
public class CloudBalancingHelloWorld {
public static void main(String[] args) {
// Build the Solver
SolverFactory<CloudBalance> solverFactory = SolverFactory.createFromXmlResource(
"org/optaplanner/examples/cloudbalancing/solver/cloudBalancingSolverConfig.xml");
Solver<CloudBalance> solver = solverFactory.buildSolver();
// Load a problem with 400 computers and 1200 processes
CloudBalance unsolvedCloudBalance = new CloudBalancingGenerator().createCloudBalance(400, 1200);
// Solve the problem
CloudBalance solvedCloudBalance = solver.solve(unsolvedCloudBalance);
// Display the result
System.out.println("\nSolved cloudBalance with 400 computers and 1200 processes:\n"
+ toDisplayString(solvedCloudBalance));
//
//A Piece of code added - start
//
ScoreDirector<CloudBalance> scoreDirector = solver.getScoreDirectorFactory().buildScoreDirector();
scoreDirector.setWorkingSolution(solvedCloudBalance);
Collection<ConstraintMatchTotal> constrains = scoreDirector.getConstraintMatchTotals();
System.out.println(constrains.size());
//
//A Piece of code added - end
//
}
public static String toDisplayString(CloudBalance cloudBalance) {
StringBuilder displayString = new StringBuilder();
for (CloudProcess process : cloudBalance.getProcessList()) {
CloudComputer computer = process.getComputer();
displayString.append(" ").append(process.getLabel()).append(" -> ")
.append(computer == null ? null : computer.getLabel()).append("\n");
}
return displayString.toString();
}
}
And this is the change to requiredCpoPowerTotal rule. Please note that I have done this only to demonstrate the problem. Basicaly I have changed sum to max.
rule "requiredCpuPowerTotal"
when
$computer : CloudComputer($cpuPower : cpuPower)
accumulate(
CloudProcess(
computer == $computer,
$requiredCpuPower : requiredCpuPower);
$requiredCpuPowerTotal : max($requiredCpuPower);
(Integer) $requiredCpuPowerTotal > $cpuPower
)
then
scoreHolder.addHardConstraintMatch(kcontext, $cpuPower - (Integer) $requiredCpuPowerTotal);
end
I am really confused, because the error does not happen during planing phase, but when the scoreDirector recomputes the score to obtain broken constrains it does. I mean the same calculations must have happened during the planning phase right?
Anyway here is the stack trace
Exception in thread "main" Exception executing consequence for rule "requiredCpuPowerTotal" in org.optaplanner.examples.cloudbalancing.solver: java.lang.NullPointerException
at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.core.common.DefaultAgenda.handleException(DefaultAgenda.java:1256)
at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:438)
at org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:379)
at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:135)
at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:88)
at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:34)
at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1072)
at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1019)
at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1011)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1321)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1312)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1296)
at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.getConstraintMatchTotals(DroolsScoreDirector.java:134)
at org.optaplanner.examples.cloudbalancing.app.CloudBalancingHelloWorld.main(CloudBalancingHelloWorld.java:52)
Caused by: java.lang.NullPointerException
at org.drools.core.base.accumulators.JavaAccumulatorFunctionExecutor$JavaAccumulatorFunctionContext.getAccumulatedObjects(JavaAccumulatorFunctionExecutor.java:208)
at org.drools.core.reteoo.FromNodeLeftTuple.getAccumulatedObjects(FromNodeLeftTuple.java:94)
at org.drools.core.common.AgendaItem.getObjectsDeep(AgendaItem.java:78)
at org.drools.core.reteoo.RuleTerminalNodeLeftTuple.getObjectsDeep(RuleTerminalNodeLeftTuple.java:359)
at org.optaplanner.core.api.score.holder.AbstractScoreHolder.extractJustificationList(AbstractScoreHolder.java:118)
at org.optaplanner.core.api.score.holder.AbstractScoreHolder.registerConstraintMatch(AbstractScoreHolder.java:88)
at org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScoreHolder.addHardConstraintMatch(HardSoftScoreHolder.java:53)
at org.optaplanner.examples.cloudbalancing.solver.Rule_requiredCpuPowerTotal1284553313.defaultConsequence(Rule_requiredCpuPowerTotal1284553313.java:14)
at org.optaplanner.examples.cloudbalancing.solver.Rule_requiredCpuPowerTotal1284553313DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
at org.optaplanner.examples.cloudbalancing.solver.Rule_requiredCpuPowerTotal1284553313DefaultConsequenceInvoker.evaluate(Unknown Source)
at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:431)
... 13 more
Thank you for any help in advance.
That NPE sounds like a bug in Drools. The ConstraintMatch API should always just work. Very that you get it against the latest master version. If so, please create a jira for this with a minimal reproducer and we'll look into it.
Recently, we started to work with play 2.2. Previously we were working with play 2.1.3.
In play 2.2 it says Akka.future and async methods are seen as deprecated. Also when we tried to run below piece of code fetchSample() through a loop, it took more time to complete in play 2.2.
So how can we replace the below deprecated code with the latest one?
private static Promise<SampleDBResponseBean> fetchSample(
final Document sampleDoc) throws Exception {
Promise<SampleBean> promiseOfSampleJson = Akka.future(
new Callable<SampleBean>() {
public SampleBean call() throws Exception
{
return doSomeCalc(sampleDoc);
}
});
}
private Result getAsyncResult(final SampleResponseBean sampleDbResponseBean) {
List<F.Promise<? extends SampleDBResponseBean>> promiseList = sampleDbResponseBean
.getSampleHelperList();
Promise<List<SampleDBResponseBean>> promiseJsonObjLists = Promise
.sequence(promiseList);
return async(
promiseJsonObjLists.map(
new Function<List<SampleDBResponseBean>, Result>() {
public Result apply(List<SampleDBResponseBean> sampleList) {
SampleResponseBean sampleResponseBean = new SampleResponseBean();
sampleResponseBean.setStatus("success");
sampleResponseBean.setSampleList(sampleList);
JsonNode jsNodeResponse = Json.toJson(sampleResponseBean);
return ok(jsNodeResponse);
}
}));
}
I had searched a lot of places not seeing any solution. The problem effects our code performance when comparing to 2.1.3.
Any ideas how can we implement the deprecated methods for the above 2 methods in play 2.2?
As pointed out in the migration docs:
http://www.playframework.com/documentation/2.2.x/Migration22
You want to use Promise.promise. This is also described in the documentation:
http://www.playframework.com/documentation/2.2.x/JavaAsync
And of course in the API docs:
http://www.playframework.com/documentation/2.2.x/api/java/play/libs/F.Promise.html#promise(play.libs.F.Function0)
One of the really nice things about Play 2.2 Java promises is now you can control exactly which execution context the code runs in, so you can create your own execution context, or get one from Akka, and so control exactly how many, in your case, concurrent DB operations are run across the whole app at the same time.
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.