You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/07/06 12:47:54 UTC

[GitHub] [shardingsphere] syhasia opened a new issue #6284: tomcat cannot be started after integrated with sharding-jdbc

syhasia opened a new issue #6284:
URL: https://github.com/apache/shardingsphere/issues/6284


   Hi,
   I integrated sharding-jdbc in my spring boot project, but my application cannot be started. once i comment off sharding-jdbc maven dependency from pom, the application can be started. anyone can help to resolve it?
   
   the pom file:
   
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0"
   		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   	<parent>
   
   		<groupId>org.springframework.boot</groupId>
   		<artifactId>spring-boot-starter-parent</artifactId>
   		<version>2.0.5.RELEASE</version>
   		<relativePath/> <!-- lookup parent from repository -->
   	</parent>
   	<modelVersion>4.0.0</modelVersion>
   
   	<groupId>test</groupId>
   	<artifactId>test</artifactId>
   	<version>1.0-SNAPSHOT</version>
   
   
   	<properties>
   		<!--project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding-->
   		<java.version>1.8</java.version>
   		<mybatis.version>3.4.0</mybatis.version>
   		<mybatis.generator.version>1.3.2</mybatis.generator.version>
   		<mybatis.springboot.version>2.0.1</mybatis.springboot.version>
           <skipTests>true</skipTests>
   	</properties>
   
   	<dependencies>
   
   		<dependency>
   			<groupId>org.mybatis.spring.boot</groupId>
   			<artifactId>mybatis-spring-boot-starter</artifactId>
   			<version>${mybatis.springboot.version}</version>
   		</dependency>
   		<dependency>
   			<groupId>mysql</groupId>
   			<artifactId>mysql-connector-java</artifactId>
   		</dependency>
   
   		<!-- <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-velocity</artifactId>
            </dependency>-->
   		<dependency>
   			<groupId>org.springframework.boot</groupId>
   			<artifactId>spring-boot-starter-data-redis</artifactId>
   		</dependency>
   		<dependency>
   			<groupId>org.apache.shardingsphere</groupId>
   			<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
   			<version>4.0.0-RC1</version>
   		</dependency>
   
   		<dependency>
   			<groupId>org.apache.shardingsphere</groupId>
   			<artifactId>sharding-jdbc-spring-namespace</artifactId>
   			<version>4.0.0-RC1</version>
   		</dependency>
   		<dependency>
   			<groupId>org.springframework.boot</groupId>
   			<artifactId>spring-boot-starter-web</artifactId>
   		</dependency>
   		<!-- <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> 
   			</dependency> -->
   		<dependency>
   			<groupId>org.quartz-scheduler</groupId>
   			<artifactId>quartz</artifactId>
   			<version>2.3.0</version>
   		</dependency>
   		<dependency>
   			<groupId>org.apache.commons</groupId>
   			<artifactId>commons-lang3</artifactId>
   			<version>3.7</version>
   		</dependency>
   
   		<!-- python执行 -->
   		<dependency>
   			<groupId>org.apache.commons</groupId>
   			<artifactId>commons-exec</artifactId>
   			<version>1.3</version>
   		</dependency>
   		<!-- <dependency>
   			<groupId>org.python</groupId>
   			<artifactId>jython-standalone</artifactId>
   			<version>2.7-b1</version>
   		</dependency> -->
   		<!-- redis -->
   		<dependency>
   			<groupId>redis.clients</groupId>
   			<artifactId>jedis</artifactId>
   			<version>2.9.0</version>
   		</dependency>
   		<!-- json -->
   		<dependency>
   			<groupId>net.sf.json-lib</groupId>
   			<artifactId>json-lib</artifactId>
   			<version>2.4</version>
   			<classifier>jdk15</classifier>
   		</dependency>
   		<dependency>
   			<groupId>com.alibaba</groupId>
   			<artifactId>fastjson</artifactId>
   			<version>1.2.7</version>
   		</dependency>
   
   		<dependency>
   			<groupId>mysql</groupId>
   			<artifactId>mysql-connector-java</artifactId>
   			<version>6.0.6</version>
   		</dependency>
   		<dependency>
   			<groupId>com.alibaba</groupId>
   			<artifactId>druid</artifactId>
   			<version>1.1.16</version>
   		</dependency>
   		<dependency>
   			<groupId>commons-codec</groupId>
   			<artifactId>commons-codec</artifactId>
   			<version>1.10</version>
   		</dependency>
   		<dependency>
   			<groupId>jdom</groupId>
   			<artifactId>jdom</artifactId>
   			<version>1.0</version>
   		</dependency>
   		<dependency>
   			<groupId>commons-io</groupId>
   			<artifactId>commons-io</artifactId>
   			<version>2.4</version>
   		</dependency>
   		 <!-- logback -->
           <dependency>
   			<groupId>ch.qos.logback</groupId>
   			<artifactId>logback-core</artifactId>
   		</dependency>
   		<dependency>
   			<groupId>ch.qos.logback</groupId>
   			<artifactId>logback-classic</artifactId>
   		</dependency>
   		<dependency>
   			<groupId>ch.qos.logback</groupId>
   			<artifactId>logback-access</artifactId>
   		</dependency>
   		<dependency>
   			<groupId>org.logback-extensions</groupId>
   			<artifactId>logback-ext-spring</artifactId>
               <version>0.1.4</version>  
   		</dependency>
   		<dependency>
   			<groupId>org.springframework.boot</groupId>
   			<artifactId>spring-boot-starter-test</artifactId>
   			<scope>test</scope>
   		</dependency>
           <dependency>
               <groupId>javax.mail</groupId>
               <artifactId>mail</artifactId>
               <version>1.4.7</version>
           </dependency>
   	</dependencies>
   	
   	<profiles>
           <profile>
               <id>dev</id><!--执行打包命令时将使用此处的id进行定位-->
               <properties>
                   <env>dev</env><!--此处为对应的环境放置配置文件的目录,上一步创建的为dev,这里设置为dev。下面两个目录配置参照此处-->
               </properties>
               <activation>
                   <activeByDefault>true</activeByDefault><!--此处将dev设置为默认环境-->
               </activation>
           </profile>
       </profiles>
       
   	<build>
   		<resources>
               <resource><!--此处的设置是打包的时候排除不相关的目录-->
                   <directory>src/main/resources/env</directory><!--此处设置为上面在resource目录下创建的文件夹-->
                   <excludes>
                       <exclude>dev/*</exclude>
                   </excludes>
                   <filtering>true</filtering><!--开启过滤器,此处不能忽略!-->
               </resource>
               <resource><!--此处的设置是为了将放置于resource文件夹下mybatis的mapper文件正常打包进去,和一些不需要多环境的配置文件-->
                   <directory>src/main/resources</directory><!--如果将mybatis的mapper文件放在dao接口的同目录下,应该将此处设置为src/main/java-->
                   <includes>
                       <include>**/*.xml</include>
                       <include>**/*.json</include>
   					<include>**/*.txt</include>
                       <!--<include>*.properties</include>-->
                   </includes>
                   <filtering>false</filtering><!--此处不需要过滤器过滤-->
               </resource>
               <resource><!--此处设置是配置相应配置文件夹的路径-->
                   <directory>src/main/resources/env/${env}</directory>
               </resource>
           </resources>
   
           <finalName>${project.artifactId}-${project.version}</finalName>
   		
   		<plugins>
   			<plugin>
   				<groupId>org.springframework.boot</groupId>
   				<artifactId>spring-boot-maven-plugin</artifactId>
   				<configuration>
   					<mainClass>test.TaskApplication</mainClass>
   				</configuration>
   				<executions>
   					<execution>
   						<goals>
   							<goal>repackage</goal>
   						</goals>
   					</execution>
   				</executions>
   			</plugin>
   
   			<!-- mybatis generator 自动生成代码插件 maven运行: Golas:mybatis-generator:generate 
   				-e -->
   			<!-- <plugin>
   				<groupId>org.mybatis.generator</groupId>
   				<artifactId>mybatis-generator-maven-plugin</artifactId>
   				<version>1.3.2</version>
   				<configuration>
   					<configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile>
   					<overwrite>true</overwrite>
   					<verbose>true</verbose>
   				</configuration>
   			</plugin> -->
   
   		</plugins>
   	</build>
   </project>
   
   
   
   application.properties
   
   server.port=8080
   server.context-path=/scheduler
   spring.mvc.view.prefix=/WEB-INF/jsp/
   spring.mvc.view.suffix=.jsp
   spring.datasource.url=jdbc:mysql://11.1.1.1:3306/test?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=false
   spring.datasource.username=test
   spring.datasource.password=test
   spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.mail.host=mail.test.com
   spring.mail.username=test@test.com
   spring.mail.password=test
   spring.mail.port=587
   spring.mail.protocol=smtp
   spring.mail.default-encoding=UTF-8
   spring.main.allow-bean-definition-overriding=true
   logging.pattern.level=DEBUG
   spring.shardingsphere.datasource.names=master
   
   # 数据源 主库
   spring.shardingsphere.datasource.master.type=com.alibaba.druid.pool.DruidDataSource
   spring.shardingsphere.datasource.master.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.master.url=jdbc:mysql://11.1.1.1:3306/glodonrobot?characterEncoding=utf-8
   spring.shardingsphere.datasource.master.username=test
   spring.shardingsphere.datasource.master.password=test
   
   #数据分表规则
   #spring.shardingsphere.sharding.tables.user.actual-data-nodes=master.user$->{0..3}
   #指定主键
   #spring.shardingsphere.sharding.tables.user.table-strategy.inline.sharding-column=id
   #分表规则为主键除以3取模
   #spring.shardingsphere.sharding.tables.user.table-strategy.inline.algorithm-expression=user$->{id % 3}#指定所需分的表
   
   
   #打印sql
   spring.shardingsphere.props.sql.show=true
   
   mybatis.mapper-locations=classpath:mapping/*.xml
   mybatis.type-aliases-package=test.task
   pagehelper.helperDialect=mysql
   pagehelper.reasonable=true
   pagehelper.supportMethodsArguments=true
   pagehelper.params=count=countSql
   #log
   #logging.config=classpath:logback-local.xml
   #redis config
   redis.host.ip=11.1.1.1
   redis.port=6379
   redis.password=
   redis.database=0
   redis.max.active=600
   redis.max.wait=1000
   redis.max.idle=3000
   redis.min.idle=0
   
   
   logging.config=classpath:logback.xml
   spring.profiles.active=dev
   
   
   error output:
   
   2020-07-06 20:22:56.601 [INFO ] [main] test.TaskApplication[logStarting:50] - Starting TaskApplication on test with PID 93568 (E:\gitproject\scheduler\target\classes started by test in E:\gitproject\scheduler) 
   2020-07-06 20:22:56.603 [INFO ] [main] test.TaskApplication[logStartupProfileInfo:684] - The following profiles are active: dev 
   2020-07-06 20:22:56.833 [INFO ] [main] o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext[prepareRefresh:590] - Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@dbf57b3: startup date [Mon Jul 06 20:22:56 CST 2020]; root of context hierarchy 
   2020-07-06 20:22:57.510 [INFO ] [main] o.s.d.r.c.RepositoryConfigurationDelegate[multipleStoresDetected:172] - Multiple Spring Data modules found, entering strict repository configuration mode! 
   2020-07-06 20:22:57.928 [INFO ] [main] o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker[postProcessAfterInitialization:326] - Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$54648c5d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
   2020-07-06 20:22:58.523 [INFO ] [main] o.s.b.w.e.tomcat.TomcatWebServer[initialize:91] - Tomcat initialized with port(s): 8080 (http) 
   2020-07-06 20:22:58.536 [INFO ] [main] o.a.coyote.http11.Http11NioProtocol[log:180] - Initializing ProtocolHandler ["http-nio-8080"] 
   2020-07-06 20:22:58.545 [INFO ] [main] o.a.catalina.core.StandardService[log:180] - Starting service [Tomcat] 
   2020-07-06 20:22:58.546 [INFO ] [main] o.a.catalina.core.StandardEngine[log:180] - Starting Servlet Engine: Apache Tomcat/8.5.34 
   2020-07-06 20:22:58.555 [INFO ] [localhost-startStop-1] o.a.c.core.AprLifecycleListener[log:180] - The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_191\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_191;C:\Users\test\Downloads\apache-maven-3.6.2-bin\apache-maven-3.6.2\bin;C:\Users\test\AppData\Local\Microsoft\WindowsApps;C:\Users\test\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\test\AppData\Roaming\npm;C:\Program Files\Java\jdk1.8.0_191;C:\Users\test\Downloads\apache-maven-3.6.2-bin\apache-maven-3.6.2\bin\mvn;;C:\Users\test\AppData\Local\Programs\EmEditor;.] 
   2020-07-06 20:22:58.688 [INFO ] [localhost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/][log:180] - Initializing Spring embedded WebApplicationContext 
   2020-07-06 20:22:58.688 [INFO ] [localhost-startStop-1] o.s.web.context.ContextLoader[prepareWebApplicationContext:285] - Root WebApplicationContext: initialization completed in 1855 ms 
   2020-07-06 20:22:58.745 [INFO ] [localhost-startStop-1] o.s.b.w.s.ServletRegistrationBean[addRegistration:187] - Servlet dispatcherServlet mapped to [/] 
   2020-07-06 20:22:58.748 [INFO ] [localhost-startStop-1] o.s.b.w.s.FilterRegistrationBean[configure:245] - Mapping filter: 'characterEncodingFilter' to: [/*] 
   2020-07-06 20:22:58.749 [INFO ] [localhost-startStop-1] o.s.b.w.s.FilterRegistrationBean[configure:245] - Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 
   2020-07-06 20:22:58.749 [INFO ] [localhost-startStop-1] o.s.b.w.s.FilterRegistrationBean[configure:245] - Mapping filter: 'httpPutFormContentFilter' to: [/*] 
   2020-07-06 20:22:58.749 [INFO ] [localhost-startStop-1] o.s.b.w.s.FilterRegistrationBean[configure:245] - Mapping filter: 'requestContextFilter' to: [/*] 
   2020-07-06 20:22:59.090 [INFO ] [main] c.alibaba.druid.pool.DruidDataSource[init:1002] - {dataSource-1} inited 
   Mon Jul 06 20:22:59 CST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
   2020-07-06 20:22:59.540 [INFO ] [main] o.a.catalina.core.StandardService[log:180] - **Stopping service** [Tomcat] 
   
   Process finished with exit code 1
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yanyzy commented on issue #6284: tomcat cannot be started after integrated with sharding-jdbc

Posted by GitBox <gi...@apache.org>.
yanyzy commented on issue #6284:
URL: https://github.com/apache/shardingsphere/issues/6284#issuecomment-654562890


   Your active profile is dev, may be something wrong with this file
   ```
   2020-07-06 20:22:56.603 [INFO ] [main] test.TaskApplication[logStartupProfileInfo:684] - The following profiles are active: dev
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] syhasia commented on issue #6284: tomcat cannot be started after integrated with sharding-jdbc

Posted by GitBox <gi...@apache.org>.
syhasia commented on issue #6284:
URL: https://github.com/apache/shardingsphere/issues/6284#issuecomment-654572125


   > @syhasia Hi
   > How about commenting the following item out and import `Sharding-Spring-Boot`?
   > 
   > ```
   > <dependency>
   > 		<groupId>org.mybatis.spring.boot</groupId>
   > 		<artifactId>mybatis-spring-boot-starter</artifactId>
   > 		<version>${mybatis.springboot.version}</version>
   > 	</dependency>
   > ```
   
   are you mentioned the following dependency? if yes, i have already added it in my pom file.
                  <dependency>
   			<groupId>org.apache.shardingsphere</groupId>
   			<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
   			<version>4.0.0-RC1</version>
   		</dependency>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] syhasia commented on issue #6284: tomcat cannot be started after integrated with sharding-jdbc

Posted by GitBox <gi...@apache.org>.
syhasia commented on issue #6284:
URL: https://github.com/apache/shardingsphere/issues/6284#issuecomment-654579768


   fix it. the root cause is mybatis version issue, i changed the mybatis version to 2.1.1 to fix it. thanks everyone!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] syhasia commented on issue #6284: tomcat cannot be started after integrated with sharding-jdbc

Posted by GitBox <gi...@apache.org>.
syhasia commented on issue #6284:
URL: https://github.com/apache/shardingsphere/issues/6284#issuecomment-654558688


   used ut and found some error:
   
   Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration': Initialization of bean failed; nested exception is org.apache.shardingsphere.core.exception.ShardingException: Can't find datasource type!
   
   but i have already configured the datasource on application.properites file...


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #6284: tomcat cannot be started after integrated with sharding-jdbc

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #6284:
URL: https://github.com/apache/shardingsphere/issues/6284#issuecomment-654562321


   @syhasia Hi 
   How about commenting the following item out and import `Sharding-Spring-Boot`?
   ```
   <dependency>
   		<groupId>org.mybatis.spring.boot</groupId>
   		<artifactId>mybatis-spring-boot-starter</artifactId>
   		<version>${mybatis.springboot.version}</version>
   	</dependency>
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] syhasia closed issue #6284: tomcat cannot be started after integrated with sharding-jdbc

Posted by GitBox <gi...@apache.org>.
syhasia closed issue #6284:
URL: https://github.com/apache/shardingsphere/issues/6284


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] menghaoranss commented on issue #6284: tomcat cannot be started after integrated with sharding-jdbc

Posted by GitBox <gi...@apache.org>.
menghaoranss commented on issue #6284:
URL: https://github.com/apache/shardingsphere/issues/6284#issuecomment-654339857


   There is no error message about sharding in the log . I guess it's jar conflict. Could you refer to the examples to configure dependency and try again? 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org