Tapestry class loader with Tomcat and maven - maven

Is it possible to integrate tapestry for class loading only under tomcat7 and eclipce, if so, how?
I am interesting in that for making java development alot faster.
My project is consists of:
Spring MVC+JSP
Maven
String Security
Mysql
Hibernate
log4j
Tomcat7
Eclipse
helios
ExtJs
I am looking for a stuation where I can save the java file and refresh the browser for seeing results/changes. (Like Jrebel).
Thanks

someone on the mailing list says it's possible, however i haven't gotten it to work 100%. You need to figure out how to point tomcat to various locations to find resources and not copy resources and libraries into the webroot folder. try asking on the mailing list for more instructions.

You need to use Jetty + tapestry for it. And use tomcat7 only to production and tests.

Absolutely it's possible and it works well. We (at tynamo.org) have a whole guide available for using Maven, Eclipse, Tomcat7 and Tapestry together, just follow the steps. Tomcat7 is easily as fast, perhaps faster starting up than Jetty.

Related

Simple working Spring MVC / Maven configuration

I’ve been trying to set up a Spring MVC application from scratch, using Maven, in IntelliJ Idea. I know there are probably some nice Archetypes that can do this for you, but I really want to understand what’s going on. Here’s what I want to do:
Create a simple web application that shows displays “Hello World” under https://localhost:8080/, using an embedded Tomcat (with the Maven plugin). So, one controller, one request mapping, and one template. I’ve been able to get the spring application to boot (the Spring logo appears in the console) and Tomcat seems to run as well (the site responds). The problem is, I haven’t been able to get the request to map to my RequestMap method in my Controller. I’m quite sure that the controller isn’t the problem, but that it’s some configuration/setup issue.
Here’s the thing: I’ve been looking at tutorials, StackOverflow, Spring documentation, etc. for hours now, but I haven’t found a source that really explains how to configure a Spring MVC Maven project. Everyone seems to have a different opinion on what XML files you need, what they should be named, and where they should be located. The consensus seems to be that you need a web.xml file in a folder named WEB-INF, but even there, everyone has a different opinion on where that folder should go. I appreciate that there are multiple different ways to do this, and that there’s no “right” way, but in my experience, there are definitely many “wrong” ways =).
My question right now isn’t necessarily how to get my current project running (I don’t mind starting over), but what kinds of config files are out there (web, spring, app-config, servlet, …), what they do, which ones you need, where they need to go, what they should be named, how they connect, etc. Some people also use the Maven Compiler plugin, and others don’t, and nobody says why :D. Essentially: How do I let Spring know where to find controllers, templates, etc., and how to run and deploy all of this on the embedded Tomcat. I would like to find a source that explains the entire core-ecosystem of Spring MVC in a unified way. I have found many sources that provide “how-to” tutorials, but with little to no explanation (like “add the following servlet.xml file to your WEB-INF folder”). So, if your setup slightly differs from the tutorial (e.g. because you are using IntelliJ instead of Eclipse, Tomcat instead of Jetty, embedded Tomcat, a slightly different folder structure) nothing works, and, most importantly, you have no clue why.
Has anyone learned these setup-basics with anything better than copy/pasting or trial & error? :D
Easiest way to start is by using Spring Boot. Go to following link:
Spring initializr
Choose "Web" for "Selected Dependencise" and click "Generate Project". Download of maven project should start after that. Then import that project in IntelliJ IDEA as a Maven project. And that is a good starting point. You'll get main class that you can run and embeded Tomcat will start at 8080 port. Than you can add some controller, template etc...
Also good guides

Deploy a Ninjaframework application on openshift

Apologies for the vagueness of this question.
Is it possible or, how can a ninjaframework application be deployed on Openshift.
Basically, I have a Ninjaframework application running locally in superdev mode. I can even build a war file. However, when I push it to an Openshift git repository it simply doesn't work. Specifically, I get a vague "Oops. That's an internal server error and all we know." page when I try to access the site.
TBH, I'm not surprised. I need to somehow specify to Openshift how to build the application. I'm hoping this can be done by some Maven configurations etc. but I haven't the faintest idea how?
Any help or pointers very much appreciated.
Yep, cool, thanks guys. I'm afraid i was so clueless on how to do this that logs would only tell me what I already knew; that simply git committing a NinjaFramework application configured to build as a fat jar (by default per the archetype) was never going to work in a Tomcat application server. Apologies if that didn't come across in the question.
I expected some elaborate Maven stuff would be required but luckily I was wrong. It turns out that a simple Maven change was all that was required to have the application deployable in OpenShift (Tomcat 7).
I've outlined the steps here in tutorial form: http://outbottle.com/deploying-a-ninjaframework-application-on-openshift/

