Spring insecuremvc - sample files location? - spring

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.

Related

Akka with spring and maven

I am trying to use "Akka" model with spring in maven project but i am not able to succeed because i am getting initialization failed error. I would like to know that is it possible to use them together and if it is then let me know.
Sure, we built a whole framework based on akka+spring+maven at my company. Setting it up is a bit tricky, but once configured it works smoothly. You can find a lot of examples online, like http://www.baeldung.com/akka-with-spring, but just by googling 'akka spring example' you will get a few entries.

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

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.

Tapestry class loader with Tomcat and 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.

How to summarize view-components/widgets-information in a JAR-File?

I would like to use an ajax toolkit/framework like ZK (www.zkoss.org) or GWT. But I don't know whether it's possible to bundle resources in a JAR? Do you know which one support such resource loading?
Not sure what your goal is, but if its to bundle a web application into one file, then you can do that with a WAR file - assuming your deploying onto a java webcontainer like tomcat or jboss.
My goal is to summarize the Java-classes and also their Templates-files for the view of various application modules, each in one Java-Jar-File. These modules I use in another application, which of course I summarize in a WAR-File for Deployment. I would like to know which ajax-Framework/Toolkit does support this.
Take a look at http://www.ztemplates.org which is simple and easy to learn. This one allows you to put all related templates, javascript and css into one jar and use it transparently. Means you even have not to care about declaring the needed javascript in your page when using a provided component, as the framework does it for you.

Resources