Properties file changes are not reflecting unless restarting Glassfish server - java

I am using JSF2.0 and Glassfish v3.
I have a ValidatorMessage.properties file under WEB-INF>Classes folder of my project.
When I make any changes to messages in this file, through my project, its changes are not reflected.
I access this messages through <f:loadBundle var="msg" basename="ValidationMessages"/>
Are there any configurations to be made in Glassfish or my project side?
P.S.-> the same functionality works under Jetty 7.0.0pre3
Please comment if question is not clear..

There is no need to restart the server when you make change in a properties file.
I often do changes in my files for internationalization and i don't need to restart.
I don't know what IDE do you use, but i use eclipse and there i have an option when i double click on Glassfish application server to automatically publish when changes are detected(See image below). I think that is what you are looking for.
Also there is a podcast from oracle that mentions it(time 2.04)
http://www.youtube.com/watch?v=ppGqtOeHm-g&feature=related

Related

Why I need to restart Tomcat Apache server every time I change/edit my java servlet code

I am coding my basic servlet programs in notepad but every time I make changes in my java file and after compiling it, I need to restart my tomcat apache to see that changes on browser. Is there any solution for this as I have to work on project and will need changes frequently.
I have tried making service automatic from services manager.
The changes made in Servlet/Java code will not reflect itself, we have to re-compile the Java code and again deploy the application to the Tomcat server. Only after these work server will be able to get the modified values.
If you don't want to do it manually then you can set reloadable="true" in the context.xml file. Now Catalina (tomcat server) will 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. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.

How do I make modification in java class hosted on a tomcat server faster?

I have a java codebase in form a war hosted on Apache tomcat server(Production server). Now let us say i make changes in my class and i want the same to reflect on my hosted codebase. Do i have to re-start the server every time after updating the class, or is there some better way to do it
You can use auto-deploy feature of tomcat. Read the documentation here.
If it is a development testing server, you can enable debugging, and reload your changed classes without having to restart the server or redeploying your webapp.
You can enable debugging by setting the following and restarting tomcat. (you can use a desired port):
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787
In your IDE, create a debug configuration specifying server ip and the debug port you specified.
After connecting debugger, your IDE will usually prompt you to reload changed classes whenever you compile a class.
There is also a menu item also if you want to manually reload changed classes. Once you reload classes, your changes will be immediately effective.

How to use Eclipse for Spring REST development with Brackets like editor for JavaScript/front end development?

We have two separate web projects for our application
One for Spring REST services
Other for AngularJS, the front end of the application.
We have been using eclipse for development of both and also for running those locally on tomcat server.
It is a great deal of pain to view updates to JavaScript and CSS part of the second project from eclipse, because it requires restart or publish of the tomcat server every time which takes a long time.
So I wanted to use eclipse for development of REST and front-end development editor like Brackets for development of AngularJS/JavaScript and CSS. But then they run on different ports causing Cross Site requests errors, and I don't want to write any CORS filter like this for this purpose.
Is there any better way to get these tools work together ?
Spring Tool Suite (STS) uses the pivotal tc server will automatically deploy resources without redeploying the application. Download it and give it a go, STS is just eclipse anyway with different branding. Maybe you can just download it, copy the pivotal server folder to your eclipse folder and add it to your servers view in your eclipse version. One thing I have noticed is that the application must be running under a context for this to work, deploying to root does not automatically deploy resources for some reason (at least this was the case when I was using the previous vfabric server about a year ago).

Deploy Java EE Project in Weblogic

