Khosrow Moossavi

Greenhorn
+ Follow
since Aug 08, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Khosrow Moossavi

Hello Ranchers,

I've developed a web site using Struts2 as a controller and integrated it with Spring and Hibernate to do the business logic and DB stuff. The website's URIs are http://my.domian.com/{URI}; which {URI} is dynamically generated thorough the admin cms. The mapping of each uri to the servlet are done with help of Apache mod_rewrite, as follow:


(Before any further information, is this a good and suitable approach?)

The struts configuration is just a typically-academic one as:


DynamicContentAction is extending ActionSupport and implementing ServletRequestAware, ServletContextAware. I'm checking a couple of things (such as a current visiting language which is identified as a subdomain), looking up in the database that the requested uri is valid or not, generating that uri's content and setting a couple of runtime global variables (such as current visiting page id, layout config due to current visiting language ...) and put it on a Request object in this servlet.

Everything looks good and even works perfectly ok, unless too many dynamic pages being requested by a single user concurrently. "Too Many" in my case is at least 9-10 pages. In this case it throws exceptions, different ones! Sometimes the HttpServletRequest request is null, sometimes ServletContext servletContext is null, some other times these are ok, but the runtime variables are null which is used in business logic or db querying.

I've googled about it and found out that this action is being instanciated "Per Request". Isn't this so? If there is an action per request, what's wrong with this conflict or "nullability thing". Should I do some thread-like thing in that action, beyond the threading of struts?

I'd be so appreciated if you could help me out or point me a direction.

Regards.
Khosrow
13 years ago
Thank you guys for your answers.

Well I have not considering monitoring that much, because we were good both in Development and Deployment environment. But after this, I've installed Java-monitor and here is the Result about Heap, PermGen and GC:


java.lang:type=MemoryPool, name=PS Perm Gen
    Usage.used: 107 MiB and 588 KiB
    Usage.committed: 114 MiB and 256 KiB
    Usage.max: 128 MiB


java.lang:type=Memory
    NonHeapMemoryUsage.committed: 120 MiB and 384 KiB
    HeapMemoryUsage.used: 87 MiB and 667 KiB
    ObjectPendingFinalizationCount: 0
    NonHeapMemoryUsage.used: 113 MiB and 119 KiB
    NonHeapMemoryUsage.max: 176 MiB
    HeapMemoryUsage.max: 113 MiB and 832 KiB
    HeapMemoryUsage.committed: 109 MiB and 512 KiB


java.lang:type=GarbageCollector,name=PS MarkSweep
    CollectionCount: 4
    CollectionTime: 1 second and 426 milliseconds


java.lang:type=GarbageCollector,name=PS Scavenge
    CollectionCount: 77
    CollectionTime: 652 milliseconds +5


Well, to be honest I didn't google for these terms yet. But are we good or anything seems not working all right?
What Monitor Application should I use? There are plenty out there and I couldn't decide what is good, so I went for the one that is on Kees Jan's signature.

Regards,
Khosrow.
13 years ago
Hello Guys,

We're currently having a Private Tomcat (version 6.0.16) hosting package, which gives us plenty of control over server, tomcat. So basically we're happy. But after deploying almost each and every new Java Application to Tomcat, we have to purchase more Heap size, which is ok and reasonable on the other hand.

The question is How much Heap Memory Size per application we need? I know that the more, the better, but what is the minimum of it?
Applications are generally a typical struts/spring/hibernate integration. The current is 32 MB starting, 128 MB maximum, and 4 applications work perfectly fine, but for recently deployed 5th and 6th, sweet little PermGen is there, slap me in the face!

If there are more things I should tell in order for "an" answer or a better one, please tell me to find that out. I don't think of anything else right now.

Regards,
Khosrow.
13 years ago
Thanks for your response Ankit. I've managed it someway, with my piece of code, but I should look up Convention Plugin as well.
By the way, It's great, specially the words in the brackets!!
14 years ago
Hello Ranchers,

I've just faced something weird and couldn't find anything useful regarding to it after some googling.
I'm using Struts 2.1.6, Spring 2.5, Hibernate 3.0.

The struts.xml


