Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!

Claude Moore

Bartender
+ Follow
since Jun 24, 2005
Claude likes ...
IBM DB2 Netbeans IDE Spring Java
Italy
Cows and Likes
Cows
Total received
39
In last 30 days
0
Total given
12
Likes
Total received
129
Received in last 30 days
0
Total given
287
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Claude Moore

Machine learning is a vast topic. Sentiment analysis IMHO is a good candidate for a first approach; there are lot of free dataset and example on the web, the training of the model shouldn't take to much time so that you can taste ML without a great effort.
If you specify GET method with @Requestmapping, the Rest endpoint will respond only to GET requests. Are you really sure you are POSTing a request???
What happens using curl - for example ?
2 weeks ago
Thanks for you pretty detailed answer.
What I was asking for was more design-oriented, i.e if JTA is - generally - fading away, at least within Spring and Spring Boot world.
3 weeks ago
In the latest releases, I've noticed that the number of JTA providers officially supported in Spring Boot has been remarkably reduced.
When I started using Spring boot about three years ago, there were three 'starters' providing JTA support: Narayana, Bitronix and Atomikos.
Now Narayana isn't mentioned anymore in the official latest documentation, while Bitronix is marked as deprecated.
This obviously imply that the only choice left is using Atomikos.
I wonder if the next step will be dropping JTA support at all.
I'm about to start a long-term project where I'll need to handle distributed transactions to work with two or more entitymanagers, and I'm doubt if using JTA would be a good choice, or if I'd better start
planning some other strategy to work with more than a single entitymanager - eventual consistency tipical of microservices ?

Any hint ?

3 weeks ago

Zachary Griggs wrote:A background in math and statistics will help as well; in many ways machine learning is more math than programming. And you can pretty easily pick up python along the way if you know any sort of programming.


Fully agree, except for one thing:a math background is essential, at least if you want to really understand ML. My advice is to read a good book where you can learn theory as well as practical examples .
I wonder if it's possible to run a licensed copy of Mac OS on VMware or similar VMs players, and, using it, to develop and distribute apps on Apple store. Reading here and there on the web, it seems that while it is technically possible, it would be  a license infringement  - you can run MacOS only on MacOS hardware.
Any advice ?
1 month ago

Tim Holloway wrote:
Of course, you can overdo the whole microservice thing. Breaking down apps into sand-granule size may simply complicate things and not save any resources at all. And while there is a certain advantange to making different parts of the app be "black boxes" to other parts of the app, you can also end up not understanding what anything is doing. So, as in all things, some planning is required. And the design should be flexible enough to change, since actual system use almost always show different requirements than what the planners originally envisioned.



Tim's 'warning' IMHO gets the point, and addresses one of the most critical aspects of Microservices, i.e careful planning and clear documentation about each service's responsability and interactions.
Also, beware that microservices aren't (as usual, in IT) a silver-bullet. They are great when you really need scalability and whenever you need to easily adapt your system to a quickly changing business enviroment - new protocols, new business flows and so on.
Personally, my biggest concern about Microservices is related to eventually consistency you need to adopt when working with microservices. For the kind of project I work on - essentialy, an ERP system - thinking of having several services, each with its own database (at least, in theory), and no real support for distributed transactions....well, don't let me think about it.....
2 months ago
Welcome ! This book looks really amazing, thanks for being here.

Peter Rooke wrote:I suspect the BeanFactoryPostProcessor interface is what your are looking for.  
Not sure why you would want to extend the actual framework itself, but it is possible.  



If the OP wants really to do this:

Instead of putting "@PostConstruct" and "@PreDestroy" annotation in all bean class,  l want more generic solution, which is  putting  "@PostConstruct" and "@PreDestroy" annotation in
"Configuration" class than expect to work this two methods for all bean classes.



then creating one's one BeanPostProcessorBean could be a good idea. I was thinking about using a class hierarchy - if you want to use the very same method for doing something, one should put in a single ancestor class the required code.
2 months ago

salih ayan wrote:hi Stephan  ...
What l am want to do ?
Instead of putting "@PostConstruct" and "@PreDestroy" annotation in all bean class,  l want more generic solution, which is  putting  "@PostConstruct" and "@PreDestroy" annotation in
"Configuration" class than expect to work this two methods for all bean classes.



