Giter VIP home page Giter VIP logo

pro-spring-5's Introduction

Apress Source Code

This repository accompanies [Pro Spring 5th Edition](http://www.apress.com/9781484228074) by Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho (Apress, 2017).

Cover image

Download the files as a zip using the green button, or clone the repository to your machine using Git.

Requirements

To be able to execute 'gradle clean build -x test' successfully you need at least Java 8 installed.

The AspectJ plugin in module 'chapter05:aspectj-aspects' requires Gradle 4.0.

Releases

Release v1.0 corresponds to the code in the published book, without corrections or updates.

Corrections

For corrections to the content in the published book, see the file errata.md.

Contributions

See the file Contributing.adoc for more information on how you can contribute to this repository.

Building and Deploying

This is a Gradle multi-module project. Currently it can be compiled with Gradle 5.x and JDK 8. Build it from scratch using:

gradle clean build

Build it without tests using:

gradle build -x test

Build it and copy dependencies into build/libs using:

gradle clean build copyDependencies

pro-spring-5's People

Contributors

inponomarev avatar iuliana avatar markp88 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pro-spring-5's Issues

Error running "gradle clean build"

I cloned the repo and ran the above command and got the below error -
What went wrong:
A problem occurred configuring project ':chapter05:aspectj-aspects'.

Could not resolve all files for configuration ':chapter05:aspectj-aspects:classpath'.
Could not resolve nl.eveoh:gradle-aspectj:1.6.
Required by:
project :chapter05:aspectj-aspects
> Could not resolve nl.eveoh:gradle-aspectj:1.6.
> Could not get resource 'https://maven.eveoh.nl/content/repositories/releases/nl/eveoh/gradle-aspectj/1.6/gradle-aspectj-1.6.pom'.
> Could not GET 'https://maven.eveoh.nl/content/repositories/releases/nl/eveoh/gradle-aspectj/1.6/gradle-aspectj-1.6.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Gradle error

Hi, I am unable to build the repo, I am getting this error:

Build file '/home/pro-spring-5/chapter02/chapter02.gradle' line: 7

A problem occurred evaluating project ':chapter02'.
> Could not get unknown property 'compile' for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.

Error with JUnit

Could not find method useJUnitPlatform() for arguments [] on task ':chapter13:junit5-test:test' of type org.gradle.api.tasks.testing.Test.

This is the very first setup with IntelliJ.

Inconsistency with Book

Here the problem is while casting args0, normally you should be casting the argument: objects[0] (which is correct in github code)
screenshot

Chapter5 - NamePointcutUsingAdvisor

Hey,

Inside the code (chapter05==>simple-name-matching), you have overriding:

NameMatchMethodPointcutAdvisor advisor = new NameMatchMethodPointcutAdvisor(new SimpleAdvice());
advisor.setMappedNames("sing");
advisor.setMappedNames("rest"); ==> replace all methods above

BTW, In the book (Pro Spring 5 - Fifth Edition), the code is a little bit different than in repo and doesn't work with the intention (maybe errata was created hard to say).

BR,
Rafał

How to import to Spring STS.

I want to import demo projects to Spring STS.
I have tried various methods that I learned through googling.
But, all failed.
Do i have to use IDEA?
I wonder if you can help me.
Good day!

Error in Chapter 3 - AnnotatedBeanNaming

Without annotating Award with

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)

The AnnotatedBeanNaming class will fail with:

An exception occured while executing the Java class. Unexpected exception parsing XML document from class path resource [spring/app-context-annotated.xml]; nested exception is org.springframework.core.annotation.AnnotationConfigurationException: @AliasFor declaration on attribute 'name' in annotation [com.apress.prospring5.ch3.annotated.Trophy] declares an alias for attribute 'value' in meta-annotation [com.apress.prospring5.ch3.annotated.Award] which is not meta-present. -> [Help 1]

Lack of javadocs with usage of gradle wrapper

