Ron McLeod

Saloon Keeper
+ Follow
since Feb 12, 2013
Ron likes ...
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
Richmond, BC, Canada
Cows and Likes
Cows
Total received
239
In last 30 days
1
Total given
87
Likes
Total received
492
Received in last 30 days
11
Total given
703
Given in last 30 days
22
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ron McLeod

TransactionAttributeType.NOT_SUPPORTED solves the problem

Thanks Rob.
Yes - I just finished trying TransactionAttributeType.REQUIRES_NEW, and I was able to raise the alarm.

Now, I am trying to sort-out if I need to manually set the outer transaction to rolled-back or not.

Maybe if I make the raiseAlarm method TransactionAttributeType.NOT_SUPPORTED, I don't need to worry about this.

I have servlet calling an EJB (MessageServiceImpl), which calls another EJB (MessageRegistry) that performs a database lookup using JPA.  When there is a JPA failure, an exception is thrown.  I want to catch the exception, and raise an alarm indicating that there was a failure (which fires an SNMP trap), and then have the exception handled normally.  The alarm management is handled by another EJB (ManagementServiceImpl).

The issue that I am having is that after the JPA failure, the transaction associated with this processing has been marked as rolled-back, and the attempt to call the ManagementService EJB, results in an EJBTransactionRolledbackException being thrown (since it normally wouldn't make sense to continue processing if the transaction is over-with).

I could probably use a org.eclipse.persistence.exceptions.ExceptionHandler to catch the failure before the container rolls-back the transaction and raise an alarm there, but there would not be enough information to actually determine what type of application processing was being done (for example - how would it determine the the error was associated with looking up a message from the Message Registry).

Any ideas on what approach might be able to use to be able to call the ManagementService EJB after a JPA failure?

Your issue might be that there is a problem with the connector trying to establish a encrypted connection to the database.  As a test, try specifying useSSL=false.
As you have mentioned, GenericServlet is for protocol-independent servlets, and is a base class for protocol-specific servlet classes.

For servlets which deal with HTTP protocol, HttpServlet extends GenericServlet with HTTP-specific functionality.
Similarly for SIP protocol, SipServlet extends GenericServlet with SIP-specific functionality.
5 days ago
What are the version numbers of the MySQL database and the mysql-connector jar file?
5 days ago
You mentioned that the GET was successful, but the POST failed.  Is the GET in the same class?

Also, what does the URIs for the GET and POST requests look like?
6 days ago
Can you post a the Jersey resource class (or a simplified one which has the same issue) here?
6 days ago
Binary coded decimal (BCD) is a way of storing decimal digits 0 through 9 using a binary form.  BCD is often used with display devices with have limited or no processing capabilities.  It is also used is a lot of telephony signalling protocols, like the GSM protocol you are working with.  In telephony the two digits are generally packed in to a single octet, so when you see a value like 0011 0010, you need to evaluate the two 4-bit sections of the octet individually as two separate digits; not as one 8-bit value.

0011 represents the digit 3
0010 represents the digit 2


Here's another example which might help - counting from 0 to 25, using packed BCD:
Decimal     BCD
   0     0000 0000
   1     0000 0001
   2     0000 0010
   3     0000 0011
   4     0000 0100
   5     0000 0101
   6     0000 0110
   7     0000 0111
   8     0000 1000
   9     0000 1001
  10     0001 0000
  11     0001 0001
  12     0001 0010
  13     0001 0011
  14     0001 0100
  15     0001 0101
  16     0001 0110
  17     0001 0111
  18     0001 1000
  19     0001 1001
  20     0010 0000
  21     0010 0001
  22     0010 0010
  23     0010 0011
  24     0010 0100
  25     0010 0101

Stephan van Hulst wrote:I think the reason is that in many functional languages, underscore is used to indicate that you don't care about the value of a certain parameter because you're not going to use it. Maybe the Java designers wanted to keep this option open until they decided what they really wanted to do, so they prevented people from using it as an identifier so they don't have to worry about backwards compatibility.

Maybe in the future they will allow the use of underscore as a parameter name in lambda expressions, while prohibiting their use in lambda expression bodies, thereby enforcing the convention that underscores indicate the parameter is not used.


This agrees with what is mentioned in JEP 302: Lambda Leftovers:

Treatment of underscores
In many languages, it is common to use an underscore (_) to denote an unnamed lambda parameter (and similarly for method and exception parameters):

    BiFunction<Integer, String, String> biss = (i, _) -> String.valueOf(i);

This allows stronger static checking of unused arguments, and also allows multiple arguments to be marked as unused. However, because underscore was a valid identifier as of Java 8, compatibility required us to take a more indirect path to getting to where underscore could serve this role in Java. Phase 1 was forbidding underscore as a lambda formal parameter name in Java 8 (this had no compatibility consequence, since lambdas did not exist previously) and a warning was issued for using underscore as an identifier in other places. Phase 2 came in Java 9, when this warning became an error. We are now free to complete the planned rehabilitation of underscore to indicate an unused lambda, method, or catch formal parameter.

Ron McLeod wrote:Launch4j may work for you.  I have not used it myself, but I have used applications like the Arduino IDE which use it.


Excelsior JET might be another option.  I believe that they have a non-cost license for personal use.
1 week ago

Jim Venolia wrote:3 years ago I wanted to learn OO, Java seemed the way to go.  But if Java won't produce a .exe then, well, I'm not gonna call it wasted, just misdirected.


I don't see the connection between learning  OOD/OOP and producing .exe files, but if the end goal was to create Windows executables or Linux kernel modules, then C# or C++ might have been better choices.
1 week ago
Maybe you shouldn't be using Java for those types of applications.
1 week ago