java.lang.NullPointerException with XmlReader in libgdx - libgdx

this is my first time using xml and I have this problem:
here's the xml file :
<file>
<extension>.png</extension>
<animated>false</animated>
</file>
and here is the code I use to read the animated block :
isAnimated = Boolean.parseBoolean(xmlTextureFile.getChildByName("file").get("animated"));
and when I execute the program it gives the java.lang.NullPointerException error

I found the answer,
xmlTextureFile is an Element and when you parse a file the first element used to parse is the fisrt tag (file here).
therefore here I only need to do
isAnimated = Boolean.parseBoolean(xmlTextureFile.get("animated"));

Related

JMeter - saving properties in variables, but JMeter not resolving the variable

I'm using the JMeter Property file reader successfully to get values from a file.
Then I use a simple Groovy snippet to save those values in variables.
Why, then, is JMeter still thinking the variable is not defined?
Output to the console shows that the variables are being stored.
for (i in props)
if (i.key.startsWith('testData')) {
vars.put(i.key, i.value)
log.info(vars.get(i.key))
}
tigapo.prop:
testData.getUserHistoryPageUsingGETFile=HistoryControllerApi.csv
testData.createBillingUsingPOSTFile=BillingControllerApi.csv
testData.getCreditExchangeInfoUsingGETFile=BillingControllerApi.csv
testData.handleTagDetectionUsingPOSTFile=TagDetectionControllerApi.csv
testData.getSettingsUsingGETFile=SettingsControllerApi.csv
testData.createUserUsingPOSTFile=UserControllerApi.csv
With all steps disabled except one, no errors, and I get the vars in the output.
When I enable one step that uses a variable, the error is displayed.
And here is the CSV Data Config:
To make my comment easier to read:
Did what was suggested.
And verified that:
But still getting:
2022-05-10 16:32:46,656 INFO o.a.j.s.FileServer: Stored: ${testData.getUserUsingGETFile} Alias: ${testData.getUserUsingGETFile}#11286416
2022-05-10 16:32:46,656 ERROR o.a.j.t.JMeterThread: Test failed!
java.lang.IllegalArgumentException: Could not read file header line for file ${testData.getUserUsingGETFile}
at org.apache.jmeter.services.FileServer.reserveFile(FileServer.java:283) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.config.CSVDataSet.initVars(CSVDataSet.java:208) ~[ApacheJMeter_components.jar:5.4.3]
at org.apache.jmeter.config.CSVDataSet.iterationStart(CSVDataSet.java:171) ~[ApacheJMeter_components.jar:5.4.3]
at org.apache.jmeter.control.GenericController.fireIterationStart(GenericController.java:399) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.control.GenericController.fireIterEvents(GenericController.java:391) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.control.GenericController.next(GenericController.java:160) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.control.LoopController.next(LoopController.java:134) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java:91) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:254) [ApacheJMeter_core.jar:5.4.3]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_311]
Caused by: java.lang.IllegalArgumentException: File ${testData.getUserUsingGETFile} must exist and be readable
testData.getUserUsingGETFile=UserControllerApi.csv
Because CSV Data Set Config is being initialized before JSR223 PreProcessor, take a look at JMeter test elements execution order:
0. Configuration elements
1. Pre-Processors
2. Timers
3. Sampler
4. Post-Processors (unless SampleResult is null)
5. Assertions (unless SampleResult is null)
6. Listeners (unless SampleResult is null)
CSV Data Set Config is a configuration element hence it's being run before anything else.
so you need to:
Convert JSR223 PreProcessor to JSR223 Sampler
Put it under setUp Thread Group

Adding a link to an invoice into a notification message

I have a screen with a form contaning invoices I want to notify the user with. The screen is used as bodyScreenLocation for the EmailTemplate. Up to here, it works. I wanted to add a link for each invoice so that the user can open the document right from withing the message. How to construct the path? This way it does not work:
This field is created in a form, that is included in a screen. This screen is used in a template called using
<service-call name="org.moqui.impl.EmailServices.send#EmailTemplate" async="true">
Added 18.10.2016
I attempted to use your advice.
<actions>
<entity-find entity-name="mantle.account.invoice.Invoice" list="invoiceList"/>
<script>
import org.moqui.impl.context.WebFacadeImpl
def httpUrl = WebFacadeImpl.getWebappRootUrl('webroot',null,false,false,ec)
</script>
</actions>
This is the log:
21:47:18.996 WARN oquiWorker-2 o.moqui.i.c.TransactionFacadeImpl Transaction set rollback only. The rollback was originally caused by: Error rendering screen [component://HS-data/screen/Notification/PayablesDue.xml]
java.lang.NullPointerException: null
at org.moqui.impl.context.WebFacadeImpl.makeWebappHost(WebFacadeImpl.groovy:477) ~[moqui-framework-2.0.0.jar:2.0.0]
at org.moqui.impl.context.WebFacadeImpl.makeWebappRootUrl(WebFacadeImpl.groovy:520) ~[moqui-framework-2.0.0.jar:2.0.0]
at org.moqui.impl.context.WebFacadeImpl.getWebappRootUrl(WebFacadeImpl.groovy:467) ~[moqui-framework-2.0.0.jar:2.0.0]
at org.moqui.impl.context.WebFacadeImpl$getWebappRootUrl.call(Unknown Source) ~[?:?]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) ~[groovy-2.4.7.jar:2.4.7]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) ~[groovy-2.4.7.jar:2.4.7]
at PayablesDue_xml_screen_actions.run(PayablesDue_xml_screen_actions:11) ~[script:?]
What you're looking for is the WebFacade.getWebappRootUrl() method. Use a call that is something like this in your template to get the base URL:
ec.web.getWebappRootUrl(true, null)
When there is no WebFacade in place, such as when running in an async service, you'll have to drop a level lower and there is a static method in WebFacadeImpl for this (it's not so convenient when you don't have the standard interfaces to go through), here is the method signature:
String getWebappRootUrl(String webappName, String servletContextPath, boolean requireFullUrl, Boolean useEncryption, ExecutionContextImpl eci)
The standard webappName is 'webroot' and unless you're doing something fancy in your Moqui Conf XML file this can be a static String. The servletContextPath can be null or an empty String if your Moqui webapp is mounted on the root (commonly the case; without a request where we can get to the ServletContext to see where it is mounted this can't be determined automatically).

