could not initialize proxy - no Session - Production server only? - java

I know this issue has been beat to death and I have read up on all the various solutions such as adjusting the lazy fetching. The issue is that this application has been running for a couple years now and just recently started having this issue.
The strange part is this application works fine on my local dev machine as well as our testing server. Once I deploy this into our production site I get the error. So I don't believe its an application problem, it has to be something with the server, maybe some sort of tomcat configuration that might somehow be different?
The setups are the same between all 3 servers with versions of tomcat/mysql/java. Does anyone have ideas on what I can look at?
For what its working im running hibernate 3.5.3, Spring 3.02, Struts 2.2.1, Tomcat 6.0.24, Mysql 5.1.67 on a RHEL 6.3 Server
Thanks

I would explore 2 parallel paths to figuring out the answer.
One is, try to troubleshoot the problem itself. Crank up your log levels to DEBUG and see if that illuminates anything. Are you able to successfully fetch a simple object, and only complex objects (those that have a sub-object) cause a problem? etc. It may have to do with the data source / connection pool, which often has a different setup in production.
The 2nd approach is, figure out what has changed. If this problem just started happening, then something must have changed. Have you upgraded a library, changed versions of Tomcat, changed the OS, etc.
Related to this 2nd approach is figuring out what is different between your development/test environment and production. They can't be "the same" in every way if the problem occurs reliably in production but not the others. If you have a version of "production" that you can tinker with, without screwing with active users, then you can experiment with changes and see if you can isolate the specific thing that causes the problem to appear.

Related

Easy deployment of a jvm based web server on a remote machine

I wanted to know what is the easiest way to deploy a web server made using java or kotlin. With nodejs, I just keep all the server code on remote machine and edit it using the sshfs plugin for vscode. For jvm based servers, this doesn't appear as easy since intellij doesn't provide remote editing support. Is there a method for jvm based servers which allows quick iterative development cycle?
Do you have to keep your server code on remote machine? How about developing and testing it locally, and only when you want to test it on the actual deployment site, then deploy it?
I once tried to use SSH-FS with IntelliJ, and because of the way IntelliJ builds its cache, the performance was terrible. The caching was in progress, but after 15 minutes I gave up. And IntelliJ without its caching and smart hints would be close to a regular editor.
In my professional environment, I also use Unison from time to time: https://www.cis.upenn.edu/~bcpierce/unison/. I have it configured in a way to copy only code, not the generated sources. Most of the times it works pretty well, but it tends to have its quirks which can make you waste half a day on debugging it.
To sum up, I see such options:
Developing and testing locally, and avoiding frequent deployments to the remote machine.
VSCode with sshfs plugin, because why not, if it's enough for you for nodejs?
A synchronization tool like Unison.
Related answers regarding SSHFS from IntelliJ Support (several years old, but, I believe, still hold true):
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206592225-Indexing-on-a-project-hosted-via-SSHFS-makes-pycharm-unusable-disable-indexing-
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206599275-Working-directly-on-remote-project-via-ssh-
A professional deployment won't keep source code on the remote server, for several reasons:
It's less secure. If you can change your running application by editing source code and recompiling (or even if edits are deployed automatically), it's that much easier for an attacker to do the same.
It's less stable. What happens to users who try to access your application while you are editing source files or recompiling? At best, they get an error page; at worst, they could get a garbage response, or even a leak of customer data.
It's less testable. If you edit your source code and deploy immediately, how do you test to ensure that your application works? Throwing untested buggy code directly at your users is highly unprofessional.
It's less scalable. If you can keep your source code on the server, then by definition you only have one server. (Or, slightly better, a small number of servers that share a common filesystem.) But that's not very scalable: you're clearly hosted in only one geographic location and thus vulnerable to all kinds of single points of failure. A professional web-scale deployment will need to be geographically distributed and redundant at every level of the application.
If you want a "quick iterative development cycle" then the best way to do that is with a local development environment, which may involve a local VM (managed with something like Vagrant) or a local container (managed with something like Docker). VMs and containers both provide mechanisms to map a local directory containing your source code into the running application server.