Hi,
I'm reading your book :) and want to use your code in action and It's working but I'm facing another issue that I can't get any javadocs from jars (I'm talking about spring jars, not JDK). I tried to add this code

apply plugin: 'java'
apply plugin: 'idea'

idea {
    module {
        downloadJavadoc = true
        downloadSources = true
    }
}

to many build.gradle files also to the one with the highest hierarchy but I don't see any javadocs, for example when I want to see javadoc to annotation @SpringBootApplication I only see:

org.springframework.boot.autoconfigure @Target({ElementType.TYPE}) 

    @Retention(RetentionPolicy.RUNTIME) 
    @Documented 
    @Inherited 
    @SpringBootConfiguration 
    @EnableAutoConfiguration 
    @ComponentScan(excludeFilters = {@org.springframework.context.annotation.ComponentScan.Filter(type = org.springframework.context.annotation.FilterType.CUSTOM, classes = {org.springframework.boot.context.TypeExcludeFilter.class}),@org.springframework.context.annotation.ComponentScan.Filter(type = org.springframework.context.annotation.FilterType.CUSTOM, classes = {org.springframework.boot.autoconfigure.AutoConfigurationExcludeFilter.class})}) 
    public interface SpringBootApplication
    extends annotation.Annotation

      Gradle: org.springframework.boot:spring-boot-autoconfigure:2.0.6.RELEASE

but not documentation itself

chapter04/property-editors/src/main/java/com/apress/prospring5/ch4/PropertyEditorBean.java 运行错误

chapter04/property-editors/src/main/java/com/apress/prospring5/ch4/PropertyEditorBean.java 运行报错

public static class CustomPropertyEditorRegistrar implements PropertyEditorRegistrar { 
        @Override
        public void registerCustomEditors(PropertyEditorRegistry registry) {
            SimpleDateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy");
            registry.registerCustomEditor(Date.class, 
                     new CustomDateEditor(dateFormatter, true));

            registry.registerCustomEditor(String.class, new StringTrimmerEditor(true));
        }
    }

修改为如下形式

@Override
public void registerCustomEditors(PropertyEditorRegistry registry) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    registry.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));

    registry.registerCustomEditor(String.class, new StringTrimmerEditor(true));

    registry.registerCustomEditor(InputStream.class,
            new InputStreamEditor(new ResourceEditor(new FileSystemResourceLoader(), null, true)));
}

原因是因为默认读取文件路径为classpath路径下的文件,但是主程序创建的文件在临时目录下,所以会出现找不到文件的错误。

Chapter 12 Using Spring Remoting / Section RESTful-WS with Spring Boot

The project is boot-rest. The current test code (RestClientTest) doesn't work because the server security, all the test cases are getting 401. To fix that, I have added the following code

@before
public void setUp() {
// restTemplate = new RestTemplate();
RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder();
restTemplate = restTemplateBuilder.basicAuthorization("admin", "admin").build();

}

And I also add a application.properties file with following lines:

spring.security.user.name=admin
spring.security.user.password=admin

The the test code works for the non-modification ones (testFindAll, testFindById), but testCreate, testDelete, testUpdate are still getting 401. I couldn't quite figure it out why.

Then I had to change approach changing the @SpringBootApplication annotation to exclude the Security Configuration.

@SpringBootApplication(scanBasePackages = "com.apress.prospring5.ch12",
exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}

)

This time everything works. But I would like to know why the first approach doesn't work for the modification types, what's missing?

Code will not compile

updated spring resources to current version since it first complained about that. Then still getting:

This project is a collection of simple code samples. It is meant to be used tog
ether with the "Spring Pro, Fifth Edition" published by Apress in order to lear
n and practice with all Spring Web libraries.

FAILURE: Build failed with an exception.

  • Where:
    Build file 'C:\Users\anderjh\Downloads\pro-spring-5-master\chapter02\hello-world
    \build.gradle' line: 7

  • What went wrong:
    A problem occurred evaluating project ':chapter02:hello-world'.

