Purpose of Glassfish's "generated" directory - deployment

I need to better understand what goes into the "generated" directory inside a domain folder of Glassfish. I can see that deployed applications store some resource files in there, (xmls, properties, manifests...) but don't really understand why. Google was not very useful this time. Could someone point me to some relevant documentation? Thanks.
Edit: I need to know these details because i want/need to delete this folder when restarting the server.

After experimenting a bit i found that i could delete all of the
following directories inside the GF domain and have them created when
GF starts:
applications
autodeploy
generated
logs
osgi-cache
The first 2, of course, if you redeploy your applications. I usually
delete these in development after a GF crash.
To complement sebi's answer, make sure your server is stopped when you delete those directories. Doing this while it's running may damage the domain you are working with.

After experimenting a bit i found that i could delete all of the following directories inside the GF domain and have them created when GF starts:
applications
autodeploy
generated
logs
osgi-cache
The first 2, of course, if you redeploy your applications. I usually delete these in development after a GF crash.

Related

WAR doesn't get redeployed in Glassfish from autodeploy

I was able to deploy my WAR the first time I placed it under domains/domain1/autodeploy dir. However, after making some changes and redeploying the WAR to the autodeploy dir, the changes were not picked up. I even deleted domains/domain1/applications/myapp (where myapp corresponds to the myapp.jar being deployed) but the WAR was not redeployed. The server was started and stopped via asadmin:
asadmin start-domain
asadmin stop-domain
What am I doing wrong so that the app does not get redeployed?
UPDATE: I tried manually (re)deploying (also using --force option) the WAR but got the following error in server.log:
[#|2013-03-17T20:47:36.177-0400|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=72;_ThreadName=Thread-2;|Application with name myprojectname is already registered. Either specify that redeployment must be forced, or redeploy the application. Or if this is a new deployment, pick a different name|#]
I do not know how to unregister/undeploy an app that's been once deployed. I tried removing all the references to my app in domain.xml but it didn't work. This seems like a very basic bug in the software.
I know this was answered long ago, but in case anyone else gets here via google like I did, I have another possible answer ...
After encountering this same issue, I found the following ... the autodeploy/.autodeploystatus directory still had a file referencing the application I was trying to redeploy by copying the war into the autodeploy directory. I had to delete the file in the autodeploy/.autodeploystatus directory, then my application was deployed when the war was copied into the autodeploy directory.
Hope that helps.
NOTE: Apparently, it is obvious to others who use glassfish that you have to delete all this stuff from the hidden .autodeploystatus directory to get your re-deploys to work. Why is it obvious to them? We may never know.
You can undeploy via asadamin with:
asadmin undeploy yourapplication
You can also visit the glassfish admin console http://localhost:4848 and undeploy via the graphical interface (look at Applications).
In general the re-autodeployment should work, but I would recommend using the normal deploy method or an incremental redeployment by some IDE like NetBeans...
Exactly the same problem reappears for an application running to be deployed in Payara 5.2021.10 (perhaps for other recent versions > 5.193) within a docker container.
The problem happens every time the docker container restarts - the deployment fails with a message:
Application with name {applicationName} is already registered. Either
specify that redeployment must be forced, or redeploy the application.
Or if this is a new deployment, pick a different name
The problem can be fixed by a forced redeploy. Place something like this into a Dockerfile of the application image:
ENV DEPLOY_PROPS="--force=true"
This environment variable allows to set custom parameters to asadmin's deploy command. How exactly is it applied can be seen in the script that generates the deploy commands, that is being run from within the container's entrypoint.

How to completely uninstall WAMPSERVER

I recently uninstalled, then re-installed WAMP, But now my domains(zend projects) are malfunctioning. I can only access the front pages for these domains but not any further pages, which I explained in a previous thread Everything suggested on the thread and more have not worked so far.
So I have another idea from searching google which suggests that WAMP has not been completely uninstalled when I did the first uninstall, and the solution is to go to regedit after uninstall, do a search for "wamp" then delete all records related to wampserver. I'd done this but I'm getting 216-records and only three of them has a mention of "wamp" on the record names. I feel it can't be right to delete all 216-records and i'm scared because these records point to other programs and systems in windows. But this blog seems to suggest that I delete them all as below:
...into the registry. Highlight 'Computer' and press the [Ctrl][F]
key combination to launch a search box. Type in 'wamp' as a search
term. Delete all instances of a record pertaining to WampServer. On
a healthy installation, there may be 70 such entries or more. Just
grit your teeth and get it done, making sure all the while that the
search result is indeed a WampServer related entry...
I have deleted the 3-records I found with mentions of "wampserver", but yet no solution to my problem. So my question is: Could the instruction possibly be to delete the entire 216-records in order to completely clear my system of all traces of the old WAMP installation?
Removing WampServer should consist of:
stopping and uninstalling the services (wampapache and wampmysql) either with the uninstall services batch file included or on the command line
deleting the wamp folder
Bear in mind any changes to:
Your web root folder(s)
Your hosts files
Your firewall
Now, if you've done the above and have problems still, it'll likely there are other problems. Such things as different httpd configs, .htaccess files, different versions of wampserver and components like PHP and it's modules, databases and their security credentials, etc.
Check the above, and if there are more specific errors feel free to post them too.
Thanks guys for your time. I think my actions as in the OP were successful in completely uninstalling wampserver. Just that my fresh instal of WAMP was mis-behaving and not finding pages beyond the home page. It's been sorted by enabling mod_rewrite. Though I'm not quite sure what went wrong as I'd applied the same mod_rewrite severally without a resolution.

Why does tomcat replace context.xml on redeploy?

Documentation says if you have a context file here:
$CATALINA_HOME/conf/Catalina/localhost/myapp.xml
it will NOT be replaced by a context file here:
mywebapp.war/META-INF/context.xml
It is written here: http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
Only if a context file does not exist for the application in the $CATALINA_BASE/conf/[enginename]/[hostname]/, in an individual file at /META-INF/context.xml inside the application files.
But everytime I re-deploy the war it replaces this myapp.xml with the /META-INF/context.xml!
Why does it do it and how can I avoid it?
Thanx
Undeploy part of redeploy deletes app and the associated context.xml.
If you use maven tomcat plugin you can avoid deleting context.xml if you deploy your app with command like this:
mvn tomcat:deploy-only -Dmaven.tomcat.update=true
More info here: https://tomcat.apache.org/maven-plugin-2.0-beta-1/tomcat7-maven-plugin/deploy-only-mojo.html
You can use deploy-only with parameter mode to deploy the context.xml too.
The short answer:
Just make the TOMCATHOME/conf/Catalina/localhost dir read-only, and keep reading for more details:
For quick deployment mode (Eclipse dynamic web project, direct Tomcat
connection, etc.) on a local/non-shared Tomcat server you can just define your JDBC datasource (or any
other 'web resource') using the META-INF/context.xml file inside the
WAR file. Easy and fast in your local environment, but not suitable for staging, QA, or
production.
For build deployment mode (usually for staging, QA, or prod), JDBC
datasources and other 'web resources' details are defined by the
QA/production team, not the development team anymore. Therefore, they
must be specified in the Tomcat server, not inside the WAR file
anymore. In this case, specify them in the file
TOMCATHOME/conf/Catalina/localhost/CONTEXT.xml (change Catalina
by the engine, and localhost by the host, and CONTEXT by your context accordingly). However,
Tomcat will delete this file on each deployment. To prevent this
deletion, just make this dir read-only; in Linux you can type:
chmod a-w TOMCATHOME/conf/Catalina/localhost
Voila! Your welcome.
The long answer
For historical reasons Tomcat allows you to define web resources (JDBC datasources, and others) in four
different places (read four different files) in a very specific order of precedence, if you happen to define the same resource multiple times. The ones named in the
short answer above are the more suitable nowadays for each purpose, though you could still
use the others (nah... you probably don't want to). I'm not going to
discuss the other ones here unless someone asks for it.
On tomcat7, also woth autoDeploy=false the file will be deleted on undeploy. This is documented and not a bug (althought it avoids good automated deployments with server-side fixed configuration).
I found a workaround which solved the problem for me:
create a META-INF/context.xml file in your webapp that contains
on the Server create a second context "/config-context" in server.xml and put all your server-side configuration parameters there
on the application use context.getContext("/config-context").getInitParameter(...) to access the configuration there.
This allows a per-host configuration that is independent of the deployed war.
It should also be possible to add per-context configurations by adding contexts like "/config-context-MYPATH". In your app you can use the context path oth the app to calculate the context path of the config app.
According to the documentation (http://tomcat.apache.org/tomcat-8.0-doc/config/automatic-deployment.html#Deleted_files) upon redeploy tomcat detects the deletion (undeploy) of your application. So it will start a cleanup process deleting the directory and xml also. This is independent of auto deployment - so it will happen upon redeployment through manager and modification of war also. There are 3 exceptions:
global resources are never deleted
external resources are never deleted
if the WAR or DIR has been modified then the XML file is only deleted
if copyXML is true and deployXML is true
I don't know why, but copyXML="false" deployXML="false" won't help.
Secondly: Making the directory read only just makes tomcat throwing an exception and won't start.
You can try merging your $CATALINA_BASE/conf/Catalina/localhost/myapp-1.xml, $CATALINA_BASE/conf/Catalina/localhost/myapp-2.xml, etc files into $CATALINA_BASE/conf/context.xml (that works only if you make sure your application won't deploy its own context configuration, like myapp-1.xml)
If someone could tell what is that "external resources" that would generally solve the problem.
The general issue as described by the title is covered by Re-deploy from war without deleting context which is still an open issue at this time.
There is an acknowledged distinction between re-deploy which does not delete the context, and deploy after un-deploy where the un-deploy deletes the context. The documentation was out of date, and the manager GUI still does not support re-deploy.
Redeployment means two parts: undeployment and deployment.
Undeployment removes the conf/Catalina/yourhost/yourapp.xml because the
<Host name="localhost" appBase="webapps" unpackWARs="true"
autoDeploy="true"> <!-- means autoUndeploy too!!! -->
</Host>
Change the autoDeploy="false" and Tomcat has no order anymore to remove the conf/Catalina/yourhost/yourapp.xml.
There is an feature that allowes us to make those steps (undeploy/deploy) as one single step (redeploy) that do not remove the context.xml. This feature is available via the manager-text-interface, but the option is not available using the manager-html-interface. You might have to wait until the bug in tomcat is fixed. You can use the method described in this answer as an workaround.

How to create own server profile in JBoss AS 5 and 6

I am using JBoss AS 5 + 6 as an application server, however only as a simple EJB3/Web container with ear and war deployment but without special capabilities such as clustering, ejb2 or hornetq.
JBoss AS provides server profiles for different uses but I did not find any documentation on how to create my own or customize an existing profile. How can this be achieved? And where is it documented on the internet?
If you want create your own profile you have to create your own profile, which can base on one of the standard JBoss profiles: minimal or default (if you want clustering you can also use all or production profile).
If you choose minimal profile you have to copy necessary services to it (for example from default profile). You have to remember about config files, deployers and so on.
If you choose default profile you have simple remove unnecessary services.
In my opinion it is much easier to remove some services.
And the most important point: there is JBoss documentation what you have to remove from profile to disable given service: JBoss 5.x Tuning/Slimming.
I haven't seen any documentation on this, because I'm not sure it's something you're really supposed to do.
Having said that, I've been doing it for years, and it works great for me :)
It's a bit of a hit-and-miss task, though. You need to go through the deploy and deployers directories, removing any services or deployers that you don't need. You'll find that they have inter-dependencies on one another, though, and it's not always obvious what depends on what.
Take it one at a time - start with an existing profile (e.g. default), copy it (e.g. to myprofile), then start by removing one thing you don't need (e.g. the deploy/messaging directory), then start it up with that profile (i.e. run.bat -c myprofile), and see if it starts up OK. Try this with each service you want to remove. If you removing something it needs, it'll complain, and tell you what depends on it.

JBoss Application Server redeploy

I need a windows shell script which will redeploy my .ear file. I wrote one:
net stop "JBAS50SVC"
copy /y O:\TEMP\app.ear C:\jboss-4.2.3.GA\server\default\deploy\app.ear
net start "JBAS50SVC"
But the problem is that when I try to stop the JBoss service it does not fully unload itself (my suggestion), so when I start it there's no app deployed in JBoss.
You mentioned that JBoss becomes very slow when you use autoDeploy and keep the server running for a month or more. That's likely to be because your permanent generation memory is filling up over time. See this related question.
I think you'd be best served by using the autoDeploy feature as other suggest, and restarting the entire server periodically to clear out PermGen. There's several ways to track PermGen utilization; I add the following to JAVA_OPTS in run.conf:
-XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -Xloggc:$LOGDIR/gc.log
Typically to redeploy an application that is self-contained in an ear in jboss just requires replacing the ear. If there is more to the application (such as classes that have to go in the jboss lib directory) then it may require a restart.
In terms of how to restart it, it depends what you are using to start jboss as a service. Some service starters do not actually control the jvm after they start it, so restarting the service just starts a second instance. You can shutdown jboss with the shutdown script in the JBOSS_HOME/bin directory (shutdown.bat) and then deploy and restart the service. Be sure to pause when you do this, as the shutdown command will issue the shutdown request, the server may still be running.
You can just COPY/RENAME the EAR file to deploy directory. JBoss will automatically take care of re-deployment for you.
As mentioned earlier jboss automatically deploys everything you copy into the deploy directory by default.
If not, check if you are working on a vhost that doesnt autodeploy ear files.
<Host name="vhost2" autoDeploy="false" .... />
other than that, I feel like this is a totally different error due to the fact that jboss takes care of deployment for you. Please check the log files for startup errors of your application.
You might want to check the JBoss community wiki on this, there are undoubtedly easier and more reliable methods than a batch file.
Stopping the server should not undeploy the application - that wouldn't make much sense.