I have WebLogic installed in my computer. I already added it as a server in my Eclipse IDE. How do I configure my Web application to run or for it to be deployed on the WebLogic server. I found a sample project and found a weblogic.xml in it. Where do I start? Do I need to add something, etc.
If your web application is already a "Dynamic Web Application", then you should be able to deploy it just by right clicking on it, then Run As > Run on Server and choose the WebLogic Server runtime.
If this doesn't work, maybe you need to add the right facet to your project. Right click on your project and go to Properties > Project Facets and check that Dynamic Web Module is checked.
If this still doesn't work, maybe recreate a "Dynamic Web Application" from scratch and move (or copy) your sources to this newly created project.
Many tutorials are actually available at the WTP Community Resources page. See for example Using the Eclipse Web Tools Platform with Apache Tomcat. It is not specific to WebLogic but if you already have it setup in Eclipse, it should be easy to adapt the specific parts.
PS: It's hard to say anything about your sample project and the weblogic.xml as you didn't provide any detail about them. Maybe try to follow the advices above and, if you still have problems, update your question with more information.
There are a number of resources on using Eclipse with WebLogic, including Oracl'es Enterprise Pack for Eclipse. It's hard to tell without more information, but you need a WebLogic Domain configured with at least an Admin Server to deploy the web application to. When doing local development, it's acceptable to deploy applications to the Admin Server, but beyond this you typically want an Admin Server and a managed server where the application will get deployed to.
Here's some info on Eclipse and WebLogic - http://www.oracle.com/technetwork/developer-tools/eclipse/learnmore/index.html
Question is missing much details. You can find some detailed help here
http://download-llnw.oracle.com/docs/cd/E13222_01/wls/docs90/deployment/index.html

Should I implement source control for j2ee application server configuration files?

For a typical J2EE web application, the datasource connection settings are stored as part of the application server configuration.
Is there a way to version control these configuration details? I want more control on the datasource and other application server config changes.
What is the standard practice for doing this?
Tracking configuration changes to your application server through version control is a good thing to ask for. However, It does imply that all changes are done via scripting, instead of the administrative web interface. I recommend
http://www.ibm.com/developerworks/java/library/j-ap01139/index.html?ca=drs-
as a good background information article on this topic.
Update: Just recently, part 2 has been published here: http://www.ibm.com/developerworks/java/library/j-ap02109/index.html?ca=drs-
When working with WebSphere we found the best approach was to script the deployment and place the script under version control plus the response files for each of the target environments.
Websphere canbe tricky as the directory structure is a mess of files - often there appears to be duplicates and it's hard to figure which is the magic file you need to backup / restore . The question of how to go about this should not detract from the need to do it. - which is a definite yes.
Our (Spring) apps have a hardcoded jndi name in the spring config file. That way, the same ear can be deployed to dev, qa and prod environments, and you don't have to worry about database connection details.
The app server admins ensure that a datasource is registered against that jndi name, with the connection details as appropriate on each environment.
But how does this let me manage changes to datasource configurations in the application servers. Here's a scenario:
DBAs change the connection password of the database server.
Webspehere/Weblogic administrator makes corresponding changes to server configuration through administrator console.
The above change is not version controlled so there is no clean way of knowing the history of such changes.
The problem is not about how the application should be configured but about how the configuration changes should be version controlled. Perhaps it sounds like an overkill for simple projects but for some projects, controlling changes like these really becomes a problem.
Any time you ask yourself "should X be in version control" the default answer is "yes".
For a more refined answer, ask yourself this: is the file created by a person (like a source file or a document) or is it generated by another program (like an object file or a distribution PDF)?
File that are created, and/or maintained, by a human should be under configuration control.
We are always using version control for our app server settings. It's a tool called WLST (weblogic scripting tool) which is part of the weblogic server distribution. The domain configuration is stored within a Jython script, which can easily be executed via command line and therefore integrates superb with our build tool maven.
Creating a preconfigured running weblogic domain only needs to execute a maven goal. All those annoying problems of misconfigured jdbc connections or wrong jms destination parameters are gone. You will always have a appserver configuration which matches the source code at a given time. You will never need to remember which app server setting must be applied for this specific version of the project you are working on.
I really recommend this.
I also would like to know, if there are similar solutions for other application server available. As far as i know there is a way for glassfish via ant. How this can be achieved for JBoss?

Categories