Spring insecuremvc - sample files location?

I am trying to use Spring with: gradle, annotations (not xml), springboot, embedded server. Followed the guides of the side; they are great. Now I wanted to try it myself. I am creating a simple MVC (however I do not understand the difference between MVC and web-MVC entirely) - and want to add 'security'.
This example 'insecuremvc' (is maven, is war; instead of gradle/jar; but it is available). I could make it run.
However, where are the sources? I wanted to see them to learn it. It runs in my localhost, magically if said so, only by poms and downloaded jars - while, I could not find the jar of insecuremvc or such.
A similar question did not help. Is there anything fundamental that I have missed?
You wont have sources located in a WAR file as it means a web-archive. You can use the below link to get your sources which are in Groovy.
Source code
If there is anything else, let me know.

How to run a project containg drools in Tomcat7?

I have created a Dynamic web project which also uses drools for providing some functionality. When i put the WAR file in Tomcat7 and the server, the drools part does not work.
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
After this line which is first line relating to drools, nothing happens.
Is some configuration required to run my project containing drools 5.5.0 Final in the Tomcat7.
Please help me. I am badly stuck and I am new to drools.
You'll have to add some facts to the working memory and execute(fire) the rules. Check out these examples on GitHub
P.S. Probably not related to Tomcat in any way. Might be worth while to try getting the rules executed from command line app first.
You need to check all the dependencies that are added to your web application (WEB-INF/lib) make sure that drools has all the required deps there, because if not it will not be able to create the knowledge builder. Most of the time if it is failing is because that you forgot to add the deps in the web app.
The following project in GitHub is a web application, containing some REST-style endpoints for validating IBANs. It uses Drools 5.5 to perform that evaluation.
https://github.com/gratiartis/sctrcd-payment-validation-web/
It generates a .war which can be loaded into Tomcat, and could be a useful starting point. The knowledge base is wrapped within a Spring service:
https://github.com/gratiartis/sctrcd-payment-validation-web/blob/master/src/main/java/com/sctrcd/payments/validation/RuleBasedIbanValidator.java
Following through how that creates a knowledge base and session might help you see where your code is going wrong.
As a bonus, you can run it up in Tomcat using "mvn tomcat7:run" to test it out immediately.

web.xml in OSGi container

pros! Looks like basic question, but I just can't find what I am looking for.
I have Equinox and want to run Spring in it (bootstraped in Servlet).
I can't use dm-server, nor can I use the http-bridge, just plain standalone Equinox.
On the other side, using plugin.xml http registry servlet extension is not good enough, since I need the fully-blown web.xml in order to bootstrap Spring.
Where should I dig?
Thanks!
Baruch.
To support "traditional" (aka legacy) web.xml file for webapp deployment you need an implementation of the OSGi Web Applications spec, part of the OSGi R4.2 Enterprise spec. This will allow you to deploy "Web Application Bundles" (WABs) or even plain old WAR files.
There are implementations of this container in both the Eclipse Gemini and Apache Aries projects. Note that the one found in Eclipse Gemini is also found in Eclipse Virgo (the new name for dm Server). You may find that using Virgo will give you a cleaner out-of-the-box experience rather than having to assemble components yourself. Then again I fully understand if it also provides an awful lot more than you really want!
An alternative to this is to move away from web.xml and to register servlets programmatically with the OSGi HttpService. This should be a lot more lightweight, but I don't know whether it will work for "bootstrapping Spring" — quite a vague requirement.
Or you can use the tomcat OSGi bundle that will make you to be able to load bundles as war files. The problem there is that your web bundle's name must end with ".war" and all that stands before that suffix is the application name. So if your bundle's name is myapp.war you connect to it with http://your.server.cc/myapp (and as far as i know there's no way to change that)

Resources