Could not resolve all files for configuration ':chapter02:hello-world:compile'
.
Could not resolve ch.qos.logback:logback-classic:1.2.3.
Required by:
project :chapter02:hello-world
> Could not resolve ch.qos.logback:logback-classic:1.2.3.
> Could not get resource 'https://repo.maven.apache.org/maven2/ch/qos/l
ogback/logback-classic/1.2.3/logback-classic-1.2.3.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/ch/qos/logback
/logback-classic/1.2.3/logback-classic-1.2.3.pom'.
> sun.security.validator.ValidatorException: PKIX path building f
ailed: sun.security.provider.certpath.SunCertPathBuilderException: unable to fin
d valid certification path to requested target
> Could not resolve ch.qos.logback:logback-classic:1.2.3.
> Could not get resource 'https://repo.spring.io/libs-snapshot/ch/qos/l
ogback/logback-classic/1.2.3/logback-classic-1.2.3.pom'.
> Could not GET 'https://repo.spring.io/libs-snapshot/ch/qos/logback
/logback-classic/1.2.3/logback-classic-1.2.3.pom'.
> sun.security.validator.ValidatorException: PKIX path building f
ailed: sun.security.provider.certpath.SunCertPathBuilderException: unable to fin
d valid certification path to requested target
> Could not resolve ch.qos.logback:logback-classic:1.2.3.
> Could not get resource 'https://repo.spring.io/libs-milestone/ch/qos/
logback/logback-classic/1.2.3/logback-classic-1.2.3.pom'.
> Could not GET 'https://repo.spring.io/libs-milestone/ch/qos/logbac
k/logback-classic/1.2.3/logback-classic-1.2.3.pom'.
> sun.security.validator.ValidatorException: PKIX path building f
ailed: sun.security.provider.certpath.SunCertPathBuilderException: unable to fin
d valid certification path to requested target
Could not resolve org.springframework:spring-core:5.0.2.RELEASE.
Required by:
project :chapter02:hello-world > org.springframework:spring-context:5.0
.2.RELEASE
project :chapter02:hello-world > org.springframework:spring-context:5.0
.2.RELEASE > org.springframework:spring-aop:5.0.2.RELEASE
project :chapter02:hello-world > org.springframework:spring-context:5.0
.2.RELEASE > org.springframework:spring-beans:5.0.2.RELEASE
project :chapter02:hello-world > org.springframework:spring-context:5.0
.2.RELEASE > org.springframework:spring-expression:5.0.2.RELEASE
> Could not resolve org.springframework:spring-core:5.0.2.RELEASE.
> Could not get resource 'https://repo.maven.apache.org/maven2/org/spri
ngframework/spring-core/5.0.2.RELEASE/spring-core-5.0.2.RELEASE.pom'.
> Could not HEAD 'https://repo.maven.apache.org/maven2/org/springfra
mework/spring-core/5.0.2.RELEASE/spring-core-5.0.2.RELEASE.pom'.
> sun.security.validator.ValidatorException: PKIX path building f
ailed: sun.security.provider.certpath.SunCertPathBuilderException: unable to fin
d valid certification path to requested target
> Could not resolve org.springframework:spring-core:5.0.2.RELEASE.
> Could not parse POM http://repo.spring.io/release/org/springframework
/spring-core/5.0.2.RELEASE/spring-core-5.0.2.RELEASE.pom
> Could not resolve io.netty:netty-bom:4.1.17.Final.
> Could not resolve io.netty:netty-bom:4.1.17.Final.
> Could not get resource 'https://repo.maven.apache.org/maven2
/io/netty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/io/ne
tty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> sun.security.validator.ValidatorException: PKIX path b
uilding failed: sun.security.provider.certpath.SunCertPathBuilderException: unab
le to find valid certification path to requested target
> Could not resolve io.netty:netty-bom:4.1.17.Final.
> Could not get resource 'https://repo.spring.io/libs-snapshot
/io/netty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> Could not GET 'https://repo.spring.io/libs-snapshot/io/ne
tty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> sun.security.validator.ValidatorException: PKIX path b
uilding failed: sun.security.provider.certpath.SunCertPathBuilderException: unab
le to find valid certification path to requested target
> Could not resolve io.netty:netty-bom:4.1.17.Final.
> Could not get resource 'https://repo.spring.io/libs-mileston
e/io/netty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> Could not GET 'https://repo.spring.io/libs-milestone/io/n
etty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> sun.security.validator.ValidatorException: PKIX path b
uilding failed: sun.security.provider.certpath.SunCertPathBuilderException: unab
le to find valid certification path to requested target
> Could not resolve org.springframework:spring-core:5.0.2.RELEASE.
> Could not get resource 'https://repo.spring.io/libs-snapshot/org/spri
ngframework/spring-core/5.0.2.RELEASE/spring-core-5.0.2.RELEASE.pom'.
> Could not HEAD 'https://repo.spring.io/libs-snapshot/org/springfra
mework/spring-core/5.0.2.RELEASE/spring-core-5.0.2.RELEASE.pom'.
> sun.security.validator.ValidatorException: PKIX path building f
ailed: sun.security.provider.certpath.SunCertPathBuilderException: unable to fin
d valid certification path to requested target
> Could not resolve org.springframework:spring-core:5.0.2.RELEASE.
> Could not parse POM http://repo.spring.io/milestone/org/springframewo
rk/spring-core/5.0.2.RELEASE/spring-core-5.0.2.RELEASE.pom
> Could not resolve io.netty:netty-bom:4.1.17.Final.
> Could not resolve io.netty:netty-bom:4.1.17.Final.
> Could not get resource 'https://repo.maven.apache.org/maven2
/io/netty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/io/ne
tty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> sun.security.validator.ValidatorException: PKIX path b
uilding failed: sun.security.provider.certpath.SunCertPathBuilderException: unab
le to find valid certification path to requested target
> Could not resolve io.netty:netty-bom:4.1.17.Final.
> Could not get resource 'https://repo.spring.io/libs-snapshot
/io/netty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> Could not GET 'https://repo.spring.io/libs-snapshot/io/ne
tty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> sun.security.validator.ValidatorException: PKIX path b
uilding failed: sun.security.provider.certpath.SunCertPathBuilderException: unab
le to find valid certification path to requested target
> Could not resolve io.netty:netty-bom:4.1.17.Final.
> Could not get resource 'https://repo.spring.io/libs-mileston
e/io/netty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> Could not GET 'https://repo.spring.io/libs-milestone/io/n
etty/netty-bom/4.1.17.Final/netty-bom-4.1.17.Final.pom'.
> sun.security.validator.ValidatorException: PKIX path b
uilding failed: sun.security.provider.certpath.SunCertPathBuilderException: unab
le to find valid certification path to requested target
> Could not resolve org.springframework:spring-core:5.0.2.RELEASE.
> Could not get resource 'https://repo.spring.io/libs-milestone/org/spr
ingframework/spring-core/5.0.2.RELEASE/spring-core-5.0.2.RELEASE.pom'.
> Could not HEAD 'https://repo.spring.io/libs-milestone/org/springfr
amework/spring-core/5.0.2.RELEASE/spring-core-5.0.2.RELEASE.pom'.
> sun.security.validator.ValidatorException: PKIX path building f
ailed: sun.security.provider.certpath.SunCertPathBuilderException: unable to fin
d valid certification path to requested target

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug
    option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 10s

