Stopping a web application during JBoss startup, when fatal error encountered - destroy

In one of the applications that is in development, we have a home-grown cache manager that is a spring bean. It's init method gets called when this web application starts up in JBoss (EAP 6.0 to be specific).
As the application is still in development, there are cases when a developer starts the application that certain database master data tables that are mentioned to be cached are not available in the developer's db instance by mistake.
Is there a way to stop the web application, when a irrecoverable exception is encountered in such cases, so that the application is not up?

Related

Having RESTful service in RCP application

We have an existing eclipse RCP application that works as a standalone product. At a high level, this product is used to configure a image specification using its UI and we can export a sample Image based on these configuration.
Now we are developing another web application that has several modules and one module of it is to develop something that our eclipse RCP application does.
Just to provide a QUICK integration of the RCP application for demo purpose, I plan to run the RCP application separately in the server machine and expose its static functionality as a RESTful webservice. So the module shall make a RESTful call to the RCP application.
Now just to begin with I tried to embed a jetty server for hosting the REST service during the start of RCP application like below
But the thing is after the Jetty server is started I am not able to access the TestWebService using the path i configured. So I am confused if this is the right approach to have a RESTful service inside a RCP application. Please note that iam able to hit the server with http://localhost:1002, but not the service.
Following is the console log when i hit on http://localhost:1002/hello/test:
It's a really weird architecture you're experimenting with.
I mean to write an RCP-application which listens on a port and offers REST services on it; this could lead to further obstacles.
Instead I would seperate it into two software artifacts: an RCP-app and a web-application (.war).
You could extract a business-logic jar (It can be an OSGi plug-in if necessary) contaning your image manipulation logic.
Then include this plug-in/.jar as a dependency in the webapp and offer out it's functionalities thru a Web-container (Tomcat, GlassFish, etc.)
So your other (third) application will connect to the Web-services offered by this .war file.
opt.1) If you need a single running instance (because of database or other shared resource) then your RCP-app will have to use this REST service too.
opt.2) If not then simple compile the .jar/plug-in containing the business-logic into your RCP-app.

Bitness confusion

We are migrating a sharepoint farm from a traditional DC to a private cloud.
One of the forms in a site is calling some web services, both the sharepoint site and Web Service application are housed by the same IIS server. Sharepoint site and the Web Services application are having different application pool.
After migrating, one of the forms that is calling some Web Services is throwing an error about: data connection error. Looking at the sharepoint logs, we found that there is http error 500 when hitting the form's URL and that we realized that hitting the WSDL from the browser is throwing the same error too.
The error in WSDL is about: Could not load file or assembly <...> or one of its dependencies. This error is gone if we set the application pool settings to Enable 32 bit = true.
However, the rendering of form is not completed because setting the WSDL application pool to 32 bit is causing to throw a FileNotFoundException with stack trace:
at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at ...
We are sure that the cause of the problem here is the binary "bitness" because we are able to simulate the above exception and able to resolve in the other forms by just setting back the 32bit option to false in application pool.
We would like to seek anyone's idea on how to resolve the issue. Unfortunately, we only have the DLL of the Web Service, it will take for us a while to get some source codes so we are hoping for some solution that requires no re-compilation. Also, the source code that we are to receive is not guaranteed to produce the same DLL that is deployed to production due to the age of this legacy system turned blackbox.
For more information on the versions of softwares used:
IIS, source: IIS 6; destination: IIS 7.5
Sharepoint: 2007 (yes unfortunately due to alot of reasons upgrade cannot be done just yet) - source and destination are of the same version
OS: Windows Server 2008 R2 - source and destination are of the same version

Have web app do tasks when it is not opened by a user

I'm a semi-experienced developer but a total noob to writing web apps. My question is: would it be possible to have a web app perform some sort of task while it is not opened by any user? For my purposes, I want it to send out text messages to users based on provided phone numbers, but this task must perform when the app is not opened by the user. At a high level, how exactly would I go about doing this? Thanks.
At a high level: The web server on which the application is being hosted will need to run, regardless of user activity. Therefore, it is plausible to also run either a service or scheduled job from this server, or to host a separate application that runs at a fixed interval. That is the high level answer at least :)
The short answer is no, and yes. Depends on your definition of "web server".
If you're talking about the service (e.g. Apache) then no. If you're just talking about the server that your web server is on then yes.
Basically you will need a companion app that runs as a service on the parent OS. It can be written in a language of your choice. The key is in getting your web app and companion app communicating.
The simplest way is to have your web app and companion app use a shared database like MySQL or Mongo. If you need real time communication between your app's users and the companion app you may want to investigate using a messaging service like RabbitMQ or ActiveMQ.
It should be easily possible, but it depends on your environment.
As Example:
When using Java/[Tomcat/Jetty/or whatever] you could create an Servlet which is automatically loaded when your "App" is being loaded.
You can put your "tasks-code" into this servlets init-Method.
Edit:
in web.xml you can configure, which of your servlets should be automatically loaded.

Compile JSP & Java on browser refresh - Tomcat

Is there any way to setup Tomcat server so whenever I make changes to Java class or JSP page the change is visible on browser refresh.
I'm bored stopping and starting Tomcat. I want to configure Tomcat like the way WAMP works [where you can see the PHP code change upon browser refresh]
If it's for development mode that's ok. Don't use it for production stuff.
You don't have to restart the server. You can restart the app through the Tomcat Manager.
You can even do this directly as: http://[hostname]:[port]/manager/reload?path=[/path/to/your/webapp]
or
Define your context as reloadable
Be careful: It is NOT recommended to place elements directly in the server.xml file
Check out the Tomcat configuration guide
For java classes: reloadable
Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.
NOTE - The value for this property will be inherited from the reloadable attribute you set on the surrounding Context component, and any value you explicitly set here will be replaced.
(http://tomcat.apache.org/tomcat-7.0-doc/config/loader.html)
For JSP: development ($CATALINA_BASE/conf/web.xml)
development - Is Jasper used in development mode? If true, the frequency at which JSPs are checked for modification may be specified via the modificationTestInterval parameter.true or false, default true.
Hope this helps

Deploy .asmx (not WCF) web service on windows 7

I need to deploy an old style .asmx asp.net web service (not WCF) on a windows 7 machine for test reasons. However it seems that just deploying it on a virtual directory or new web site on IIS won't cut like it used to back in xp.
What should I do? I need to test the service locally prior to deploying it, and so far it's giving me a hard time.
Any help will be greatly appreciated
Thanks
Deploying to a Virtual Directory should work just like it did in XP...with one minor change.
The default behavior in IIS7 is to use 'Integrated' Managed Pipeline Mode for your Application Pools. More than likely, you just need to change that to 'Classic' Managed Pipeline Mode (or switch your Web Service over to use the built-in 'Classic ASP.NET' App Pool).