When sending Andoird Build to server I get the following build error:
Error! Failed to transform some classes java.lang.RuntimeException:
Method code too large! at
net.orfjackal.retrolambda.asm.MethodWriter.getSize(MethodWriter.java:2036)
at
net.orfjackal.retrolambda.asm.ClassWriter.toByteArray(ClassWriter.java:827)
at
net.orfjackal.retrolambda.Transformers.transform(Transformers.java:121)
at
net.orfjackal.retrolambda.Transformers.transform(Transformers.java:106)
at
net.orfjackal.retrolambda.Transformers.backportClass(Transformers.java:46)
at net.orfjackal.retrolambda.Retrolambda.run(Retrolambda.java:72) at
net.orfjackal.retrolambda.Main.main(Main.java:26)
I must confess I'm not sure why this is occurring as I do not references these classes. Could someone please explain how to track down the cause and fix it? I have not added any new imports since the last successful build :/ My project is also set to use Java 8. Not sure where to go from here to be honest.
there is a hard limit on the size of methods in a class file of 64k. You have at least one big method that you need to split up. It may have been coming in just under the limit for the initial compilation but the retrolambda conversion just pushed it over. You need to split these methods into smaller methods.
This error doesnt really give you a clue as to which methods are problematic but you can probably eyeball it.
Related
I am new to Salesforce apex coding. My first class that I am developing has 10 methods and is some 800 lines.
I haven’t added much of exception handling, so the size should swell further.
I am wondering, what the best practice for Apex code is... should I create 10 classes with 1 method instead of letting 1 class with 10 methods.
Any help on this would be greatly appreciated.
Thanks
Argee
What do you use for coding? Try to move away from Developer Console. VSCode has some decent plugins like Prettier or Apex PMD that should help you with formatting and making methods too complex. ~80 lines/method is so-so. I'd worry about passing long lists of parameters and having deeply nested code in functions rather than just their length.
There are general guidelines (from other languages, there's nothing special about Apex!) that ideally function should fit on 1 screen so programmer can see it whole without scrolling. Read this one, maybe it'll resonate with you: https://dzone.com/articles/rule-30-%E2%80%93-when-method-class-or
I wouldn't split it into separate files just for sake of it, unless you can clearly define some "separation of concerns". Say 1 trigger per object, 1 trigger handler class (ideally derived from base class). Chunkier bits not in the handler but maybe in some "service" style class that has public static methods and can operate whether called from trigger, visualforce, lightning web component, maybe some one-off data fix would need these, maybe in future you'd need to expose part of it as REST service. And separate file for unit tests (as blasphemous as it sounds - try to not write too many comments. As you're learning you'll need comments to remind yourself what built-in methods do but naming your functions right can help a lot. And a well-written unit test is better at demonstrating the idea behind the code, sample usage and expected errors than comments that can be often overlooked).
Exception handling is an art. Sometimes it's good to just let it throw an exception. If you have a method that creates Account, Contact and Opportunity and say Opportunity fails on validation rule - what should happen? Only you will know what's good. Exception will mean the whole thing gets rolled back (no "widow" Accounts) which sucks but it's probably "more stable" state for your application. If you naively try-catch it without Database.rollback() - how will you tell user to not create duplicates with 2nd click. So maybe you don't need too much error handling ;)
I have a block of deprecated Ruby on Rails code which is the beginning of a rake file and doesn't depend on anything except accessing the Protein class, which it can (inherited from an earlier version of the project)
task :import_merops_cleavages do
require "#{Rails.root}/config/environment"
require 'bio'
require 'merops'
require_relative '../../app/models/protein.rb'
proteases = Protein.includes(:drs).map(&:drs).where(db_name: 'MEROPS').uniq
#total = proteases.count
puts "starting import of #{#total} proteases"
#added = 1
#padded =1
Every time I try to rake this particular task, the rake aborts and I get the same error message
NoMethodError: undefined method where for #<Array:0x00007f88a625d290> Did you mean? when
I have tried to use other methods to get rid of the where or rearrange things but keep the logic the same, but am at a loss. If anyone has an idea how to resolve this, I would be very grateful
Edit: this is the main visual relational documentation for the application, but I can explain anything that may not make sense.
The error is correct, the where method is not available on Arrays.
It can only be used on rails models.
The map method returns an array, so I reckon you're issue is there.. try removing the .map and see if that solves this issue.
So I'd imagine something like this might work:
proteases = Protein.all.where(db_name: 'MEROPS').uniq
Tell us more about what Protein is.. better yet share the code for it.
I'm trying to catch "nrpe unable to read output" output from plugin and send an email when this one occurs and I'm a little bit stuck :) . Thing is there are different return codes when this error occurs on different plugin:
Return code Service status
0 OK
1 WARNING
2 CRITICAL
3 UNKNOWN
Is there a way either to unify return codes of all plugins I use(that there always will be 2[CRITICAL] when this problem occurs), or any other way to catch those alerts? I want to keep return codes for different situations as is(i.e. filesystem /home will be warning(return code 1) for 95% and critical(return code 2) for 98%
Most folks would rather not have this error sending alert emails, because it does not represent an actual failed check. Basically it means nothing more than:
The command/plugin (local or remote) was ran by NRPE, but
failed to return any usable status and/or text back to nrpe.
This most often means something went wrong with the command/plugin and it hasn't done the job it was expected to perform. You don't want alerts being thrown for checks, when the check wasn't actually performed - as this would be very misleading. It's also important to note that the Return Code is not even be coming from the command/plugin.
In my experience, the number one cause of this error is a bad check. And as the docs for NPRE state, you should run the check (with all its options!) to make sure it runs correctly. Do yourself a favor and test both working AND not working states. About 75% of the time, this has happened because the check only works correctly when it has OK results, and blows up when something not-OK must be reported.
Another issue that causes these are network glitches. NRPE connects and runs the check; but the connection is closed before any response is seen. Once again, not a true check result.
For a production Nagios monitoring system, these should be very rare errors. If they are happening frequently, then you likely have other issues that need to be fixed.
And as far as I can tell, all built-in Nagios plugins use the exact same set of return codes. Are you certain this isn't a 'custom' check?
Ok, I think I've found the solution for my problems-I will try to check nagios.log on each node for those errors.
I have a CakePHP error and I having a hard time to trace the problem. Hope you can help me.
Here is the error message:
Missing Database Table
Error: Database table cake_errors for model CakeError was not found.
Notice: If you want to customize this error message, create app/views/errors/missing_table.ctp
Am I missing something here?
Thanks in Advance.
Cheers,
Mark
Its hard to tell why exactly without seeing the code firsthand, one trick i have used with theese kinds of errors though is making "app/views/errors/missing_table.ctp" as inserting the following code
<?php pr( Debugger::trace() ); ?>
This will will help workout what you called to cause this issue in the first place.
I realize this question is 4 years old, but since I bumped into the exact same problem and found no information about it that could explain where the error is coming from, I did some digging of my own and come up with some clues that I include here in case it helps.
My AppController beforeFiler() method, amongst other things, uses a function that checks if the Model of the Controller has enum fields (I know... I know...) and handles them "properly".
When an error in the application triggers an Exception (Nothing fancy... a "Missing Controller" does it) and the debug level is 0, the CakeErrorController tries to render the exception and it fails because there's no cake_errors table, generating an endless loop that ends when PHP runs out of memory.
I fixed this by improving the detection of whether the main Model of the controller is indeed using a "real" table.
I am using plugins for one of my Mac OS X(desktop) application. These plugins refer to a common file that contains base class implementation of both the plugins.
When the application refers to this common base class, the following message is displayed in the console by the system:
" is implemented in both and . One of the two will be used. Which one is undefined."
This console message is displayed from 10.5.x onwards.
However this does not cause any problem. But, I do not want my class name to be printed in the console. Can someone help to avoid this console message.
A possible way around is to #define the name of your class as something unrelated, so that it remains the same in your code, for your use, but is obfuscated in the executable.
I'd like a neater solution myself. I have searched quite a lot, and it seems that in general console messages are for solving problems, rather than for looking for them, and more specifically that this kind of message isn't really an issue.
One can also use an EXPORTED_SYMBOLS_FILE or an UNEXPORTED_SYMBOLS_FILE (these are the relevant build setting names) to state which symbols you do or don't want to export. Often, you want to export at least one, but it can reduce the number of names that are revealed.