Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!

Tim Holloway

Saloon Keeper
+ Follow
since Jun 25, 2001
Tim likes ...
Android Eclipse IDE Tomcat Server Redhat Java Linux
Long-time moderator for the Tomcat and JavaServer Faces forums. Designer and manager for the mousetech.com enterprise server farm, which runs VMs, a private cloud and a whole raft of Docker containers.
These days, doing a lot of IoT stuff with Arduinos and Raspberry Pi's.
Jacksonville, Florida USA
Cows and Likes
Cows
Total received
161
In last 30 days
2
Total given
29
Likes
Total received
2204
Received in last 30 days
19
Total given
207
Given in last 30 days
5
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tim Holloway

PLEASE don't throw around loose acronyms!

My first reaction to BOM was Bill of Materials. The second was to Google and get Bureau of Meteorology/Mining.

Only by doing a fine-tuned search on UTF-8 did I get Byte Order Marker.

This is a Java in GENERAL forum and we're "A friendly place for programming greenhorns". I'd be unhappy if BOM was used unexplained in an I18N forum, but it's even more inappropriate here.

Hmm. OK. On closer reading, I MIGHT have inferred BOM's meaning after reading several posts and doing a certain amount of meditation. But modern times are not friendly to that sort of thing.

Now that I've vented about insufficient context, my Humble Opinion is that any stream reading that sees Byte Order Markers as something to explicitly pass on isn't properly operating as a text reader, it's operating in raw mode and therefore not the proper choice.

Once read as Java Strings everything's supposed to be Unicode and the infrastructure should be invisible. Thus, the Stream level - or at worst the Reader level - should have dealt with it.
3 hours ago
I think you've got your ideas of clients and servers fuzzed there.

Tomcat is a webapp server. It accepts requests from web clients. Those clients may be running as applications on other server machines, but regardless, from Tomcat's point of view, only Tomcat is the server when web requests come in. Tomcat doesn't care if the request comes from a user's desktop, an Internet of Things device (I actually do a lot of that!) or another machine that itself hosts webapp servers. And, of course, using web services, it's not uncommon for a web request to come into one server, and the web application in that server make requests to backend servers running Tomcat and/or other webapp server programs. We can put load-balancers and reverse-proxy servers in front of Tomcat as well. They are clients for Tomcat, too.

OK. Hope that makes sense. Now if you want to restrict which clients can access stuff on your Tomcat server, you have 2 primary choices. One is via a user identity and the other is by blocking everything at the network level. Often we'll do a little of both.

Using a user login on a Tomcat webapp allows you to establish a security session and you can use this session to allow access only to certain URLs served by the Tomcat server. So, for example, my client may no be allowed to access URLs whose resource path is /admin unless I've granted an admin role to that userid.

Blocking at the network level is usually all-or-nothing for the source IP address. You CAN use a Tomcat Valve  to limit what IPs Tomcat will listen to, but it's usually easier to employ the firewall of the machine that Tomcat's running in. Changing a Tomcat Valve requires modifying the basic Tomcat configuration, which requires restarting Tomcat. And should only be done by people who understand Tomcat. Filtering via OS firewall, on the other hand, is a standard sysadmin task and does not require stopping and restarting Tomcat. Also incoming requests are blocked well upstream of Tomcat, which reduces the amount of mayhem that Bad Packets could exploit security weaknesses downstream.

There's also another option, rarely used, where you assign client security certficates and define corresponding keys in your Tomcat server. Doing this eliminates the need for an explicit login and password, but it's best used for permanent internal client machines. The problem with client certs is that 1) if the client machine gets stolen, so does the cert and the thief can happily chat to your Tomcat server, subject only to firewall restrictions. The other problem is that if the client machine breaks down and has to be swapped out, you have to ensure that the replacement has its own security cert installed.

6 hours ago
Let's say I've defined a single class that acts as a Comma-separated (CSV) File parser. It's general purpose, so I'd like to use it as a "mini library". For consistency's sake, I'd be best off putting it in a JAR file, but if I wanted to, I could just keep it as a loose class file. You'd need to put it on your compiler classpath to be able to use it when compiling apps that read CSVs. And you'd need to put it on the runtime classpath when you executed your apps, since compiling doesn't merge input classpath files (previously-compiled classes) into the classes being output.