Vaadin 7 - Good framework but not for my project [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Vaadin is a wonderful framework, It is very useful to develop colorful web apps. However, I'm totally frustrated by some unexpected things happening in it. I know it is hard to create such a framework where client and server side components can be coded at the same time. It saved me time.
But, I don't know why I'm getting communication error, session expired notification, app freezes sometimes in the server environment. However, Everything works perfectly fine in my local environment.
Can anyone please tell me why I'm facing these issues?
Problems:
Communication Problem? (http://dev.vaadin.com/ticket/8466)
Session expired message? (I set the session to expire after 300 minutes. But it happens before. But, not all the time)
App freezes sometimes. (I can click buttons, But no use.. No actions.. Only way is to restart)
Very bad performance in IE. (I know it is common for all web apps. But, my application when compared to other browser; IE totally sucks.
Lazy loading in treetable will be really helpful for me.
ICEPush add-on, doing its job perfectly. But, after sometime it is giving me exception in the console.(https://vaadin.com/forum#!/thread/234493/4528542)
If I do any action in a browser. It is reflected in another browser(another instance of the application. (http://dev.vaadin.com/ticket/10208)
Context menu add-on: Easy to implement and fantastic. but, gives me exception on multiple right clicks on a slow network.https://vaadin.com/forum#!/thread/119996/4455717
Annoying exception messages. what is the need to show it on the UI?
I already spent most of my time in forums. I really got good support from you guys. But, I don't want to.
I suspect the following things will be the reason for the above problems.
My Vaadin server is in UK and API server is in US, Is this a reason for the communication problem?
I build components from functions of a Util class. Is this the reason for the problem no 7 on my list. Like this,
ComponentsBuilder.buildVerticalLayout();
It's a lot of questions. I don't have answers, but have some insights for You.
I've developed one and seen three web applications developed in Vaadin 6. All failed, the reasons were varied, but I can share with you some of my humble insights:
Some Vaadin behaviors (at least 6.x) was hard to customize, e.g. session expiration.
Resulting HTML was extremely heavy and hard to customize also. Often it was impossible for my team to achieve the desired visual effect.
I found Vaadin's design quite poor (a lot of casting/ using Object instead of generics). Also source code is not high quality in my humble opinion.
Built-in widgets are sometimes hard to use due to bugs and lack of real-world examples.
Portability among browsers is a myth (especially IE, but You found out that already)
Simple Vaadin app can take up a lot of CPU resources
Keep in mind also that Vaadin used in wrong way (not in Single Page App) becomes a nightmare - but is not a fault of framework itself. The same applies to any other tool.
Vaadin 8 & 10
A lot has changed in the intervening years.
Communication Problem? (http://dev.vaadin.com/ticket/8466)
That ticket has been migrated to GitHub as Issue 2178. Now marked closed. Seems to be bugs in Tomcat and browsers, now fixed.
This is a bug caused by the cookie handling of certain browsers when using Tomcat 7 and no trailing slash is used in the address after the name of the app (i.e. http://host/app instead of http://host/app/).
You can fix this by setting the context attribute sessionCookiePathUsesTrailingSlash to false.
Session expired message? (I set the session to expire after 300 minutes. But it happens before. But, not all the time)
I have not tried this, and I am just guessing here, but it looks like we have a getter for the session expiration message displayed to user here, com.vaadin.server.SystemMessages class, methods getSessionExpiredCaption() & getSessionExpiredMessage().
The description for that SystemMessages class says:
Use VaadinService.setSystemMessagesProvider(SystemMessagesProvider) to customize.
So perhaps we can override the session-expired message by implementing the SystemMessagesProvider interface. (I am not sure how all this works.)
App freezes sometimes. (I can click buttons, But no use.. No actions.. Only way is to restart)
I do not know about this. I have found Vaadin 7 to be very stable in production, running for countless months at a time without failure. Vaadin 8 in my current development efforts also seems completely reliable.
The implementations of web browsers, web servers, Java Servlet containers such as Tomcat & Jetty, and so on have dramatically improved and evolved in recent years.
If the user’s web browser has lost contact with the Vaadin server, they should see a message displayed.
Very bad performance in IE. (I know it is common for all web apps. But, my application when compared to other browser; IE totally sucks. Someone please talk with gates to stop IE... :-(
Yes, indeed IE was a series of terrible browsers, with many problems.
Fortunately, someone did indeed talk to Gates/Ballmer/Nadella. The Internet Explorer product line has ended. Replaced with Microsoft Edge. A huge improvement. They seem to have a new spirit, and heartily endorse and follow web standards now.
See the CanIUse.com site to see which versions of what browsers support which features in HTML, CSS, etc.
Lazy loading in treetable will be really helpful for me.
The TreeTable widget is supplanted by TreeGrid in Vaadin 8. This new widget shares technology in the amazing new Grid widget.
See also the manual page on Hierarchical Data. It discusses lazy-loading data from your backend.
Here is an article on lazy-loading in Vaadin 8 by Alejandro Duarte.
ICEPush add-on, doing its job perfectly. But, after sometime it is giving me exception in the console.(https://vaadin.com/forum#!/thread/234493/4528542)
Push technology is now supported within Vaadin, as a built-in feature. Amazingly, basically all you need to do is add a #Push annotation to your app.
The Push implementation in Vaadin is based on the popular, robust, and well-proven library, Atmosphere.
See the manual page, Server Push.
Be aware that Push technology has improved dramatically in recent years, especially WebSocket. The new HTTP/2 standard furthers the advancement. Be sure to use the later versions of web containers such as Tomcat, and of Vaadin, and of the web browsers.
If I do any action in a browser. It is reflected in another browser(another instance of the application. (http://dev.vaadin.com/ticket/10208)
See update to that ticket. Seems to be a non-issue.
Looks like passing in the page like: new Notification(message).show(ui.getPage()) solves the problem…
Context menu add-on: Easy to implement and fantastic. but, gives me exception on multiple right clicks on a slow network. https://vaadin.com/forum#!/thread/119996/4455717
I cannot speak to this except to say:
There is much discussion on that thread.
That component has now been integrated as part of the Vaadin framework.
I suggest trying it again. (I have not used it.)
Annoying exception messages. what is the need to show it on the UI?
Not sure what you mean here.
If you refer to Java exceptions, I am not sure what else you would want to happen, if the app has errored-out for that user.
If you refer to session communication problems, you should know that recent versions of Vaadin try more aggressively to maintain and re-establish a problem connection.
I cannot find links at the moment, but it has been documented. Perhaps in their blog.
My Vaadin server is in UK and API server is in US, Is this a reason for the communication problem?
Of course maintaining sessions over the Internet can be problematic.
What I can tell you is that Vaadin has worked well for me with my server deployed in a colo in Wisconsin US and users running successfully from Florida, Seattle, Canada, and even Hong Kong using an app that uses Push to update displayed data every minute.
If your network is unreliable, then an actively “chatty” architecture such as Vaadin is not appropriate.

Messaging queue application

I´m told to develop a message queue like MSMQ for some apps, but it has to be written in Java so it's able to work on a Linux server. A co-worker tested openmq via glassfish but it's very slow, even having both apps on the same computer. It would delay each message for 1 second on a slow computer and .8 on a fast one, ive read his code and everything seems fine, delays seem to be caused by openmq glassfish functions(not his code).
Ive read a bunch of things that are related to the subject but i can´t find a library or something(ive seen zeromq,openmq and i dont know if they would suit because they seem to be oriented for managing and not providing the service). The only one i think suits my needs is MSMQ and i am not able to use it for the reasons i gave before.
In a couple of months it would be used to communicate at least 200 live applications
The main reason of this question is to try get a suggestion of what should i use or if someone had used openmq with glassfish and works cool and i should re ckeck that code to look for issues.
Have you tried ActiveMQ? Easy to set up and use and can handle a hell of lot of messages. We always use it with Spring's JMS templates for pain free messaging.
http://activemq.apache.org/

Stuck on a Spring performance issue

I am kind of stuck on an issue. I have a Spring + Hibernate app, which for the last few days has been behaving really strange.
Normally, even on Debug mode, it bootstrapped for around 15 seconds.
As of a couple of days, without any significant errors or problems being shown, it started running twice, if not three times as slowly.
I thought maybe the problem was in Tomcat, but even when I ran the series of unit tests which I've written, they went amazingly slow (we are talking 8+ sec on a test + 20sec for the initial context bootstrapping). I use a local PostgreSQL database for the tests which is normally not so bad (around one second on a test)
I am stuck. I know that the last thing I did was to add support for #Transactional on my #Controller classes. Could this be the reason? I doubt, because when I deployed the transactional modifications to the stable server and restarted it, it ran just as fast as before.
I am completely stuck
You are aware that based on your description we can only guess. Obviously if you are using continuous-integration, build times of subsequent builds will reveal which code change could be the reason. If you identify the code, diagnosing will be much simpler.
Chances are it wasn't really caused by code change but by the environment change. E.g.:
Spring fetches some external resource on bootstrap (XML schemas, DTDs, etc.)
there is some extra network overhead (router/switch reconfiguration, firewall)
Database is fragmented or somehow slow. Try vacuuming
Investigating:
Capture few stack traces during bootstrap. No need for full-blown profiling, I bet there is a single blocking/waiting operation slowing things down
Enable every logging statement you can. Every. Investigate which pieces of your application are slow.
My guess is that your DB is the root cause for this.
Probably you have some query that is taking longer than it used to due to data size growth, schema changes, or the like.
Here are some tips:
Try to check the startup logs to see what seems to be slower.
Can you try to start an older version of the app, and see if it's faster?
Can you see which tests are slower now?
Maybe profiling will help you to gain more information. There is a nice tool which comes shipped with JDK called jvisualvm (you can find it within the bin folder of your jdk installation). It's pretty much self explanory. You can connect to you applciation and start sampeling.

Using HSQLDB in production environments

I want to use HSQLDB in a production environment for stroring some data in memory and for data export using files. Does anybody have experience with using hsqldb in production environments? Is hsqldb treating server resources gracefully and does it cleanup unused resources properly?
I've seen a critical post on those issues from red hat and I'm wondering whether this still holds for hsqldb:
http://kbase.redhat.com/faq/docs/DOC-15194
I've used hsql on numerous occasions in production (mainly as quick filebased storage for complex preferences) and never encountered any problems.
Don't know about HSQLDB but we've been using H2 on same purposes with no problems at all.
I can confirm some of the issues listed on the Red Hat page.
We have had issues using HSQLDB as a standalone instance in a Tomcat container. The application would not shutdown properly and hang at 100% cpu. There was a code fix, though.
We have also had issues were some data was lost after the server was forcibly killed. I could not reliably reproduce the situations.
I also have some strangeness that I cannot start multiple instances of the same application using HSQLDB at the same time.
You need to evaluate the if a standalone, in-memory DB is the right choice. If consistency and integrity is essential, HSQLDB may not be the right choice.
We experienced database corruption (entire database was lost) a few times times over a year using HSQLDB when it was not shut down cleanly.

Categories