Can someone explain what GlassFish does with deployed directories - eclipse

I have an exploded directory that I am editing in eclipse (created via setting location to directory location when creating New Project, deployed directory already existed). When I deploy this directory from the command line, it does not seem to save it locally (anywhere within glassfish\domain_
If I create a Java EE application in eclipse from scratch and deploy it from Eclipse Run -> on server, it copies it to glassfish\domains\domain1\eclipseapps
Is there a way to have GlassFish save deployed directories locally without using the GlassFish plugin magic?

Short Answer: No.
The whole point of directory deployment is speed and development convenience.
You tell GlassFish to not copy any files at all but to, instead, use the files already laid out on disk.
If you want to run from a copy of your app then just deploy the archive (war/rar/ear/jar) file.

Related

JBoss EAP 6 - How to deploy huge exploded folder

We run JBoss 6 in standalone mode. We do have a folder (content.war/) in deployments that contains a symlink to a different folder (let's call it docs). Symlinking is enabled in jboss-web.xml with <symbolic-linking-enabled>true</symbolic-linking-enabled>. Our scenario is to use this to serve static files via this app context.
We do deploy the folder using touch content.war.dodeploy. It all works fine when the docs folder contains just few files. When the docs folder points to actual folder that has around 30GB the deployment seems to be stuck (the folder is not deployed and no other deployment works afterwards).
I believe that JBoss tries to somehow traverse or scan the whole folder. Is it possible to somehow disable this behaviour?
One workaround seems to do the trick. I can deploy an empty exploded war folder and once it is deployed I create the symlink to the huge folder.
Disadvantage: When JBoss is restarted it gets stuck again. I'd need to remove the link and create it again after deployment.
Another option is to use welcome-content that JBoss uses to serve static content. I can remove the original welcome-content folder and create a symlink to my folder instead.
ln ‐sv /home/mypath/my-static-content ${JBOSS_HOME}/welcome‐content
Disadvantage: This doesn't allow you to use any symlinks inside your folder or subfolders.

web app file spec mismatch between Eclipse project and Eclipse-generated .war

I am developing a web app in Eclipse for deployment to a Tomcat server. Currenly, it works fine when I launch it from within Eclipse, using a Tomcat installation on the localhost. But when I export a .war file and install it on a remote server, it fails because of a mismatch between the file system in Eclipse and the file system in the .war file.
When Eclipse created the Java EE project for me, it created the following directory structure:
app
src
WebContent
I put all of my Java source files---servlets and classes---in the src directory, and all of the Web files---.jsp, .html, and various .xml resources---in WebContent.
So that my app could use the .xml resources, I put them all in a WebContent subdirectory named, not coincidentally, resources.
I then defined a variable pointing to these files...
path_to_resources = "WebContent" + pathMrkr + "resources" + pathMrkr;
// where pathMrkr = System.getProperty("file.separator")
...in each class that needs to access the .xml files.
This works well when I run the app from within Eclipse. But when I export and deploy the app if fails. The .war file Eclipse creates does not include a WebContent folder, so the search for resources fails, and the app crashes, shutting down Tomcat in the process.
So, I guess I'm looking for some advice on how best to structure Eclipse or my app so that a single code base works both in Eclipse on the localhost and from a .war file on a remote server, with a minimum of fuss and fidgeting with build configurations or having to manually edit the .war file.
While I don't think it's pertinent, for the record my system is:
Eclipse Luna, on a Windows 10 localhost, with Tomcat 8 and Java 8. The remote server running in the cloud is a CentOS 5.5 system running Tomcat 7 and Java 8.
Thanks.
Jerry

How to employe auto-deployment?

I'm working on a WLS 12.1c locally installed application server (on a VM instance). I deployed apps with the help of the WLS web console. Selecting "install" and selecting the path of the EAR file I wish to deploy. Fine. Works.
However, I wish that the ear is picked up from this same place every time it changes. Otherwise I have to "Delete" the deployment package, restart the server and "install" the EAR again. Too much hassle.
How do I activate auto-deployment?
thanks
If you're in a development setting, you might want to use auto-deployment instead:
Development mode enables a WebLogic Server instance to automatically deploy and update applications that are in the domain_name/autodeploy directory (where domain_name is the name of a WebLogic Server domain).
Note that your Weblogic Server MUST be running in development mode.
Once you add your EAR to domain_name/autodeploy/, from there on out, it will automatically picks up changes to the files in that directory:
To auto-deploy an archived application, copy its archive file to the /autodeploy directory. WebLogic Server automatically sets the application's deployment mode to stage mode.
A deployment unit that was auto-deployed can be dynamically redeployed while the server is running. To dynamically redeploy, copy the new version of the archive file over the existing file in the /autodeploy directory.
See: http://docs.oracle.com/cd/E24329_01/web.1211/e24443/autodeploy.htm

file created using getRealPath gets created on .metada/.plugins folder not in WebContent project folder

I am trying to create a file using below code in a Servlet:
File outfile= new File(servletContext.getRealPath("/Output/output.xml"));
OutputStream os = new FileOutputStream(outfile);
from a J2EE Application (CallMain) and the file gets created in deployed temp path
.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\CallMain\Output
Actually I want the file to be created in current project folder: WebContent.
Actually when you ran the servlet within eclipse using the embedded tomcat server
getServletContext().getRealPath("WEB-INF")
Gives you this
D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\DynaServletProject\WEB-INF
But when you ran the servlet from standalone Apache Tomcat:
getServletContext().getRealPath("WEB-INF")
This gives you
D:\apache-tomcat-7.0.33\webapps\DynaServletProject\WEB-INF
While in eclipse you can give the absolute path i dont think this is the best approach though
By default, your application stages and runs from a directory buried in the workspace's .metadata directory. That is the "real path" at runtime. Check your Server's configuration for options regarding deploying the app directory from the workspace folders.

Deploy a War file with Eclipse and Tomcat 6 without a build file

I know there are a bunch of posts on this topic, but I can't seem to figure it out. Here is my setup:
- Eclipse Indigo
- Tomcat 6
- Struts WAR file that I imported into Eclipse from http://www.manning.com/dbrown/SampleApplication.zip
I added the server to Eclipse, and added the project to the server. It runs fine, but I'd like to make some changes to the XML and java files (not the jsp files). I was under the impression that Eclipse takes care of the deployment after I save and restart the server, but I guess this isn't the case. I looked into creating an ant file to do a custom build, but I'm not really sure how to make it since I don't even know how to do a deployment "manually". How would I go about doing a manual deployment? Thanks.
A war file is usually created by exporting it from an IDE like eclipse, netbeans, etc.
While generating a war file there is 2 options,
You can include your java files with it
You can avoid java files from it.
In both the cases class files will be there which are created from java files. Class files will be able to take care of the actions of java class.
If the war file which you down loaded is not having those java files, you will not be able to use it with eclipse, where as it will work fine if you are putting it into tomcat directory for running.
For running a war file manually just put it into tomcat webapps folder and run tomcat.
Then you can access the pages using the url.
http://localhost:8080/yourprojectname/
If you want to check whether the war file contains any java files, after starting the tomcat server it will extract the war file into the same directry, where you can search for java files.
If you want to run the project from eclipse,
import it into eclipse, open index.jsp page
right click-> run as-> run on server
if you have not yet configured the server yet,select the server in the list, specify its installation path, then add projects into server in next step, finish it. then it will load your project.
Please provide little more details so that we can help you better.
manual: copy the war in the tomcat folder then start tomcat.
if you want to use eclipse you need to click redeploy war first by right clickling the deployed war in the servers tab under tomcat.