Mike Gosling wrote:
This is probably correct, but I don't think that is the reason why I'm getting error above. Project is two and a half year in production without hash and equals.



Lots of things "work" - until they don't. Sometimes you can fail to follow protocol and be lucky - for a while.

.hbm.xml is an XML file(s) that do the entity mapping for legacy Hibernate. Java annotations have superseded the need for them. Be glad.

Far more valuable than your Maven POM would be your Spring Framework application context definitions where you define your beans and their relationships.

You're obviously connecting something incorrectly, since SingleTableEntityPersister is designed to be instantiated internally by Hibernate with constructor arguments supplied and it appears that Spring is trying to explicitly construct an instance of SingleTableEntityPersister without constructor arguments. Spring also constructs singleton instances by default, but as I read it, each Entity class managed by SingleTableEntityPersister should have its own matching instance of SingleTableEntityPersister.
6 hours ago
FreeType is an open-source typeface support library and if memory serves, originally reverse-engineered Microsoft's TrueType functions and later also Adobe Type 1.

As far as I know, it's going to be pre-installed on virtually any Linux system with the possible exception of text-only ones. And even some (all?) of them, since you can still typeset without a GUI desktop (using ghostscript and something like TeX - or brute-force PostScript).

It would be even more unusual not to find it in a Java system, since I'll virtually guarantee that Swing/AWT tap into it, indirectly, if not directly.

Of course, if this is a Windows machine, it might be different, since FreeType was designed to provide things that Windows already had - in proprietary form.
20 hours ago
There is an open-source Java-based (Spring Boot) "OpenCMIS" sponsored by Alkacon Software. It's not obviously related to Apache Chemistry OpenCMIS but it has seen maintenance within the last 6 months or so.

It's also available in Docker Container form, which is nice for quick deployments.
Oh yeah, that thing.

Someone who had the same problem has listed the following 3 likely causes for that error:

1.  Your Java POJO Mapping class may not have the empty/default constructor.
2.  Your Set/List or any collection class may not have the default constructor or overridden hashcode and equals method. That is, the same rules apply for any joined collections/parent-children.
3.  Set name you have given in the java class and mapping .hbm.xml file may be different.

Note that having an .hbm.xml file is not recommended these days, so the third problem shouldn't be a problem.

But you cannot use java.lang.Object's hashCode and equals methods.

In JPA, you might have multiple versions of the same database row in memory in different objects. Like if you fetch a row and make changes to it. The only way that JPA can distinguish between the "before" and "after" versions of that row - instead of confusing them with other rows in the database is to consider them as the same row (equals) by comparing ONLY the keys of that object. Since hashCode must track equals(), that means customizing hashCode to hash only on the key field(s) as well.
1 day ago
Did you define a no-argument constructor for your SingleTableEntityPersister entity class?

All JPA Entity classes must define a no-argument constructor and (usually) overide the hashCode() and equals() methods.
1 day ago
True decimal is incompatible with floating-point - unless you can find a FP system whose exponent covers in 10's rather than in 2's or 16's. And I've never seen one, and definitely not in hardware.

COBOL defined a set of COMPUTATIONAL data types and the pure language spec doesn't indicate which flavour is what. For IBM, COMPUTATIONAL-2 was their (non-IEEE) floating point and COMPUTATIONAL-3 was "packed decimal". Vanilla COMPUTATIONAL was pure binary.

The IBM System/360 and later mainframes all had native packed-decimal instructions plus conversion-assist instructions. The Intel 8080 and Motorola MC6800 MPUs also had packed-decimal native instructions, although with some notable differences (like being open-ended instead of limited to 15 digits). Packed Decimal is widely regarded as a "business data processing" format, and I think it's safe to say that the designers of Java were not oriented in that direction.

