jaxws-spring maven dependency is for what purpose - spring

I have the following maven dependecy in my project.
<dependency>
<groupId>org.jvnet.jax-ws-commons.spring</groupId>
<artifactId>jaxws-spring</artifactId>
<version>1.8</version>
</dependency>
Question:
Is this Spring Webservices project?
If not what this dependency is for?
Thanks for your help.

It's a project combining JAX-WS and Spring. Basically it gives you the wss namespace that you might be using in your application context to expose JAX-WS providers as web services. It isn't mandatory but it can be a convenience as it allows you to easily have dependency injection in your servlets although there are other ways to get this. Unfortunately, the last time I was using it I noticed that it was depending on some pretty old spring libraries (pre 3.x) and didn't seem to be updated in some time.

Related

maven dependencies for writing Spring AOP programs?

I am trying to learn Spring AOP programming using Spring 5. I am going through online materials.
I came to know that AOP is a concept, similar to OOP; and with AOP,OOPs becomes more powerful.
Now, I am trying to do some hands-on coding for AOP with Spring framework, version 5.
I am going to use maven as the build tool.
I am not clear on what are the various dependencies that we have to use in pom.xml, for example do we need to use: spring-aop , spring-aspects, aspectjetc.
Can anyone guide me what are the various maven dependencies that we have to add in pom.xml to be able to write using maven tool, Spring 5 AOP programs?
Thanks in advance
Its very simple, in order to work spring With AOP, You need aspectjweaver Library existe on the classpath of your application (version 1.6.8 or later).use this dependency to achieve that
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.13</version>
</dependency>
As they mention in docs
To enable #AspectJ support with Java #Configuration add the
#EnableAspectJAutoProxy annotation:
You can find more info here
The only spring dependency to make something work with AOP is the famous spring-context :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
If you want a working example check my project in github which contains basic Maven AOP example based on spring
If you are trying to use CGLIB proxies in Spring without Spring Boot (and any starter dependencies of Spring Boot) then you need aspectjweaver besides spring-context, spring-aop dependencies.
Be careful not to add any of the dependencies if they already exist among your Maven dependencies - adding the same dependency with multiple versions may lead to a failing build.

Spring Boot project depending on a spring project

fair warning: I am new to Spring and maven.
The project:
The client has provided us with a web project that uses jsp to render front ends and uses spring-context only to manage some of their classes as Spring Beans. This project uses xml configuration. Here is the maven section that includes the spring-context:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
Our job is to create an api layer for this project to open up access to the project's resources. The plan is to create a modern Spring Boot api using the spring-boot-web starter.
The problem:
The jsp project is split up into sub-modules. We are trying to take their business logic submodule as a maven dependency in our api project (it defines it's own spring context). The first problem that we have faced occurs when we simply add the module from the jsp project as a dependency in our api project. The spring boot initialization process provides no log feedback and hangs but does not exit (It runs fine when the dependency is not included). When crawling through with a debugger I have found that it is loading configuration files that are in the business module. My thinking is that one of the api's configuration files are getting overwritten which is breaking spring's logging and other behaviors.
The other more general problem is that I don't know if I can use the beans provided in the business logic module in my modern version of spring.
So the question is:
Is there a proper way to use beans defined in a dependent spring project?

Spring framework compatibility between various projects

I am learning Spring framework and while trying "various" sub-projects within this, I got this doubt.
Spring framework has "core spring" at the heart of it. Now, as the project grows, e.g. trying other features like: spring-mvc, spring-web flow , spring security etc. Are all those sub-projects part of same release. For example, if I look for spring 4.0.2 release, would all these sub-projects be included in this? (hence release for various sub-project with same number: 4.0.2).
If this is not correct, then how do we ensure to chose the compatible sub-projects?
Thanks
spring-mvc is part of the spring framework, the others are separate projects following their own versioning. In general there is a minimum version for the projects and most work fine with newer versions.
If you want to be sure use the Spring IO Platform to manage your dependencies.
In your pom add
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>1.1.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Then you can simply add the dependencies (without version) to your dependencies section
<dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
</dependencies>
For a list of managed dependencies (and version) check Appendix A of the reference guide.
Spring framework has "core spring" at the heart of it. Now, as the
project grows, e.g. trying other features like: spring-mvc, spring-web
flow , spring security etc. Are all those sub-projects part of same
release
spring-mvc and spring-web are both individual artifacts that you'll find within a single Spring release. They are versioned together, and you should always use the same version for all of them in any given project.
spring-security, however, is a completely different beast. It sits on top of Spring, but it's versioned completely separately. You need to make sure that the version of Spring Security you use is combined with a compatible version of Spring.

Unit Tests with Jersey 1.17 Test framework

I want to write unit tests for my Resource classes in my Restful Web application.
I am using jersey version 1.17 and using maven 3.0.2. junit 4.8.1.
(Just a background, my web application will be deployed on a Jboss server packaged with other components as an ear.)
Now, I read the Jersey Test framework wiki, but I am unable to find the right set of dependencies to get it working.
There are many versions and artifact and groupIds that are confusing.
Some blogs say
<groupId>com.sun.jersey.test.framework</groupId>
Whereas others say,
<groupId>com.sun.jersey.jersey-test-framework</groupId>
while few say, its changed to
<groupId>com.sun.jersey</groupId>
I am totally confused.
Please help me figure out the right set dependencies required to write a unit test for Resource Classes. I want to use grizzly container. Is it possible?
Thanks in advance.
The Jersey docs for 1.18 say:
Maven developers require a dependency on the
jersey-test-framework-grizzly module. The following dependency needs
to be added to the pom:
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly</artifactId>
<version>1.18</version>
<scope>test</scope>
</dependency>
which looks like it brings in all the dependencies you'll need. EG jersey-test-framework-core

Deploying Simple Spring Hibernate Utility Project via Maven to Tomcat

My goal is understanding the J2EE lifecycle at a high-level with Spring, Hibernate, and Maven. From much research, I understand that Spring provides dependency injection and Hibernate provides object-relation mapping with databases. Maven is a tool to improve the build/deployment process from my understanding. With that said, everywhere I search I get more and more lost on configuration files (i.e. pom.xml, server.xml, etc.), terminology, and alternatives such as Gradle. I just want to build and launch the application and be able to see via http://localhost:8080 in tomcat.
At first, I couldn't get the default project (picture attached) built, but after further research found that I needed to Maven clean and Maven install.
I also modified settings in pom.xml changing version numbers and the database to use MySQL.
<properties>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
<spring.framework.version>3.1.1.RELEASE</spring.framework.version>
</properties>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.1.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
The next issue I had was in OrderPersistenceTests.java it used org.hibernate.classic.Session which is no longer the correct class path and found that it needed to be org.hibernate.Session.
Finally, I was able to get it to build but cannot figure out how to deploy to Tomcat from Spring Tool Suite.
I have put together a simple example using Maven, Spring, Hibernate, and ExtJS for the front end at the following link:
https://github.com/drembert/java-webapp-sample
If you are using Spring Source Tool Suite which it looks like you are in the screen shot, you should be able to import everything using the "Import Maven Projects" option. The example uses Hypersonic as the in-memory DB to allow easier deployment. Keep in mind this example generates two different .war files (one is presentation-layer and the other is service-layer) to emulate a simple RESTful service so both will need to be deployed to the Spring tcServer (STS's version of Tomcat), but once they are you should be able to view the GUI at http://localhost:8080/presentation-layer. Another thing to make note of is that this example currently doesn't have a security layer which would normally be implemented using Spring security, but I am working on adding that in the near future.

Resources