Every URI works perfectly ok such as
  • http://www.mydomian.com/
  • http://www.mydomian.com/about
  • http://www.mydomian.com/advertise


  • as well as these URIs(!):
  • http://www.mydomian.com/foo/about
  • http://www.mydomian.com/bar/advertise
  • http://www.mydomian.com/foo/bar/advertise/about
  • http://www.mydomian.com/every/signle/thing/you/could/imagine/about
  • ...


  • They are all working as long as the last one is correct and being in the struts.xml file.
    My question is, Am I missing something, somewhere in my code? Or is this just a known bug of struts 2?

    I'm apologizing beforehand if the question is basic or something!

    Regards,
    Khosrow
    14 years ago
    Hi Praveen,

    Well, I doubted that the problem is because of missing file in classpath or even the wrong path. But anyhow, I double checked it, and I was correct.
    UtilTimerStack.class is defined in xwork-core-2.1.5.jar, and it's available in WEB-INF/lib.
    By the way, everything is working like a clock in our development workspace. The problem is out there when it's deployed!

    Anything else.
    Please?
    14 years ago
    Hello guys,
    I'm not so sure if my issue is Struts-Related, so, I'm sorry about that. Anyhow here is my proplem.

    We've redeploying a web site , which is based on Struts2, Spring 2.5, and Hibrnate 3, and everything deployed completely and ok, bu I'm constantly getting this Error:


    I should mention that in our developing area everything is ok, but this exception is happening when we deployed it on the internet.
    I'd be appreciate if anyone could help me on this.

    Sorry about that my question is so short and might be too complicated. That's because I've googled a lot, but couldn't find any good clue to start with!

    Reagrds,
    Khosrow.
    14 years ago
    I don't want more than One Request or Response neither. I want the functionality as doing hardcoding all the program in the JSP page and using response.flush() whenever we want the buffer up to that point sent to browser.

    Is the content readable and indexable by search engines If we use AJAX?
    14 years ago
    Hello Ranchers,

    We've developed Java application using Struts 2 as presentation Layer, Spring as Service Layer and Hibernate as Persistence Layer.
    The Page Structure is like this:




    Everything is working fine. When a link on a website is clicked the previous page stands still while:
    1) Request goes to server
    2) Corresponding action class found
    3) execute() called
    4) Service called
    5) Corresponding method called
    6) Querying database using Hibernate completed
    7) List<> of Objects generated
    8) Returning SUCCESS
    9) Finding corresponding JSP page
    10) Rendering JSP Page

    And The rendered JSP Page is shown at once. As I've said everything is ok. But we're wanting the New Page (at least some elements Like Header of the Page) is starting to be generated and shown, while we're Fetching data from database.

    Is this Possible in anyway except using AJAX?
    If we're using Javascript to display Page elements (Header, Navigation bar, Menu, Content, Footer) sequential what would be the effect on SEO Ranking?
    Is using Javascript a good approach for this when the Searchability of Content by SEs is very important to us?

    I'd really appreciate if anyone could help me out.

    Regards,
    Khosrow
    14 years ago
    Hello Ranchers,

    I've recently start to learn and integrate Spring and Hibernate to my Java web app (Struts2 as a presentation). I've googled a lot about tutorial and examples and so on. Well, everything seems ok and running based on the materials I've collected. but as long as I've deployed it on a hosting web server and got a Lot of Runtime java.lang.OutOfMemoryError exception, I wanted to clear things up to myself that everything I'm doing is correct as point of view of an expert, then assuming there are some issues about my Webserver Hosting or something else.
    So here the Code:

    web.xml


    struts.xml


    applicationContext-hibernate.xml


    spring-hibernate-actions.xml


    spring-hibernate-services.xml


    spring-hibernate-daos.xml


    FirstAction.java



    FirstServiceImpl.java


    FirstDAOImpl.java


    I'd really appreciate if anyone could help me whether I was on a right path or something seems wrong or Exception-Throwing-Material on the above application development.

    Regards,
    Khosrow.
    14 years ago
    Hello Tim,

    Thanks for the reply. The application structure is like this:

    applicationContext-hibernate.xml


    spring-hibernate-actions.xml


    spring-hibernate-services.xml


    spring-hibernate-daos.xml


    FirstDAOImpl.java


    Is this a correct way? or even an accurate one? Should I close something that I'm not aware of right now?
    And by the way, what did you mean by "bypass Apache and access the app directly through Tomcat ". How can I do that?

    Regards,
    Khosrow.
    14 years ago
    I've recently deployed a java application to an shared Apache / Tomcat server with MySQL as a backend database.
    It's a UNIX server.
    Tomcat version is 5.5
    It uses mod_jk:


    The Application is structured with: Struts2 with Spring and Hibernate integration.

    Whenever I try to open a page
    1) it takes too long (2-3 minutes!) to open a single page (even the most static ones, I mean even the page which is just a Struts Action execute without anything else)

    2) The page stops working with following error appear on the browser screen:


    The frequency of happening of the second thing is something like 90%!

    I could only access catalina.out and there were not anything related to the runtime error or exception. In access.log the response code, almost everytime, was 200 but it wasn't corresponded to the browsing situation.

    I even tested the site in Lynx as well, which the same thing was occured there as well.

    I've searched about the above error and had not come to any resolution.
    I'd really appreciate if anyone could help me find out what's going on!

    Regards,
    Khosrow.
    14 years ago
    Rene :

    You can create a new HOST entry in TOMCAT_HOME/conf/server.xml



    Well, I don't have access to TOMCAT_HOME/conf/server.xml. It's a shared hosting. BTW, Isn't this configuration only working for Local Websites?


    Bill :

    Exactly what did you do and what happens? "not working" is not very informative.



    Sorry for not being so informative. I had the domain, and just purchased the hosting. It's a shared Hosting Plan which is a Windows-Based Server with IIS and Tomcat Module. Hosting Control Panel Plesk 8.4.

    When I depoly the myApp.war (which is valid. works fine on my computer) the site would be accessible through this url : http://www.mysite.com/myApp/ (works ok too!)
    but I want the site would be accessible through this url : http://www.mysite.com/

    So I've tried to rename the war file to ROOT.war (which should be deployed to TOMCAT_HOME/webapps/ROOT/ (Isn't it?) ) in order to get this done. But it's neither loading the myApp nor responding any HTTP's Error Page or Tomcat's Error Page. Just a Blank Page.

    I'm currently don't have access to Tomcat's Log too, so I can't see Stack Trace or something.
    15 years ago