NamePointcutUsingAdvisor

com.apress.prospring5.ch5.NamePointcutUsingAdvisor should add proxy method names:
NameMatchMethodPointcutAdvisor advisor = new NameMatchMethodPointcutAdvisor(new SimpleAdvice());
advisor.setMappedNames("sing","rest");

Small type in Chapter 3

In chapter 3, on page 87, there is a small type.

It should be "For abstractLookupBean..." instead of "For abstract-LookupBean...".

And on page 89, It should be "@component("singer")" instead of "@component("singer") (missing closing quote).

Spring use Computer name instead of supplied username for jdbc database access

Reading Pro Spring 5, an example that show Spring JDBC is using MySQL DB. I use the book source code. Here is the code

@Configuration
@PropertySource("classpath:db/jdbc2.properties")
@ComponentScan(basePackages = "com.apress.prospring5.ch6")
public class AppConfig {

    private static Logger logger = LoggerFactory.getLogger(AppConfig.class);
    @Value("${driverClassName}")
    private String driverClassName;
    @Value("${url}")
    private String url;
    @Value("${username}")
    private String username;
    @Value("${password}")
    private String password;

@Bean(destroyMethod = "close")
    public DataSource dataSource() {
        try {
            BasicDataSource dataSource = new BasicDataSource();
            dataSource.setDriverClassName(driverClassName);
            dataSource.setUrl(url);
            dataSource.setUsername(username);
            dataSource.setPassword(password);
            return dataSource;
        } catch (Exception e) {
            logger.error("DBCP DataSource bean cannot be created!", e);
            return null;
        }
    }

jdbc2.properties

driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/musicdb?useSSL=true
username=prospring5
password=prospring5

The test

public class AnnotationJdbcTest {

