Source code doesn't match byte code - in IntelliJ - intellij-idea

I've tried several approaches to creating a usable JAXBContent
JAXBContent jc = JAXBContent.newInstance(ClassName.class);
JAXBContent jc = JAXBContent.newInstance(contextPath:"Classname",ClassName.class.getClassLoader());
The exception is InvocationTargetException, which thrown as JAXBException
And when decompiling the JAXB classes in get the message "Source code doesn't match byte code"
Options are
rt.jar ../java/jre/lib`
oracle ../12.2.1.3/javax.javaee-api.jar
oracle ../12.2.1.3/com.oracle.webservices.wls.jaxws-wlswss-client.jar
First step is to resolve the exception source and byte code discrepancy, then the runtime classpath

Related

FluentAssertions throws ArgumentOutOfRangeException when assertion fails (possibly NCrunch related)

I'm using FluentAssertions 5.3.0 run under NCrunch 3.14.0.1. When a test fails, I often seen this error as FluentAssertions tries to generate a report message...
System.ArgumentOutOfRangeException: startIndex cannot be larger than
length of string. Parameter name: startIndex at
System.String.Substring(Int32 startIndex, Int32 length) at
FluentAssertions.CallerIdentifier.ExtractVariableNameFrom(StackFrame
frame) at
FluentAssertions.CallerIdentifier.DetermineCallerIdentity() at
FluentAssertions.Execution.AssertionScope.GetIdentifier() at
FluentAssertions.Execution.AssertionScope.FailWith(String message,
Object[] args) at FluentAssertions.Numeric.NumericAssertions`1.Be(T
expected, String because, Object[] becauseArgs) at
TableTests.ConsolidatedMovementsTester.AlternativingMovementStatesAreRecognised()
in ...test.cs
The error is sporadic - often it will disappear if the test is rerun (in which case, a proper error report is shown). I've seen this in the last couple of versions of both FluentAssertions and NCrunch and it appears on multiple machines (all running some flavour of Visual Studio 2017 Professional).
Here's an example of the latest call to bite me...
results.Count(c => c.IsStationary).Should().Be(5);
where results is an ImmutableArray of POCOs
In this case, right-clicking on the failing test and selecting "rerun in new test runner" in the ncrunch window, caused the test to re-run and FA to emit the correct report.
Can anyone suggest a workaround for this?

Console.ReadLine() throws nullpointer exception in Groovy

I started learning groovy yesterday and have been enjoying it thus far until I got to the part of the book where I have to take in inputs from the user using console().readLine() but I keep getting this error
Caught: java.lang.NullPointerException: Cannot invoke method readLine() on null object java.lang.NullPointerException: Cannot invoke method readLine() on null object
at com.usl.NewCodes.run(NewCodes.groovy:30)
I have tried it in intelliJ both as a groovy script and in a class. I even went on to try it in the groovyConsole yet it still throws an error.
Here is the code
print("What is your name ");
def fName = System.console().readLine()
println("Hello" + fName)
Thanks
If you are using any IDE for Groovy, the input / output console will not be available to you hence throwing null pointer exception so, you can use the following, If you are using Intellij enable groovy console from Tools -> groovy console for I/O.
println "What is your name?"
println "Your name is:"+System.in.newReader().readLine()

How to fail Velocity template processing with tracable message

Having:
Velocity template or macro
some object
How to validate the object (#if) and fail (stop further processing) in a way that is easily tracable to the place of failure (like throwing exception in Java).
I am looking for something like this:
#if ( ! $context.treasureMap.containsKey('gold'))
#fail('no golden treasure here')
#end
Background
I am writing a maven site page. The velocity context is injected by maven and contains POM information. I want to test existence of some information from effective pom. When the information is not available, I want to fail.
Requirements
fail Velocity processing > fail site generation > fail maven build.
error message should lead to the place of failure so the site should be fixed
preferably no configuration (no extensions, just constructs/tools contained in plain Velocity)
Tried
Strict Reference Mode
Unwanted configuration, do not want to fail on every occasion.
#evaluate('#end') aka syntax error
(Chose #end as most descriptive to my intent) Basically what I want. Fails the processing and maven build but the error message does not lead back to failure location:
ParseException: Encountered "#end" at line 1, column 1..
You need to make a method call which produce exception.See explanation:
The only place where one could run into trouble within Velocity is if there is a call to a method which throws an exception during runtime. For example, this VTL defines a String $foo and then attempts to call its substring() method on it would throw an IndexOutOfBoundsException:
#set ($foo = "bar")
#set ($bar = $foo.substring(0,10))
When the exception is thrown, the parser will stop processing and throw that exception up the stack tree where it can be caught in the method that caused the parser to execute. At that point, the exception can be handled gracefully.

TargetInvocationException Was Unhandled When Using fileWriter.Write()

I have a project in VB.NET that creates a byte array of an image input then creates a file of the image in .jpg format. Here is the code:
Dim fileWriter As New System.IO.FileStream(filePath,System.IO.FileMode.Create)
fileWriter.Write(imageBuf, 0, imageBuf.Length)
fileWriter.Close()
Once the code runs, I get the following error right after the second line executes:
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation.
I did take a look at similar posts on this site, however none of them seems to be relevant to mine. I would appreciate your input.
Thank you.

MQQueueManager Constructor throwing FileNotFoundException

I have the following vb.net code:
Imports IBM.WMQ
[...]
MQEnvironment.Hostname = hostName
MQEnvironment.Port = portNumber
MQEnvironment.Channel = channelName
queueManager = New MQQueueManager(queueManagerName) ' error here
which is throwing the following error:
System.IO.FileNotFoundException occurred
FileName=C:\Users\User\Documents\Visual Studio 2012\Projects\[...]\bin\Debug\mqclient.ini
HResult=-2147024894
Message=Could not find file 'C:\Users\User\Documents\Visual Studio 2012\Projects\[...]\bin\Debug\mqclient.ini'.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
I am not using any ini files in the construction of my queue manager, so does anyone have any idea what's going on - why is it even looking for one, and why in the same directory as the program? I have installed the MQ client, and afaik I have all the environmental variables, etc. set up properly.
Thanks for any help you can give
Is that an unhandled or a first chance exception? Internally, the MQ .net layer will try to read a MQClient.ini but should function quite happily without it. It reads the file for compatibility with the C client, and can handle some of the MQClient.ini stanzas. I would not have expected an absence of such a file to cause problems, but it will try to open it internally. Was that the full callstack, as I'd have expected some MQ libraries on the stack otherwise.