I have installed WSO2 Carbon 3.2.2 and would like to host some static files that I can access from a browser (specifically, a variety of HTML and JavaScript files that make up a working website). I want to be able to access the files from http://localhost:9763/<MY_FILES>. With Carbon 3.0.0 this was as simple as putting the files in <CARBON_HOME>/webapps/. Carbon 3.2.2 does not have the <CARBON_HOME>/webapps/ directory, and adding it doesn't help.
I noticed that (after installing certain features) there is another webapps directory located <CARBON_HOME>/repository/deployment/server/webapps/, but that appears to be specifically for deploying war files.
I've tried putting my files everywhere I can think of, but I've had no luck.
Is there a feature that I have to install? Is there a special location to put these files? Is this still a supported feature?
This is never been an advertised feature of Carbon nor it has been recommended. Hence you can't expect to have backward compatibility for a "non feature".
The right thing to in a production environment is to use a web server (Apache, nginx etc...) to serve static files because web servers are optimized to do that. Then proxy the connections to Carbon via the web server. For example, by using mod_proxy for Apache.
You can still use the Application Server (or after installing AppServer features into any Carbon server) to create a .war file and have your static site there. Then again if it's a static site using Application Server is an overkill.
Related
I am trying to deploy a simple PHP website to the Swisscom Application Cloud, based on cloud foundry.
My website is working fine locally, served by Apache.
I have followed the tutorial, but I am not clear on some aspects.
In the tutorial, the way to check if the app is working normally is to run it in the built-in web server in php through php -S. This doesn't work for me because my website has html extensions for php files and these are not interpreted correctly by the built-in server. In Apache, I can configure that just fine in the httpd.conf file, but here I don't know how to configure such a behaviour.
That's fine by me, because I can still check the website locally serving via Apache. The problem is that it looks that in the cloud this is the way to run the app as well, although I couldn't find more info in the documentation.
I'd be surprised that this is how the app is run in production because the php documentation states the following about the built-in server:
"It is not intended to be a full-featured web server. It should not be
used on a public network."
Are the web apps being run on Apache in the Swisscom Application Cloud? If yes, how do I get access to configure the httpd.conf and php.ini files? If no, how can I configure the special behavior I need for my app?
UPDATE:
Here is a sample php app which summarizes what I am trying to achieve: deploy it in cloud foundry interpreting html files as php files.
https://github.com/atineoSE/sample-php-app-cloudfoundry
Following #daniel-mikusa 's links to documentation I added special config related to the mime types under .bp-config/httpd/extra/httpd-mime.conf. This doesn't work as expected, though. Accessing from firefox, I am prompted to download the file. It works fine when I serve it locally via Apache with the same directive in the httpd.conf file.
The PHP build pack does not use php -s. I suppose that you could, but it's not the default. The default setup is to use PHP-FPM & Apache HTTPD, or ou can optionally use PHP-FPM w/Nginx.
For the most part, the PHP build pack should just run your app. There are occasionally things you need to adjust, and they are easily configurable by adding .bp-config/options.json to the root of your app.
I don't know anything about your app though, so I can't really say. If you can't get what you need with options.json you can customize the configuration for HTTPD, Nginx or PHP too. Check out the docs here for instructions to do that.
http://docs.cloudfoundry.org/buildpacks/php/gsg-php-config.html#engine-configurations
Hope that helps!
For a normal JSP web-app that provides web-services, where should the JAX-WS library jar files be placed?
<tomcat-home>/lib
or
<web-app>/WEB-INF/lib
and why?
In general, when are library files considered part of the container infrastructure or part of the web application?
DETAILS
I have implemented various JAX-WS web services following, among others, these guides:
https://jax-ws.java.net/2.2.10/docs
https://jaxenter.com/creating-soap-web-services-using-jax-ws-117689.html
http://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat/
http://examples.javacodegeeks.com/enterprise-java/jws/jax-ws-web-services-on-tomcat/
http://www.java2blog.com/2013/03/jaxws-webservice-deployement-on-tomcat.html
Whilst the above guides were useful, there are differences in terms of both the required JAX-WS library jar files and where the JAX-WS library jar files should reside.
By trial and error, for JDK 1.8, Tomcat 8.0.30 & JAS-WS 2.2.10, this is the list of JAX-WS library jars that seem to be required:
gmbal-api-only.jar
ha-api.jar
jaxb-core.jar
jaxb-impl.jar
jaxws-api.jar
jaxws-rt.jar
management-api.jar
policy.jar
stax-ex.jar
streambuffer.jar
I am aware that the JDK contains some of the JAX-WS classes but these seem to be meant for standalone Java apps
ie all of the above jar files seem to be needed to avoid a ClassNotFoundException etc.
I have read the Tomcat 8 class-loader how-to
and appreciate that there is a parent-tree, hierarchal class loader and that jar files in:
<web-app>/WEB-INF/lib
are only available to that web app ie are hidden from other web apps
causes the app war file(s) to be bloated as each web app has it’s own copy
and that jar files in:
<tomcat-home>/lib
are available to and shared by all web apps
forces all web apps to use the same version of the library
libraries must be inter web-app shareable ie no statics, thread-safe etc
enables lookup via a JNDI Resource Factory eg JDBC, mail etc
suppresses memory leaks for DriverManager eg JDBC
The web services seem to work when the JAX-WS library jar files are in either location.
Looking at the Metro JAX-WS project,
where the JAX-WS library jars must be downloaded from, for now, I have put these into <tomcat-home>/lib as that is consistent with the ‘install’ option in the ant file.
As a general rule, I try not to pollute the web-container / app-server with unnecessary library jar files where possible as this can lead to conflicts for other web-apps that have to use a specific version of a required library.
Thanks for reading.
Had the same issue trying to deploy a web service to my local tomcat installation. I went the route of adding the jars you listed to get it going, but see the instructions of what's needed from Apache:
https://tomcat.apache.org/tomcat-8.0-doc/extras.html#Web_Services_support_(JSR_109)
...which I think will go a long way to minimizing the amount of jars that end up in your Tomcat's lib folder.
I'm a django newbie. I've read that all django projects, deployed in production environment, should serve media files (uploads) through web server such as apache. My question is - why is that?
There are lots of PHP frameworks - eg. symfony 1 and 2 - which don't follow the rule. Once you've made your app accessible through a web server, you don't have to change anything depending on the env you deploy. There is just the DOCUMENT_ROOT configured on the web server and somewhere inside this directory lies the upload directory - that's all. You can be sure that no one will access PHP, sql files and so on - thanks to the proper framework architecture and the document root. Why is it different in django?
edit: besides, preparing different code for different environments (e.g. this) is quite a bad approach, since you can't use exactly the same code to deploy a project in different envs (and the code from the link makes sense only for debug env.
Because with PHP your code is served from web server's public directories together with static and media files. So when you request any of these static files web server serves them directly without executing any PHP code along the way.
In Django your code is running separately and all requests are processed by python code in Django. This is inefficient to serve static files, it's more efficient to serve allow a web server like Apache or Nginx to serve them directly without going through any python code.
I am using wso2 application server v4.0 on Linux.
I have a webapp and I want to have a folder to store files. The folder size can be huge and the application could be redeployed as well, so directory is not inside the webapp.
How do I create a virtual directory or similar in wso2? That directory can be general, i mean it is not needed to be related to the webapp examples: localhost:80/myDirectory/ and localhost:80/myApplication/myDirectory/ are valid approaches to me.
There are some clear instructions to do it in tomcat but I can't find out how to translate this to tomcat in wso2.
Please checkout the sample available here.
I have a webapp (http://sourceforge.net/projects/sf-mvn-plugins/files/m2-repo/net/sf/maven/plugins/example-captaincasa-jnlp/0.1-SNAPSHOT/example-captaincasa-jnlp-0.1-SNAPSHOT.war/download) which uses jsf in a servlet container. This works fine with jetty-maven-plugin run-war target at my local pc. In the future I would like make more of this kind of webapps.
I am looking for a way to deliver these webapps with jetty via jnlp. The end user should be have a zero installation but the webapps needs servlet container and my hoster does not support a servlet container or application server or so on.
I don't like an embedded solution because in this case each webapp must be delivered with a separate jetty und run with a separate jetty -> too big size -> to many download size and so on.
The architecture should be similar to this:
(source: sourceforge.net)
Example: Bundle1 could contains jetty and deployed webapp1 and Bundle2 could contains jetty and deployed webapp1 and webapp2 (related to requirements of end user I would like deliver many variant of my webapps)
But what is my question?
Which jars of jetty are needed? I would like these upload to my homepage for hosting.
Which jar should I use for jetty as main jar to start him via jnlp?
Which main class should I use to start jetty via jnlp?
Which parameter could I use to configure jetty to say this is war of webapp1 and this is war of webapp2.... or this is directory of weapps for hot deployment...?
The important question for me is 1. If this is answered so that I could run jetty local (without maven plugin) and via manual maybe I could solve the rest 2-4.
Why not deploy a normal Java app (with a main() etc.) that invokes Jetty programatically via its Server class? That class is configured via code with the appropriate contexts, servlet classes etc.
I've done that before with success. The only headache is running one Jetty with multiple apps being downloaded on request (if I read your question correctly). Can you use some classloading magic, and load classes/apps on demand from a remote URL ?
I have found another way today. This is interesting too. Here is the concept:
Use java webstart to install an osgi container
Use a bundle x or a osgi service to download all bundles of your app
Use the jetty bundle to provide jetty support
Then the application is installed
I got the idea from this article:
http://www.toedter.com/blog/?p=45