    private GenericApplicationContext ctx;
    private SingerDao singerDao;

    @Before
    public void setUp() {
        ctx = new AnnotationConfigApplicationContext(AppConfig.class);
        singerDao = ctx.getBean(SingerDao.class);
        assertNotNull(singerDao);
    }

    @Test
    public void testFindAll() {
        List<Singer> singers = singerDao.findAll();
        assertTrue(singers.size() == 3);
        listSingers(singers);
        ctx.close();
    }

My MySQL instance already have the user prospring5 and the schema created and populated

image
image

When I try to run AnnotationJdbcTest, I get this exception:

Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'Mehdi'@'localhost' (using password: YES))
org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'Mehdi'@'localhost' (using password: YES))
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:612)

As you can see the project is using my computer name 'Mehdi' instead of the one in the .properties file 'prospring5' . Why is That? and how Can I fix it?

the project is: chapter6/spring-jdbc-annotations

Chapter 5 section "Creating Throws Advice"

Hello Iuliana,

In your book Spring Pro5 you have one sentence:
"In the situation where your after-throwing advice has two afterThrowing() methods, both declared with the same Exception type but one with with a single argument and the other with four arguments, Spring invokes the four-argument afterThrowing() method."

I've checked this situation and it seems that it works the other way around (under certain conditions).

Source code:

public class SimpleThrowsAdvice implements ThrowsAdvice {
    public static void main(String[] args) throws Exception {
        ErrorBean errorBean = new ErrorBean();
        ProxyFactory pf = new ProxyFactory();
        pf.setTarget(errorBean);
        pf.addAdvice(new SimpleThrowsAdvice());
        ErrorBean proxy = (ErrorBean) pf.getProxy();
        try {
            proxy.errorProneMethod();
        } catch (Exception ignored) {
        }
        try {
            proxy.otherErrorProneMethod();
        } catch (Exception ignored) {
        }
    }
    public void afterThrowing(Exception ex) throws Throwable {
        System.out.println("***");
        System.out.println("One argument");
        System.out.println(ex.getMessage() + " Captured");
        System.out.println("***\n");
    }
    public void afterThrowing(Method method, Object[] args,
                              Object target, Exception ex) throws Throwable {
        System.out.println("***");
        System.out.println("Four arguments");
        System.out.println(ex.getMessage() + " Captured");
        System.out.println("***\n");
    }
    public void afterThrowing(Method method, Object[] args, Object target,
                              IllegalArgumentException ex) throws Throwable {
        System.out.println("***");
        System.out.println("IllegalArgumentException Capture");
        System.out.println("Caught: " + ex.getClass().getName());
        System.out.println("Method: " + method.getName());
        System.out.println("***\n");
    }
}

Output:
`***
One argument
Generic Exception Captured



IllegalArgumentException Capture
Caught: java.lang.IllegalArgumentException
Method: otherErrorProneMethod
***`

What is more when we change the order of afterThrowing methods then it works as you mentioned in the book.

Is it a bug in Spring?

Thanks in advance,

BR,
Rafał Nowicki

Chapter 12 Using Spring Remoting -- Section: Spring Boot Artemis Starter