As for unsigned, that was pretty definitely a deliberate omission and we've discussed it elsewhere. If they'd wanted Java to be a "bit twiddling" language, it would have other missing features as well. I think maybe they wanted to leave an opening for variable integer sizes and you can get in a lot of trouble when you blur the boundaries between the mathematical concepts of integer and whole numbers (which is what unsigned numbers technically are). And one thing Java DEFINITELY was designed for was to avoid trouble.
1 day ago
I'm kind of fuzzy here, both because I'm unfamiliar with Zapier (which actually sounds - superficially - like it may be doing its own polling), and because I'm not sure of the workflow itself.

The Unix mail system architecture included a way for individual users to scan incoming mail and do many things. Primarily, these days that means vetting it through SpamAssassin and/or ClamAV, but also "out of Office" notifiers and really any application. It was common, for example, for early open-source software to be be available by sending a specially email to a university email account that had a robot which would mail back the application source code. I think I got PCCTS this way, in fact.

You can also do after-the-fact processing. Every day on my machine a scheduled Python program opens my IMAP account and sorts through selected folders, deleting old mails (stuff like expired coupons in the junkmail folder, for example). I could have done this in Java, it's just that I was too lazy. However, for a few years I did have an OSGi app under Apache Karafe that would pull Nationial Weather Service bulletins during hurricane season and summarize them as well as scanning inputs from job services to discard the ones that said things like "No Remote Work".

Since I'm also long out of practice with Outlook, I cannot say definitively, but I'd expect you could add a snap-on service that would talk to Java. The cleanest way these days seems to be to make the Java target be a webapp server (probably a Spring Boot app).
1 day ago

fred rosenberger wrote:computers do not deal well with decimal numbers when using things like a double or a float.


Most microprocessors actually do have true decimal arithmetic instructions, but none of the Java native datatypes use that form. The best you can get is BigDecimal. One of the (relatively) few advantages that the old COBOL programming language had.

For cases where BigDecimal isn't practical, the general tactic is to scale the numbers into a cleaner range. For example, if you're adding/subtracting US currency values (2 decimals), you can multiply the values by 100. To display the results, you'd print out like so:

Note that that's an INTEGER divide, so it truncates (not rounds). And the "%02d" means pad with leading zeroes so that $2.01 doesn't output as "2.1".
1 day ago

Jesse Silverman wrote:
In Python, five members of the same class could potentially all have different data members -- not different values, but different *members*.
That can never happen in Java/C++/C#, the name of a class tells you all the data members any instance of it will ever have....



To clarify, five instances of the same class could potentially all have different (named) data members.

This is also true of JavaScript, I believe. object-oriented implementations of LISP, and possibly Smalltalk.
1 day ago
We don't have any complaints about what forum you posted in (we'd move it, if we thought there was a better choice).

But all your edits were really confusing.

Please don't edit stuff unless you've spelled something unintelligently badly (like me). Making code appear and disappear, adding/removing basic questions, and other stuff like that should not be done in edits. If you've got a major change, re-post it with the changes in it.

Yes, I edited this. My spell checker changed "unintelligently" to "intelligently". Which is the sort of thing I was talking about, as it happens.
2 days ago
You have 3 types of data here.

1. Servlet-name. This is an identifier used to link a URL(s) to a servlet. It NEVER contains a slash, because it's just an ID. It's a simple word chosen by you and not visible to anything else but the server's container mapper.

2. URL-pattern. This is a wild-card expression representing a URL resource path. That is, everything after the "http://hostname:1234/mywebapp" part of a URL and before the funny characters like "?" or ";".

A URL-pattern can be absolute or relative. For example, /myservlet is absolute. "*foo*" is relative - any URL with "foo" anywhere in its resource path matches, including "/mywebapp/foo/bar" and "/genericappfoo123".

3. A servlet classname. As I said, this must be a fully-qualified class name such as com.javaranch.foo.servlets.MyWebapp. This NEVER has a slash in it because they're not valid Java classname/package component characters.

Note: Edited #3 above because I mistyped a slash into it.
3 days ago
You are correct. That would be the mechanism you'd use if you wanted to "hide" the actual resource location (and filename extension) of a JSP and make it look exactly like a servlet from the viewpoint of a URL.

If is very definitely not common practice, however, since virtually all modern webapp frameworks dispatch into a servlet. And/or simply use the ".jsp" extension in their URLs.
3 days ago