content file after Jboss deployment from war - jboss

I am a newbie. Now I am developing a project using jBoss 7.1. When I run the project from Eclipse, my application 'myproject.war' directory exists under the directory of 'jBoss/standalone/deployments'.
But I got some problems, when I exported war file and upload/deploy by JBoss Admin Console, my application 'myproject.war' directory does not exists under the directory of jBoss/standalone/deployments. Every re-deployment times, application directory path is changed under temp directory of jboss server.
My problem is, my application keep the user uploaded files under the a directory of application root directory (Example : jBoss/standalone/deployments/myproject/upload).
I need to backup the upload directory regularly. That's why, I want to constant path of application directory for every re-development time.

Related

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

Why do files end up in JBoss tmp but not the deployment

I have a JBoss server whereby when I deploy my ear file from Eclipse, I'm ending up with a whole bunch of jar files missing from the lib/ directory. Upon further investigation, I have found these files - they're in the JBoss server's tmp/vfs-nested.tmp directory. The timestamps all confirm that they're "fresh" from the latest Eclipse server instance publish action I kick off, but I'm perplexed as to why they're residing in this tmp directory and not in the application's (failed) deployment to the server.
JBoss documentation indicates "The tmp directory is used by JBoss to store temporarily files such as unpacked deployments." but I'm unsure as to what the order is or why things are there but not in the deployed application.
Any help?
Dave

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.

Deploying GWT in localhost and see that webpage

I am a new user in GWT and I want to deploy one of existed samples in my localhost. I could run the example by eclipse and get the result. But I need to deploy that example in my localhost (IIS). How can I do this?
Copy the contents of your project's war directory to your server's document root. You could create a folder there, mproject for example. Then load your project on a web browser: localhost/mproject to view.
Go into your project's war directory For EX:
C:\workspace\HelloWorld\war
Select all the files & folders available inside war directory.
Zip all the selected files & folders in a file called HelloWorld.zip.
Rename HelloWorld.zip to HelloWorld.war.
Deploy it to the server

Can someone explain what GlassFish does with deployed directories

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.