The code sample in this section doesn't seem to work (boot-jms). And seems it's complaining about the JTA is not set. I have tried a couple of things but couldn't make it work, please check. Thanks!

_Exception in thread "main" org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is com.atomikos.jms.AtomikosTransactionRequiredJMSException: The JMS session you are using requires a JTA transaction context for the calling thread and none was found.
Please correct your code to do one of the following:

  1. start a JTA transaction if you want your JMS operations to be subject to JTA commit/rollback, or
  2. increase the maxPoolSize of the AtomikosConnectionFactoryBean to avoid transaction timeout while waiting for a connection, or
  3. create a non-transacted session and do session acknowledgment yourself, or
  4. set localTransactionMode to true so connection-level commit/rollback are enabled.
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:311)
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:185)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:507)
    at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:584)
    at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:661)
    at com.apress.prospring5.ch12.Application.main(Application.java:46)
    Caused by: com.atomikos.jms.AtomikosTransactionRequiredJMSException: The JMS session you are using requires a JTA transaction context for the calling thread and none was found.
    Please correct your code to do one of the following:
  5. start a JTA transaction if you want your JMS operations to be subject to JTA commit/rollback, or
  6. increase the maxPoolSize of the AtomikosConnectionFactoryBean to avoid transaction timeout while waiting for a connection, or
  7. create a non-transacted session and do session acknowledgment yourself, or
  8. set localTransactionMode to true so connection-level commit/rollback are enabled.
    at com.atomikos.jms.AtomikosTransactionRequiredJMSException.throwAtomikosTransactionRequiredJMSException(AtomikosTransactionRequiredJMSException.java:23)
    at com.atomikos.jms.ConsumerProducerSupport.enlist(ConsumerProducerSupport.java:90)
    at com.atomikos.jms.AtomikosJmsMessageProducerProxy.send(AtomikosJmsMessageProducerProxy.java:34)
    at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:634)
    at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:608)
    at org.springframework.jms.core.JmsTemplate.lambda$send$3(JmsTemplate.java:586)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:504)
    ... 3 more_

error: package javax.annotation is not visible

Hi,

I'm hoping to get help with this error on building the project pro-spring-5 gradle --refresh-dependencies clean build -x test :

This project is a collection of simple code samples. It is meant to be used together with the "Spring Pro, Fifth Edition" published by Apress in order to learn and practice with all Spring Web libraries.

Task :chapter02:hello-world:compileJava
Note: /Users/viet/git/pro-spring-5/chapter02/hello-world/src/main/java/com/apress/prospring5/ch2/decoupled/MessageSupportFactory.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Task :chapter03:collections:compileJava FAILED
/Users/viet/git/pro-spring-5/chapter03/collections/src/main/java/com/apress/prospring5/ch3/annotated/CollectionInjection.java:13: error: package javax.annotation is not visible
import javax.annotation.Resource;
^
(package javax.annotation is declared in module java.xml.ws.annotation, which is not in the module graph)
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':chapter03:collections:compileJava'.
    Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 29s
155 actionable tasks: 25 executed, 130 up-to-date

Using AbstractAnnotationConfigDispatcherServletInitializer to configure multiple DispatcherServlet

In Chapter 16 of Pro Spring 5, quote, "In a Spring MVC application, there can be any number of DispatcherServlet
instances for various purposes." Most of the Spring MVC example codes in the book use a class extending AbstractAnnotationConfigDispatcherServletInitializer to configure a DispatcherServlet. May I ask if and how multiple DispatcherServlets can be configured using a class extending AbstractAnnotationConfigDispatcherServletInitializer? Or how to configure multiple DispatcherServlets with Java-based configuration class? I googled and checked the reference on Spring website and failed to find the answer. Thank you!

Small typos in Chapter 7

It seems that some old example that envolved contact/telephone database was not fully adapted for singers-albums database example.

  • p. 373 'the statement from Singer s simply retrieves all contacts from database' should be 'all singers from database'
  • p. 375 'findAllWithAlbum() method will retrieve all contact information together with their telephone details and hobbies' should be 'all singer information together with their albums and instruments'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.