sending SMS via a commercial API (trendoo) : nullPointerException - java

I ask for help because I have a nullpointerexception that I don't understand.
here is the code:
try {
sr = application.launcher.getSmstrend().getConnexion()
.sendSMS(this);
}
} catch (Exception e) {
launcher.append(launcher.format_log.format(new Date())
+ " RDV.envoi : ERREUR d'envoi du message, " + e);
}
to be noted : the getConnexion() method returns a valid object (not null), and the this parameter is also not null. Smstrend is not "trendoo", a site which sends SMS via a java API. The error is :
sam. 11 janv. 2014 22-08-54 RDV.envoi : ERREUR d'envoi du message, java.lang.NullPointerException
can you explain me where to search?where is the null reference?

Related

JBoss EAP 6.4 with Hibernate - Hide a specific Oracle exception in log file

Playing with PersistenceException -> SQLException -> getErrorCode(), I'm hiding a specific Oracle error in my log. Problem is, in my server.log I still found rows like:
WARN 25 Sep 2018 12:14:47,121 - id - org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ms 5829302 SQL Error: 13333, SQLState: 72000
ERROR 25 Sep 2018 12:14:47,121 - id - org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ms 5829302 ORA-13333: invalid LRS measure
ORA-06512: at "MDSYS.SDO_LRS", line 3149
ORA-06512: at line 1
which aren't specifically logged by me.
Here is my code:
try {
try {
//business stuff
} catch (PersistenceException persEx) {
if (persEx.getCause() != null && persEx.getCause() instanceof GenericJDBCException) {
GenericJDBCException jdbcEx = (GenericJDBCException) persEx.getCause();
SQLException sqlEx = (SQLException) jdbcEx.getCause();
if (sqlEx.getErrorCode() == 13333) {
//handling ORA-13333: invalid LRS measure as an info
log.info("Possible invalid LRS measure");
} else {
throw persEx; // do not swallow unhandled exceptions
}
} else {
throw persEx; // do not swallow unhandled exceptions
}
} catch (Exception e) {
log.error("Other exception:" + e.getMessage());
}
} catch (Exception e) {
log.error("Exception to log:" + e.getMessage());
}
Solved by adding a specific filter to the JBoss log handler, in this case
<filter-spec value="all(not(match("ORA-13333")), not(match("SQL Error: 13333")))"/>
I hope it can be useful to someone else.

Has there anyway to ignore errors of google-closure JSCompiler?

