I have not been able to find any documentation on how to setup an ehCache server embedded inside an existing application. Does anyone know of a way of doing this?
It is working not as a server but it is simple library. In this case usage is pretty simple:
http://www.ehcache.org/documentation/2.8/code-samples.html
All you need - configure ehcache.xml.
Yes, there is also a server, in form of separate web-app. So you can just take this web-app and run on embdeded jetty.
Related
I have just returned to Spring after 5 years of gap and it seems lot is changed. I have a task to create a REST Service using Spring with hibernate as an ORM, So far I am able to run a basic Rest Service using embedded jetty and able to make GET/POST calls, the next is to integrate hibernate into it so that the data fetch/Sent operation actually use MySQL instead of sending hard-coded response(which I have done currently).
The issue is earlier I used to work on Spring MVC using Tomcat where we had web.xml to define the dispatcher servlet and application-context which in turn were used to define hibernate config and other beans declaration, but now having embedded jetty I am not finding a way to integrate hibernate to my REST app, Is the way to add configuration is changed from XML to class based config. I searched over internet but maybe I am out of words or not using correct keywords, in short, Have no luck finding some solution to integrate hibernate to my Spring app which is using embedded jetty.
Could some please breif me about the recent changes or point me to the right tutorial ?
Any help appreciated, thanks in advance !
ps - I have used this example to progress so far https://github.com/pethoalpar/SpringMvcJettyExample
Yes , lot of changes in these 5 years and one of the game-changer is spring-boot
If you want to build a brand new project especially if you want to run the web application on the embedded container such as Jetty , you can check out spring-boot.It already provides integration with Jetty , hibernate and Spring MVC REST service.
The end result is that you just need to change a little bit configuration (most probably the DB connection info) and you can quickly get a production-ready REST service backed by JPA/Hibernate which can just run without any XML configuration anymore.
There are tons of tutorials in Internet talking about how to do it . You should easily find them out such as this using the keywords something likes "springboot webservice hibernate jetty" etc.
im new to Java Spring and when i am starting netbeans with a new web project, i have the option to choose a framework. When I'm choosing Spring MVC, i have got an embedded tomcat out of the box. I liked it very much! So easy it can be! But this make it complicated to understand what is happing behind. I want to know, how to create a https connection, without configuring in the tomcat settings. (Or is this the only way?) I tried this one, but than you have to start tomcat manually with the batch-file. When using http-connection und you running your project it usally reachable and you do not need to start tomcat! I dont know how it works, but i think it starts the embedded tomcat and listing to a random port, the url is printing out when starting project. Another question is, where can i change the url name? Now i have this one:
http://localhost:8084/projectname/
And i want to give a customer name. Maybe someone answer to this question or post a link with useful information how to configure embedded tomcat. For me it is important to keep the default construction of java spring in netbeans!
And i want to use the dispatcher.xml, web.xml -> So don't want to switsch to use tomcat in my javacode! Hope that this is possible!
Thank you very much, Mira.
According to Spring documentation, it's possible to configure an embedded ApacheDS server, which makes testing easy.
Any reason why not use ApacheDS embedded with spring in deployment? is there some kind of limitation for that?
Also I noticed it's writing to temp directory /tmp/apacheds-spring-security. Is there a way to configure it?
I already participated in a project where embedded ApacheDS server was used in development and deployment (for test server). There was two minor problems:
If you stop your app incorrectly (for example via Terminate in debug mode or via kill -9) then you need to clean up /tmp/apacheds-spring-security directory manually. If you leave temporary files then an runtime exception will be thrown during next loading of your app.
We did not find how to change the default temporary directory (/tmp/apacheds-spring-security).
Hope this helps.
EDIT.
For the first problem I ended up with a servlet-api listener. It was declared before Spring context listener (to ensure execution before Spring and ApacheDS). This listener was responsible for checking and cleaning up /tmp/apacheds-spring-security. Maybe it is not the most elegant solution but it works. It will be better to have a param for this case in ApacheDS, something like -DapacheDSCleanUpWorkDirAtStutup=true.
In a J2EE application, how do I create a global Filter that can access other webapps installed on that app server?
In case anyone is still interested, here are my findings regarding this question:
For tomcat and others webapp servers derived from it (eg: JBoss), you can add your filter to the "global" web.xml, usually located under $TOMCAT_HOME/conf/web.xml.
For Websphere, I´ve found the following article to be useful: http://www-03.ibm.com/support/techdocs/atsmastr.nsf/WebIndex/WP101859 . In this case, the basic idea is that you write a ServletContext Listener and uses it to attach your filter to the app
The Servlet-API does not provide such a security leak. But some containers offer alike. Have a look at the <Valve> Configuration of Apache Tomcat. Maybe there is a similar functionality for webshere, but typically you need to hire a ibm consultant to "find" the configuration.
Some application servers/servlet containers (Tomcat, JBoss) provide the cross context feature. It does depend on what you're running your application within however, it's not a J2EE feature.
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
I'm not sure whether this will help you in what you want to do. What is it exactly? : )
Take a look at this response as well:
What does the crossContext attribute do in Tomcat? Does it enable session sharing?
There is no way to do this in a container/platform independent way. Your J2EE container might provide hooks for you to do this though.
This worked for me: https://stackoverflow.com/a/8815211/964681
Sorry, couldn't just comment on your question. Haven't enough "points".
Right now I am using a web-server which does not contain EJB container. If my application needs EJB container, how could I add one?
Do you really mean into? If yes, then maybe have a look at OpenEJB (the EJB Container implementation for Apache Geronimo). But I can't say that it's widely used.
Actually, why not just replacing your servlet container with a full Java EE server if you need EJBs, I don't get it, something like JBoss AS or GlassFish.
OpenEJB and EasyBeans are open-source EJB containers that can be dropped into Tomcat or other servers / applications.
But, you should describing what you need this for... because if you need EJBs specifically, you're probably better off going with a full app server (JBoss, Glassfish, Weblogic, etc.). If you're just using it for persistence, you're probably better off using some other persistence technology (Hibernate, iBatis, etc.).
JBoss is an open source J2EE server. So if for some reason you can't just use it, you could take the EJB container and graft it into something else. Probably not a small job.
Too litte information on your architecture to give a decent answer.
Anyway chances are good you already apache as web server, you can simply connect using mod_jk to the embeddd tomcat in jboss.
This configuration will use the Apache JServ Protocol (AJP) for communication between Apache and Tomcat.
A description on which config files you have to fiddle about is here