That's not the way Spring beans' lifecycle works.
@PreDestroy and @PostConstruct are applied only to the methods annotated with them, within a specific class.

You may want to define a common ancestor class, with @PreDestroy and @PostConstruct annotated methods, and let your managed beans extend it.


2 months ago

Al Hobbs wrote:
Writing the server side in javascript because the frontend is also javascript doesn't really make sense.


With a bold name, such applications are called "isomorphic applications".
Honestly, I think that Tim's comment is correct: most of times, decision about which language to use for a project is driver by skill of already hired people.


Bruno Melloni wrote:
- Since all of the embedded Tomcat instances will use the same version, is it possible for them to share the Tomcat code even as they have independent memory spaces for the apps?  It seems wasteful to load so many copies of the same read-only thing.  Same thing for Java itself, it would be even crazier to have to include a separate copy of Java for each webapp.
- What is the best way to deploy?  Googling seems to point to using a container, and more specifically to deploy the embedded Tomcat Spring Boot apps on Docker.

- Is Docker included in the Windows Server license?  Googling seems to hint so... but it is not clear.


I apologize if these are truly noob questions but google did not help, if anything it added to the confusion as every tutorial seems to be lobbying to sell you a tool instead of helping you choose the best fit.

Also, if going the Spring Boot way is overkill... please say so.  Simpler is always better, if there is such a way.



Spring Boot aims to be a self-contained java application, with every dependency packaged into a single, fat jar file. Including Tomcat runtime as Web Application Server, or Jetty, if you tell Spring Boot to use it. Jetty should have a reduced memory footprint with respect to Tomcat, but there's no huge saving in term of memory. If you deploy your applications as standalone boot application, you'll end to have n Tomcat runtimes  running all together on your server. So, yes, IMHO your concerns are right, things may be even worse with respect to memory consumption. On the other hand, splitting a monolithic installation in several, separated standalone apps will bring undoubtly some advantages: there would be nothing like a "general crash" of all your apps, because each of them work separately.
When dealing with Spring Boot applications, Docker is definitely a way to go. It's quite simple to dockerize a spring boot application, and there are plenty of tutorials on the way teaching you  how to proceed. You won't save memory anyway - a containerized application requires the same memory as before.
With docker, anyway, it's really much more simple to manage your running application and to set-up them to automatically restart if any crashes.
About licenses: AFAIK, Docker community edition is free for use. Don't know anything about Enterprise edition, which I suppose will required a regulard, paid subscriptions.
But for a starter, using CE editoin should be enough.


2 months ago

Neil Barton wrote:Thanks Again Claude,
I found some code using the hikari library and got it working. Whilst implementing it I tidied up the DB access code and closed the leakage which became fairly obvious! The code now runs about 3 times as fast and that's before I try different numbers of connections to optimise it. Excellent, thanks!


Glad it helped !
Using a ConnectionPool is undoubtedly good idea, but not for the reasons you're talking about. If you run in a socket exhaustion, most likely you have severe connection leaks here or there in your code, and using a pool won't help.
A connection pool, indeed, should be used to save opening phisical connection time. If there are connection leaks, you'll  run out of available connections in the pool.
So, first check if in your code there are no leaks.
This said, I don't understand the requirement about not to use Eclipse or Maven. I guess you need a simple jar you need to add to your project's classpath, without using Maven.
If that's true, try with Hikary connection pool - just google for it, and you'll find a lot of examples.
Last, but not least, please remember that "general" connection pool libraries work together with specific DBMS driver. In your example, looks like you're trying to use UniversalConnectionPoolManager  with MySql driver.
UniversalConnectionPoolManager seems to be the specific datasource implementation for Oracle DBMS, not a generic wrapper like Hikary.
My humble advice: have a look at some examples on the web (hikary + mysql), grab the underlaying concepts, and then go further.
Java built-in serialization mechanism will serialize the whole object graph, skipping anything declared as transient.
Just serialize the arrayList of people: related hobbies instances will be serialized as well.
Anyway, remember that serialization isn't a reliable persistence mechanism: you must not use serialization to store persistent data; use DBMS (NO SQL or SQL based) instead.
3 months ago