I want to create an enterprise project (with EAR packaging) with following modules:
1.) I want to have my Spring beans in the EJB module.
2.) The Vaadin application should be the web module.
Now I have everything in one web project. I have the spring bean configuration in the applicationContext.xml. In the web.xml the application context is configured to get loaded. How can I move the spring beans and the context configuration into the EJB module and deal only with the Vaadin UI in the web module, having the beans automatically injected into my custom components? Thanks for your help.
Consider the Spring Stuff Vaadin add-on for help with Spring and Vaadin.
Disclaimer: I'm the author
Related
I setup Camunda in my Spring 3 project (Tomcat server) using this guide. I embedded the workflow engine in my project.
However, I cannot access the cockpit when I go to the url http://localhost:8080/camunda/app/. I get a 404 error.
I see that there is a dependency to be added in case of Spring boot according to this guide
But I see no such dependencies available for Spring. Do we not get access to webapps while integrating Camunda with Spring?
Also asked this question in the camunda form: https://forum.camunda.org/t/integrating-camunda-webapps-in-spring-framework/27661
You'll need the following dependency.
<dependency>
<groupId>org.camunda.bpm.webapp</groupId>
<artifactId>camunda-webapp-webjar</artifactId>
</dependency>
Then ensure you have the required configurations. Refer the spring boot auto configuration set up here and the web app initialiser here.
we have a Spring boot App that is a Rest Service, it has several microservice to attend other app in our environment, but now we need to create a web app for administrative purpose, so we were thinking of expanding this project making it a multi module project so it can share the repository and other utilities that they will have in common.
the only thing we have concerns is about the spring security config, it is possible that each module has their own security config and still be a single executable jar?
You can make. Maven or Gradle multi-module project. Common code will be a module without executable. Then you can import that module in all the others.
Yes, different modules can have different security config class.
How can I control in my Spring 2.1.4 Boot application (packaged as a WAR) whether I am creating a servlet 3.1 or 4.0 web application. Normally, when using a web.xml web application descriptor, the attributes on the web-app would announce the version of the spec being used. In a Spring WebApplicationInitializer application without a web.xml (which is my case), there is no such advertisement.
Is it just a matter of using only the servlet 3.1 features and deploying them to a container and hope that it works?
The web.xml file is optional since Servlet 3 and Java EE 6 where annotations such as #WebServlet, #WebFilter, #WebListener were introduced.
However, there is no way to declare this information outside the web.xml using the WebApplicationInitializer so you have to include the file anyway and specify the version.
After more than a year of posting this question I discovered that maven makes such determination by the presence of the specific API declared as a dependency. For example if you have the javax.servlet:javax.servlet-api:4.0.1 dependency in your Pom file maven will assume a servlet 4.0 container. I believe Spring boot does not support this but I think it should. As a sidenote the M2eclipse plug-in also works this way
I have a multi module Maven project. One of the modules is Spring backend that has DAOs, transactional services and REST controllers for some angular clients (Ionic framework)
Now I find the need to add a new Wicket module for a web client. This module uses the first module as a dependency. When I start the Wicket application the Spring context gets started from the dependency and the REST interface is available for the ionic clients. My issue is that I cannot tie the Wicket application to that existing Spring context. Wicket just wants to start a new Spring context with the same beans.
Now I can access the beans through some static methods from the spring context, but I want to use the #SpringBean annotation as in a regular Wicket+Spring application.
Is there a solution for this?
Thank you!
Wicket does not start any Spring context, as long as you don't instruct it to do so. Are you using the filter init-param "contextConfigLocation"?
When you just register a Spring injector inside your application, it should pick up the default Spring web context (it uses Spring's WebApplicationContextUtils#getRequiredWebApplicationContext()):
getComponentInstantiationListeners().add(new SpringComponentInjector(this));
If I understand correctly, your Spring backend is a web application, not just a java module. You cannot not (should not) have this web application as a dependency to an other web application (your new Wicket module).
You should probably move your shared business logic in a new java module. This new java module can be a dependency of your 2 web applications (Spring backend and Wicket).
An other solution would be to have 3 web applications. Spring facade, Wicket facade and Spring backend. Spring facade and Wicket facade, would just be some simple REST Controller which would redirect the request to the Spring backend to execute the business logic.
I am using Spring to manage my DAO & Services. And JSF for UI. I want to use dependency injection in my JSF backing-bean. There is an article that explained how I can do that.
But I have two separate projects: one for Service and one for UI. The Spring configuration file is located in Service project.
How can I connect both project with Spring? I want to annotate my JSF pages for DI.
You can achieve this by using Spring Web Flow.
Spring have examples which show:
A JSF centric approach where your Spring and JSF beans are managed/configured the JSF way (faces-config) and a
Spring centric approach where your beans (including ManagedBeans) are managed in the Spring Context.
See Spring Flow Web Home
If you mean that you have one WAR with web services defined in it, and another separate WAR with the JSF stuff, I think it's really two separate projects each with their own Spring configuration.
The web service WAR will use either Spring web services or perhaps HTTP remoting to expose your service interfaces to clients via HTTP. This will have one set of application context configuration, either XML or annotations.
The JSF WAR will have the JSPs and controllers. The controllers will be injected with clients that will interact with the remote services to accomplish what you wish. That's all they need to know about the service WAR. There doesn't need to be any duplication of configuration at all.
It's actually a nice design, because it completely decouples the view from the rest of the problem.
Thank for everyone I did it. My mistake was with bean initialization. I tried to access my injected bean in constructor, but must must did in #PostConstruct method. And all that time i tried to find mistake in my config file. But it was in such simply place :)
I find some solution one:
Sample Application using JSF, Spring 2.5, and Java Persistence APIs with Glassfish v2
. But I have problem with it.
I can post this problem hear or must create new topic? Sorry for stupid question, i'm newbie her.