java.lang.ClassNotFoundException in specific folder - linux

A few months ago, I was making changes to this web application for a client. It's a JSP web application with tomcat as the web server. I've made the changes, tested it (of course), and left the application to the client's hands. They have come back to me and mentioned that a specific area of the website is not working. I go in and check the area, indeed it wasn't working but it was working a few months ago when I made the changes.
The issue encountering a very unusual. Every page in the directory in question (/tomcat/webapps/website/english/login) throws a java.lang.ClassNotFoundException.
To troubleshoot the issue, I've tried creating a blank JSP with "hello world" and no coding and still throws a java.lang.ClassNotFoundException. I create the same JSP page outside of this directory and it is fine
Steps taken to replicate this issue:
I enter into the directory in question (tomcat/webapps/website/english/login)
Create a JSP page called test.jsp that literally has "hello world" only (no coding)
On the browser, I navigate to test.jsp. It throws a java.lang.ClassNotFoundException
I enter into the directory one up from login (tomcat/webapps/website/english)
Create a JSP page called test2.jsp that literally has "hello world" only (no coding)
On the browser, I navigate to the test2.jsp page. It works
I've done other test but could not find the issue. See below for some methods performed
Moved the web application into a different directory (tomcat/webapps/website2). Everything, including the /english/login directory, works
Deleted the web application directory and recreated the directory path, still giving me the exception
Checked permissions. The directory in question has the same permissions as everything else in the web application (including the files)
With the results from the tests, I believe the issue is the directory itself (/tomcat/webapps/english/login). Everytime I move the directory, everything works.
Mind you that I was making changes to the web application using a text editor (notepad++) not on eclipse, building the application using TeamCity (which compiled fine), the server runs under linux and I have no access to the build script but I believe ANT is used as the builder
So my question is, what is causing this issue? To have all the files in a specific directory to look for a class?
Any clues/help is much appreciated. I've been working on this problem for a few days. It's mind boggling
Cheers!

I would check the class path being used with PS -ef and look for the process. The error logs should point to a specific class. Those two clues can help determine if is config or war issue.
A possibility that I have seen is that in a tomcat config file, the paths allowed are explicitly defined. Also, a config file could map a specific path to a java class.

