I'm using Maven to deploy a Java web project into my Tomcat 6.0 server. I have a "system" named project which is a war, and has his own JSF configuration and JSF managed beans.
The goal is that this system can have some apps installed on it, and apps themselves also have their web content and JSF configuration. My problem comes here, and I have two choices.
If I compile the app as a jar file, the faces-config.xml file has to be stored in the project's META-INF folder, so when loading the jar, JSF can find this file because it's located in the default place. However, my app also have web content, and I have to store it in the main system (webapp) location if I want it to be read. That's a functional but not elegant solution.
What I want to do is to define the app as a war file, and including it into the main system POM file, every web content from my app will be published in the server automatically. That's a good idea, but what can I do with my faces-config.xml file?? I already have one defined in my system and when Maven tries to deploy it, it finds there's already a same named file into the server. So I can't get my app JSF configuration from my system.
There is a way to define multiple jsf-config files, using a context-param in web.xml. Something like that works, but I want it to be dynamic:
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml, /WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
</context-param>
Does anybody have any idea for that? Thanks in advance!
That's a good idea, but what can I do with my faces-config.xml file?? I already have one defined in my system ...
It sounds like you should remove that copy, and put a webapp specific copy in each webapp.
Related
For some application was build a war with two web.xml files inside. I want to deploy that application in different servers, on of that being Jetty and other GlassFish for instance. For Jetty I try to deploy in jetty.xml, and I want it to load both web.xml descriptors files. It would be useful at least some tips for that. This question I consider that is a general one and I will not provide a concrete code for it.
I'm a .NET Programmer and right now I'm struggling with a web service I developed in JAVA. The web service doesn't have access to a database, only do some cryptographic tasks. To deploy it, I build the project with dependencies in Net Beans, generate a WAR File and upload it in the JBOSS web console.
The problem is that I'm looking for the analog of Web.Config in .Net, where some parameters can be set by a human without compiling again . In my code I call a XML file with all the parameters, however, the location of the file must be hardcoded. My solution was to set an enviornment variable with the folder so I always have to look for the XML there.
But I have an inconvenience: The same deploy will be set in two instances of JBOSS in the same server and both web services will have access to the same file, but that can't happen because some configurations are different in each one.
I tried the Web.xml file, but where can I find it in the JBOSS folder? Each time I upload the war or disable/enable it, it change the folder of the web.xml
What can you suggest?
The idea of using the web console is to work with artifacts (closed package) and you shouldn´t be manually modifying them.
From what i understood of your requirement, one option is to put an external file in the classpath of each jboss.
https://developer.jboss.org/wiki/HowToPutAnExternalFileInTheClasspath?_sscc=t
Can anyone guide me how to get Servlets working in Apache Tomcat server? I can run the Servlets from Netbeans without problems, but I don't know where to put the class files in Tomcat.
In tomcat:
class files must be in TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/classes
jar files must be in TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/lib
(and if course you'll need web.xml in WEB-INF)
They go in Tomcat/webapps folder. There are several ways to deploy a JSP/Servlet webapplication on Tomcat. They are all described in Tomcat Web Application Deployment HOW-TO.
If you already have developed the webapplication in Netbeans, then Netbeans should already have build a WAR file of it in the /dist folder. You just need to drop the WAR file in Tomcat/webapps folder and Tomcat will automatically deploy it during startup (or even while running, this is called hotdeploy).
If you want to develop without an IDE and/or don't want to create a WAR, then you just need to put a folder representing the context name in Tomcat/webapps, e.g. Tomcat/webapps/contextname. It will become the public web content. You can drop all JSP files and other static files in there. Then, for classes you need to create a Tomcat/webapps/contextname/WEB-INF/classes folder. There should go the package structure.
If I make a spring mvc application, what are the things I have to do to deploy the application? (say its a commercial application)
What options do I have? Do all applications compress the classes into a .war file?
/WEB-INF/web.xml, appname-servlet.xml, etc.
/WEB-INF/jsp/*.*
/WEB-INF/appname.war ???
Done correctly, the build process will create a war which can be dropped into any servlet container (Tomcat, Jetty, Glassfish).
If you use external source files, those would have to be configured.
If you use advanced features provided by the servlet container, the server would have to configured as well.
Spring application is no different from any java web application when deploying. but generally the only thing I have to do is flip the order of test spring config with the actual one.
Any IDE could create the WAR file for you. As you've said the configuration xml files go to /WEB-INF folder and jsp files (by default) to /WEB-INF/jsp/. You also need to put all required jar files in /WEB-INF/lib folder. Compiled classes will go to /WEB-INF/classes, but let the IDE do that for you.
The war file shouldn't be in the /WEB-INF folder. In Tomcat for example you need to copy it to the webapps folder.
I'm developing a Jboss web service that requires to access files which are in a folder of the project. When I deploy the web service, it creates a .jar, but the folder doesn't go inside of it, even if I added it to build path.
How do i tell jboss to place the folder inside of the .jar?
Thanks in advance.
I assume, because you explicitely say "jar" that your webservices are ejb endpoints, and not JAX-RPC servlet based webservices (because those would be packaged in a .war).
Unlike servlets, who are somewhat capable of finding files inside the project (as long as you can express their location as an offset to the web folder you can determine theire real location with ServletContext's getRealPath() EJB's don't have any "automatic" notion of directories.
So even if you could convince Eclipse to deploy files for you, I doubt it would help you much.
EDIT:
in a web-archive (.war) everything inside the web folder will be accessible by the servlets at runtime via the mechanism explained before. Do note however that files inside web are accessible via the web interface, except those inside the WEB-INF folder, so I'd suggest to at least store your files somewhere in a subdirectory of WEB-INF.
On a more global scale you should also ask yourself the question if you really must deploy these files with the application - and redeploy them with each redeployment. One solution in that case is to create some directory on the server (say c:/applicationfiles), create a JVM option e.g. -Dserverfilestore=c:/applicationfiles and have your application determine that directory with
String storebase=System.getProperty("serverfilestore");
The rest should be quite obvious. This solution will also work with you EJB services btw.