I tried to compress Inputmask.js file. Here is my code to work
public class JSFileMinifyTest {
public static void main(String[] args) throws Exception {
String sourceFileName = "D:\\temp\\jquery.inputmask.bundle.js";
String outputFilename = "D:\\temp\\combined.min.js";
com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.INFO);
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
CompilerOptions options = new CompilerOptions();
CompilationLevel.WHITESPACE_ONLY.setOptionsForCompilationLevel(options);
options.setAggressiveVarCheck(CheckLevel.OFF);
options.setRuntimeTypeCheck(false);
options.setCheckRequires(CheckLevel.OFF);
options.setCheckProvides(CheckLevel.OFF);
options.setReserveRawExports(false);
WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
// To get the complete set of externs, the logic in
// CompilerRunner.getDefaultExterns() should be used here.
SourceFile extern = SourceFile.fromCode("externs.js", "function alert(x) {}");
SourceFile jsFile = SourceFile.fromFile(sourceFileName);
compiler.compile(extern, jsFile, options);
for (JSError message : compiler.getWarnings()) {
System.err.println("Warning message: " + message.toString());
}
for (JSError message : compiler.getErrors()) {
System.err.println("Error message: " + message.toString());
}
FileWriter outputFile = new FileWriter(outputFilename);
outputFile.write(compiler.toSource());
outputFile.close();
}
}
But error occured while compressing this js file.
Apr 09, 2018 11:29:18 AM com.google.javascript.jscomp.parsing.ParserRunner parse
INFO: Error parsing D:\temp\jquery.inputmask.bundle.js: Compilation produced 3 syntax errors. (D:\temp\jquery.inputmask.bundle.js#1)
Apr 09, 2018 11:29:18 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: D:\temp\jquery.inputmask.bundle.js:1002: ERROR - Parse error. identifier is a reserved word
static || null !== test.fn && void 0 !== testPos.input ? static && null !== test.fn && void 0 !== testPos.input && (static = !1,
^
Apr 09, 2018 11:29:18 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: D:\temp\jquery.inputmask.bundle.js:1003: ERROR - Parse error. syntax error
maskTemplate += "</span>") : (static = !0, maskTemplate += "<span class='im-static''>");
^
Apr 09, 2018 11:29:18 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: D:\temp\jquery.inputmask.bundle.js:1010: ERROR - Parse error. missing variable name
var maskTemplate = "", static = !1;
^
Apr 09, 2018 11:29:18 AM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 3 error(s), 0 warning(s)
Error message: JSC_PARSE_ERROR. Parse error. identifier is a reserved word at D:\temp\jquery.inputmask.bundle.js line 1002 : 16
Error message: JSC_PARSE_ERROR. Parse error. syntax error at D:\temp\jquery.inputmask.bundle.js line 1003 : 29
Error message: JSC_PARSE_ERROR. Parse error. missing variable name at D:\temp\jquery.inputmask.bundle.js line 1010 : 39
Has there anyways to skip syntax validations or ignore errors and continue to compress ?
The compiler by default, parses code as 'use strict'. 'static' is a reserved word in strict mode. You can either change the language mode or simply renamed the variable from 'strict' to something else.
The strict mode reserve words are documented here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode#Paving_the_way_for_future_ECMAScript_versions

how to validate all preflight error for PDF/A-1a in pdfbox

i am working with vaildate PDFA/1A .I followed this code which already exist in this link PDFbox Preflight PDF/A-1b check not working properly in java version 1.8
public class test
{
public static void main(final String[] args) throws Exception
{
File pdfa=new File("D:/DMC-B787-A-00-40-07-00A-008B-D.pdf"); // error pdf
isPDFAdocument(pdfa);
System.out.println("sucess");
}
private static void isPDFAdocument(File pdfa)
{
ValidationResult result = null;
PreflightParser parser;
try
{
parser = new PreflightParser(pdfa);
parser.parse(Format.PDF_A1A);
PreflightDocument documentt = parser.getPreflightDocument();
result = documentt.getResult();
System.out.println("result"+result);
documentt.close();
}
catch (SyntaxValidationException e)
{
result = e.getResult();
}
catch (IOException e)
{
e.printStackTrace();
}
if (result.isValid())
{
System.out.println("The file " + pdfa + " is a valid PDF/A-1a file");
}
else
{
System.out.println("The file" + pdfa + " is not valid, error(s) :");
for (ValidationError error : result.getErrorsList())
{
System.out.println(error.getErrorCode() + " : " + error.getDetails());
}
}
it's not checking the error which mention below .if there it have to show exception but still its vaildate success.
Kindly suggest how to validate all probability preflight error below .how to check it in pdfbox.
Error
CharSet incomplete for Type 1 font (2 matches on 1 page) - 2
Width information for rendered glyphs is inconsistent (2 matches on 1 page) - 2
Document information
File name: "DMC-B787-A-00-40-07-00A-008B-D.pdf"
Path: "C:\Users\wm751e\Documents\Feb19\Synchronize print\Only WDM\Archived doctypes
latest\EA_TBC2016-02-2115.57.49IPD\EA_TBC2016-02-2115.57.49IPD\00"
PDF version number: "1.4"
File size (KB): 114.2
Title: "Illustrated Parts Data - Service Bulletin/Modification List"
Author: "The Boeing Company (PRINTENGINEWEB_BUILD_1.7.49.5.0.0; s1000d_merged_v6.5.36_4.xsl; JobID:)"
Creator: "AH XSL Formatter V6.0 MR7 for Linux64 : 6.0.8.9416 (2013/02/26 10:36JST)"
Producer: "Antenna House PDF Output Library 6.0.389 (Linux64)"
Created: "2/21/2016 3:56 PM"
Modified: "2/21/2016 3:56 PM"
Trapping: "False"
Number of plates: 4
Names of plates: "(Cyan) (Magenta) (Yellow) (Black) "
Environment
Preflight, 15.0.0 (151)
Acrobat version: 15.60
Operating system: Microsoft Windows 7 Service Pack 1 (Build 7601

Facebook4j - "null information" from FriendList

I've been trying to get some informations from my Friends throught facebook4j. But every time I try to do it I receive only null pointers (except on id/name).
Here's the code:
`
Stalker(String victimUsername, String yourUsername,boolean isFriend) {
try {
friendList = facebook.getFriends(yourUsername);
if(isFriend){
int index = friendList.indexOf(facebook.getUser(victimUsername));
victimUser = friendList.get(index);
println(victimUser);
}
else
victimUser = facebook.getUser(victimUsername);
try {
birthdayVictimDate.setTime(df.parse(victimUser.getBirthday()));
}
catch(ParseException e) {
e.printStackTrace();
}
victimProfilePic = loadImage(facebook.getPictureURL(victimUsername).toString());
}
catch(FacebookException e) {
e.printStackTrace();
}
}
`
As you can see:
FriendJSONImpl extends UserJSONImpl [id=733939867, name=Tamires Ribeiro, firstName=null, middleName=null, lastName=null, gender=null, locale=null, languages=[], link=null, username=null, thirdPartyId=null, timezone=null, updatedTime=null, verified=null, bio=null, birthday=null, cover=null, education=[], email=null, hometown=null, interestedIn=[], location=null, political=null, favoriteAthletes=[], favoriteTeams=[], picture=null, quotes=null, relationshipStatus=null, religion=null, significantOther=null, videoUploadLimits=null, website=null, work=[]]
If the user isn't a friend of mine I can acess some of those informations, and I get this:
UserJSONImpl [id=733939867, name=Tamires Ribeiro, firstName=Tamires, middleName=null, lastName=Ribeiro, gender=female, locale=pt_BR, languages=[], link=https://www.facebook.com/tamiresribeirodias, username=tamiresribeirodias, thirdPartyId=null, timezone=null, updatedTime=Sat Oct 26 21:20:17 BRST 2013, verified=null, bio=null, birthday=05/13, cover=null, education=[EducationJSONImpl [year=null, type=College, school=IdNameEntityJSONImpl [name=Federal University of Rio de Janeiro, id=109442119074280], degree=null, concentration=[], classes=[], with=[]]], email=null, hometown=null, interestedIn=[], location=null, political=null, favoriteAthletes=[], favoriteTeams=[IdNameEntityJSONImpl [name=Vegetarianos Pensam Melhor, id=240337606020973], IdNameEntityJSONImpl [name=Fluminense Football Club, id=159225040801899]], picture=null, quotes=null, relationshipStatus=In a relationship, religion=null, significantOther=IdNameEntityJSONImpl [name=Pedro Gabriel Lancelloti Pinto, id=100000337547270], videoUploadLimits=null, website=null, work=[]]
As you can see, I can get lot of more informations directly trought facebook wich is confusing because as friend I should get the same or more infomartion.
Does anybody knows why this happen and how it could be solved?
PS: at my app I set on permissions "friends_birthday" and set it also at my user_token.

How to get the line number in error in java?

I know that the line in error is to_return = find(list,false); How can I get the line number of this line when there is NullPointerException type of error? Or in line number in general?
I tried few things. The closest is this one Called.getLineNumber() which gives me the line number of StackTraceElement Called = new Throwable().fillInStackTrace().getStackTrace()[0];
public TestObject[] myfind(Subitem list )throws Exception{
TestObject[]to_return=null;
try {
to_return = find(list,false);
}
catch (RationalTestException ex) {
//logStoreException(ex);
StackTraceElement Called = new Throwable().fillInStackTrace().getStackTrace()[0];
StackTraceElement Calling = new Throwable().fillInStackTrace().getStackTrace()[1];
throw new Exception (this.add_debugging_info(Called, Calling, ex.getMessage()));
}
catch (NullPointerException npe) {
StackTraceElement Called = new Throwable().fillInStackTrace().getStackTrace()[0];
StackTraceElement Calling = new Throwable().fillInStackTrace().getStackTrace()[1];
logStoreException(npe);
System.out.println("Line number: "+npe.getStackTrace()[0].getLineNumber());
System.out.println("Line number2: "+Integer.toString(Called.getLineNumber()));
System.out.println(this.add_debugging_info(Called, Calling, npe.getMessage()));
throw new Exception (this.add_debugging_info(Called, Calling, npe.getMessage()));
}
catch (Exception ex) {
StackTraceElement Called = new Throwable().fillInStackTrace().getStackTrace()[0];
StackTraceElement Calling = new Throwable().fillInStackTrace().getStackTrace()[1];
throw new Exception (this.add_debugging_info(Called, Calling, ex.getMessage()));
}
finally {
//unregisterAll();
//unregister(to);
return to_return;
}
}
If you just want the current stack trace, use Thread.currentThread().getStackTrace()
If you want to force the JVM to fill in the stack traces, please set the option -XX:-OmitStackTraceInFastThrow on your JVM.
When running in Eclipse, to get the line number itself, you need to get the StackTrace array and call getLineNumber() on it.
The following worked for me in my Utils class, isSessionConnectible method:
... catch (ClassFormatError cfe) {
logger.error("Problem ClassFormatError connecting. " + cfe.getMessage() + " " + cfe.getCause());
int size = cfe.getStackTrace().length - 1;
logger.error(" Root cause: " + cfe.getStackTrace()[size].getMethodName() + " " + cfe.getStackTrace()[size].getClassName());
if (size>1) {
logger.error(" Penultimate cause: method=" + cfe.getStackTrace()[size-1].getMethodName() + " class=" + cfe.getStackTrace()[size-1].getClassName() +
" line=" + cfe.getStackTrace()[size-1].getLineNumber());
}
Result when thrown:
2018-07-06 12:00:12 ERROR Utils:319 - Problem ClassFormatError connecting to Hibernate. Absent Code attribute in method that is not native or abstract in class file javax/transaction/SystemException null
2018-07-06 12:00:12 ERROR Utils:322 - Root cause: main <mypackage>.Utils
2018-07-06 12:00:12 ERROR Utils:324 - Penultimate cause: method=isSessionConnectible class=<mypackage>.Utils line=306
BTW, in Eclipse, make sure that Window --> Preferences --> Java --> Compiler has the checkbox marked at "Add line number attributes to generated class files".

Categories

Resources