Found the answer to my own problem. The issue originates in Tomcat. The web server converts the JSP file into a .java file then compiles it. For some odd reason, Tomcat was not doing this for all my files in a specific folder.
Solution is to go into Tomcat's work folder, drill down until you see your webapp's name and delete the folder. This will force Tomcat to rebuild all the visited pages.
A safer way (which didn't work for me. Did not delete the webapp in the work folder) is to log into Tomcat and undeploy the webapp all together. This should delete the webapp folder in the work folder of tomcat.
Hope this helps for those experiencing similar issues

Related

Kentico getresource 404 error css and js

Using Kentico 9, while I was away it appeared that something changed! While our production site appears to be working fine our staging site is not. When I try to access the staging site it is unable to "find" any of the related CSS or JS files and therefore displays the site without any of those files. Another part of the problem is that the same thing is happening in the admin portal and since the admin portal relies on those CSS and JS files to work I can't troubleshoot there.
When I try to get to the resource directly in a browser: e.g. iddba-staging.azurewebsites.net/CMSPages/GetResource.ashx?stylesheetfile=/App_Themes/Default/bootstrap.css it fails.
When I try to access it directly at the prod site: www.iddba.org/CMSPages/GetResource.ashx?stylesheetfile=/App_Themes/Default/bootstrap.css as I would expect it provides me the opportunity to save the file.
Our site(s) are hosted in Azure.
Any idea of where to turn next? Thanks.
Also on a possibly unrelated note, I have also noticed an error in the logs on staging that is not on prod:
.NET Runtime version 4.0.30319.0 - Loading profiler failed. Failed trying to receive from out of process a request to attach a profiler.
Not sure if this might be related. Thanks.
Once I realized that getresource.aspx was a dynamic file and the css and js files were either already in the database or were in respective directories it looked at the dlls that power Kentico. In this case I decided to see if there were any differences in the bin directories of prod and staging. I don't know how they became out of sync but they had. Since the problems I had appeared to be serving up CSS files I noted that one file CMS.LessCss.dll was in prod and not in staging so I copied that file in. As soon as that file was copied Kentico threw an error with the word Jurassic in it (odd!). I found a file Jurassic.dll that was in Prod and not in Staging so I moved it.
Voila! The site was back, serving CSS and JS files on the front end and in administration. We are still clicking through all our pages to see if anything else is not working but for now we are good and if I have any further questions I will look in bin first since there are still files that live in prod that are not in staging and I don't want to re-populate unnecessary files. I am just not sure how the directories got out of sync in the first place... or at least no one here has admitted to having messed around! Yet.
Thanks for all your help.

Liferay: war getting copied at deployment, disappearing, but no app

I am working through the example in the Liferay documentation; I have created and built the little greeting applet and gotten no errors at compile or build. I don't get any errors at deployment, either, but the application is showing up.
The deployment says it is copying my war file to portal-dir/deploy. I have determined that I can copy the war file there, though something (I guess in the server) removes it after a few seconds. But when I go to look at it in a browser off my local server, it is not there.
Does anyone know what I should look at to fix this?
No need to fix anything here -this is how autodeployment works. Web archives found in deploy directory are removed from there, extracted, processed by Liferay and in the end you should be able to find them in ${catalina.home}\webapps (assuming that you're using a Tomcat bundle).

.htaccess Rewriting Tomcat Server

I am writing a website using Railo. My code is to be deployed on a Railo Server running on Tomcat, overlayed on a regular Apache+PHP server.
I need to send all requests to http://subdomain.myserver.co.uk/ and its child files to the directory /public_html/railo/tomcat/webapps/ROOT/subdomain/ directory.
I defined a subdomain in cPanel, with the document root as /public_html/railo/tomcat/webapps/ROOT/subdomain/, but still requests to http://subdomain.myserver.co.uk/ display files in /public_html/railo/tomcat/webapps/ROOT/. I can view my files if I request http://subdomain.myserver.co.uk/subdomain/
I've been fiddling with the .htaccess files for quite some time now, but I'm stuck
Is there any way I can do what I'm trying to achieve, or am I resigned to get those pages using http://subdomain.myserver.co.uk/subdomain/
The Railo documentation on adding a site to a Railo/Tomcat/Apache/Linux install is here:
http://wiki.getrailo.org/wiki/Installation:InstallerDocumentation:LinAddingSites
I would also personally recommend against putting your site files in ROOT/sitedir/ because the ROOT directory is already configured for localhost, and making a subdirectory into another site will cause overlapping host configs in the WEB-INF directories.
Instead, just use whatever the default is for your control panel, and update your Tomcat server.xml file to point to the directory that your control panel naturally puts sites in. This will make your Railo site and your control panel work very smoothly together.
Hope this helps!
If you want your tomcat application to serve at example.com and not at example.com/application then you need to deploy your application at /ROOT and not at /application. This will make it the "default web application" so it'll be able to serve directly from example.com.
Have a look at: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
Cherouvim's answer didn't work for me. Eventually I ended up putting my entire application in the ROOT directory

How to setup IIS 7 using physical path directing to DropBox?

I'm using multiple computers for development and I want to be able to store my files in my dropbox folder. I went to change the physical path in IIS from c:\inetpup\wwwroot to the dropbox folder but I get this error:
The requested page cannot be accessed
because the related configuration data
for the page is invalid.
I couldn't find the config file so I was wondering if anyone had done this before or whether there a better way to sync everything nicely across several PCs?
I tried it (IIS 7.5, Win 7) and it should work just fine to let your physical path of your web look at your dropfox folder. I would guess your web.config file generally contains malformed XML (see KB942055).
I'd suggest, try to map it to an empty folder just with an index.html file and see if this error still occurs.
As a workaround, I guess you can put Dropbox in your wwwroot folder and set up a virtual directory that points to Dropbox. However, there are some security issues that may hinder you from doing so. I come across a nice tutorial on how to set up Dropbox to IIS as FTP Publishing. Hope it helps.
Hodgin's guide on using Dropbox as FTP publishing.

Where is MVC3's App_Code folder

This post contains a nicely succinct explanation for implementing razor helpers. But it refers to the use of the 'App_Code' folder - something i can't get my MVC3-transitioned-from-MVC2 project to create. I understand this has to do with WebSite vs. Web App but to be honest - i can't remember if the original creation was site or app. Since there's menu selection 'Convert to Web Application' seems it was created as a Web Site. But then there should be a App_Code dir, yes?
Attempting to recreate the steps from the original post (within a manually created 'App_Code' folder) presents pre-compile errors (MyHelpers does not exist in this context) - but the strategy _does work. - at least the simple hello stuff did. so i shouldn't argue with success? MVC3/Razor isn't fully intellisensed yet?
thx
I created an app_code directory by just creating a folder called app_code. MVC3 dealt with this file correctly by creating static methods for the code I put in there. When I reopened my solution later, the app_code file had disappeared. I eventually found that the app_code file was marked as a hidden folder by visual studio.
In this virtual machine I have the RTM VS 2010. not sure if this was fixed in SP1.

Resources