Rvest parse.response 404 error is breaking my for loop. How to keep looping?

I have the following section of code nested within a for loop
mywebsite <- html(webstring)
cast <- html_nodes(mywebsite,".some-node")
text_of_cast<-html_text(cast)
The problem is that one of the URLs returns the following error:
Error in parse.response(r, parser, encoding = encoding) : client
error: (404) Not Found
And this error breaks my for loop because the page doesn't exist.
Is it possible to ignore this error and keep looping?
It sounds that the "try" function from the base package is what you are looking for.

How long is a line after a readline(fh, line) call?

I have written a JSON parser in VHDL. The parser core uses two nested loops:
1. loop over all lines until EOF
2. loop over every char until line of end
For clearance: Its not a hardware parser. the parser used to read synthesis settings at synthesis time to configure instantiated entities like a baudrate in a UART module.)
The inner loop looks like this: loopj : for j in CurrentLine.all'range loop
Source: JSON.pkg.vhdl
This code works in XST 14.7, iSim 14.7 and GHDL, but not in Vivado. Vivado does not support .all. The error message is this one:
ERROR: [Synth 8-27] access type dereference not supported [D:/git/GitHub/JSON-for-VHDL/vhdl/JSON.pkg.vhdl:293]
Updated code, due to the hint from kraigher:
#Paebbles Have you tried foo'range instead of foo.all'range? I think I remember that it should implicitly work. - kraigher
I tried it before, but got an error. Maybe this error was related to another one. Now its working. So my current loopj line looks like this:
loopj : for j in CurrentLine'range loop
This line works fine in XST, iSim, GHDL and QuestaSim, but Vivado still has problems:
INFO: [Synth 8-638] synthesizing module 'Boards2' [.../Boards2.vhdl:16]
ERROR: [Synth 8-278] expression 0 out of range [.../JSON.pkg.vhdl:293]
ERROR: [Synth 8-421] mismatched array sizes in rhs and lhs of assignment [.../Boards2.vhdl:20]
ERROR: [Synth 8-285] failed synthesizing module 'Boards2' [.../Boards2.vhdl:16]
How can a expression be out of range? This message is very strange.
Is there another way to get a range for a loop, depending on how long the current line is?

iOS 6 - HTML encoded entities are not showing

I am trying to show following HTML encoded form of string in UI.
ひょ䥜 姌祦橯ね褎 れずしゅぎゅ穃 ぢょ簨ゝじ氯 苯䛣蟤 覵だ盨ꤎ拣 夯ぢゃ焯埥榥 楎べ楚 坩づ, 覌びょ は䦞びぢじょ 氧へヴェ栤儦 ぢゅ大廩 ぷ諥 礊䛨にょ 襦綦卣楌䨵 が椧りゅ樃驌 蟥ゞ睥盥䨣 騌捯 驩ぎょちゅ レ゜㩟カグォ階 猪仯壪黨ザ れずしゅぎゅ穃, お䤂 ぴゅにゅ䧣鏨以 コざちゃ㠤ジョ 苨䰯お
Using this library, I wrote following code
#import "NSString+HTML.h"
NSLog(#"%#",plainText);
NSLog(#"%#",[plainText stringByDecodingHTMLEntities]);
On executing code, I am getting following exception:
-[__NSCFString stringByDecodingHTMLEntities]: unrecognized selector sent to instance 0x7bd4200
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[__NSCFString stringByDecodingHTMLEntities]: unrecognized selector sent to instance 0x7bd4200'
*** First throw call stack:
(0x1caa012 0x10e7e7e 0x1d354bd 0x1c99bbc 0x1c9994e 0xa72d 0x4a0e53f 0x4a20014 0x4a107d5 0x1c50af5 0x1c4ff44 0x1c4fe1b 0x1c047e3 0x1c04668 0x2bffc 0x237d 0x22a5 0x1)
libc++abi.dylib: terminate called throwing an exception
Note: I also tested my HTML encoded string on this link and found no errors in my string format.
#import "NSString+HTML.h"
NSLog(#"%#",plainText);
NSLog(#"%#",[plainText stringByDecodingHTMLEntities]);
You need add NSString+HTML.h, NSString+HTML.m, GTMNSString+HTML.h, GTMNSString+HTML.m file to your project
add -fno-objc-arc
Build Phases -> Compile Sources -> select GTMNSString+HTML.m -> double click right Compiler flags and add -fno-objc-arc
Things were perfectly fine. All I needed was just to add compile source flag -fno-objc-arc by double clicking NSString+HTML.m and GTMNSString+HTML.m under Compile Source tab.
Just imported NSString+HTML.m and no need to import other class
Drag and drop NSString+HTML.m and GTMNSString+HTML.m in Compile Source tab first before adding flag.