- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 Java/Spring/ Apache Cxf
上工作网络应用程序,突然间,当我进行了一些明显幼稚的更改时出现错误,
25-Aug-2017 11:48:43.036 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
log4j:WARN No appenders could be found for logger (org.apache.cxf.common.logging.LogUtils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
25-Aug-2017 11:48:43.540 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
25-Aug-2017 11:48:43.554 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
[2017-08-25 11:48:43,586] Artifact jaxrs-tutorials:war exploded: Error during artifact deployment. See server log for details.
25-Aug-2017 11:48:49.258 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/Applications/Tomcat-8.5.16/webapps/manager]
25-Aug-2017 11:48:49.310 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/Applications/Tomcat-8.5.16/webapps/manager] has finished in [51] ms
info
的错误,
25-Aug-2017 11:48:43.540 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
25-Aug-2017 11:48:43.554 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
config
目录用于
Java annotation based config
下面提供了代码。
AppConfig
文件,
@Configuration
@ComponentScan(AppConfig.SERVICE_PACKAGE)
public class AppConfig {
public static final String BASE_PACKAGE = "mobi.puut";
public static final String SERVICE_PACKAGE = BASE_PACKAGE + ".services";
private static final String RESOURCES_PACKAGE = BASE_PACKAGE + ".rest";
private static final String PROVIDER_PACKAGE = BASE_PACKAGE + ".rest.provider";
public static final String API_BASE = "/api/*";
@ApplicationPath("/")
public class JaxRsApiApplication extends Application {
}
@Bean(destroyMethod = "shutdown")
public SpringBus cxf() {
return new SpringBus();
}
@Bean
@DependsOn("cxf")
public Server jaxRsServer(ApplicationContext appContext) {
JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint(jaxRsApiApplication(), JAXRSServerFactoryBean.class);
factory.setServiceBeans(restServiceList(appContext));
factory.setAddress("/" + factory.getAddress());
factory.setProviders(restProviderList(appContext, jsonProvider()));
return factory.create();
}
@Bean
public JaxRsApiApplication jaxRsApiApplication() {
return new JaxRsApiApplication();
}
@Bean
public JacksonJsonProvider jsonProvider() {
return new JacksonJsonProvider();
}
private List<Object> restServiceList(ApplicationContext appContext) {
return RestServiceBeanScanner.scan(appContext, AppConfig.RESOURCES_PACKAGE);
}
private List<Object> restProviderList(final ApplicationContext appContext,
final JacksonJsonProvider jsonProvider) {
final List<Object> providers = RestProviderBeanScanner.scan(appContext, PROVIDER_PACKAGE);
providers.add(jsonProvider);
return providers;
}
}
WebInitializer
提供,
public class WebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.addListener(new ContextLoaderListener(createWebAppContext()));
addApacheCxfServlet(servletContext);
}
private void addApacheCxfServlet(ServletContext servletContext) {
CXFServlet cxfServlet = new CXFServlet();
ServletRegistration.Dynamic appServlet = servletContext.addServlet("CXFServlet", cxfServlet);
appServlet.setLoadOnStartup(1);
Set<String> mappingConflicts = appServlet.addMapping(AppConfig.API_BASE);
}
private WebApplicationContext createWebAppContext() {
AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
appContext.register(AppConfig.class);
return appContext;
}
}
logger
获取更多信息以及我应该在哪里使用它们?此外,任何有关解决问题的见解都会有所帮助。我已经更新了
JAR
带有
mvn clean install
的文件和
mvn idea:idea
命令。
UPDATE
Tomcat Localhost Log
Tomcat Catalina Log
最佳答案
我想写一个关于这个问题的详细答案以及我解决问题所遵循的步骤。
A. 没有足够的日志信息。我查了一下POM
并找到了这个,
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
SLF4J
我刚刚删除了排除 XML 标记以获取更多日志信息。于是,就变成这样了
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'userService' for bean class [mobi.puut.services.UserServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [mobi.puut.services.UserService2Impl]
ConflictingBeanDefinitionException
用于创建具有相同名称的 bean。虽然我对
Spring
有一些经验,我需要用
Apache Cxf
创建一个项目因此,为此目的克隆一个演示项目。他们有一个相同的实体
User
和相同
definition - interface
和相同
implementation
其中。虽然我有
refactored
对于项目中的所有类并且似乎没有明显错误,我仍然有一个问题 - 我保留相同的 bean 名称
"userService
在接口(interface)的 2 个实现中。
User2
实体中的类,
public class User2 {
private Integer id;
private String name;
public User2() {
}
public User2(Integer id, String name) {
this.id = id;
this.name = name;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public String toString() {
return String.format("{id=%s,name=%s}", id, name);
}
}
User
实体中的类,
@Entity
@Table(name = "users")
public class User {
@Id
@Column
@NotNull
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@NotNull
@Column(name = "name")
@Size(min = 5, max = 45, message = "Name must be between 5 and 45 characters.")
private String name;
public User() {
}
public User(int id, String name) {
super();
this.id = id;
this.name = name;
}
public User(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof User)) return false;
User user = (User) o;
if (getId() != user.getId()) return false;
return getName().equals(user.getName());
}
@Override
public int hashCode() {
int result = getId();
result = 31 * result + getName().hashCode();
return result;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}
services
中的接口(interface)目录,
public interface IUserService2 {
Collection<User2> getUsers();
User2 getUser(Integer id);
Response add(User2 user);
}
public interface IUserService {
List<User> getCurrentStatuses();
void create(User user);
List<User> getAllUsers();
}
services
内部接口(interface)的实现指示,
@Service("userService")
public class UserService2Impl implements IUserService2 {
private static Map<Integer, User2> users = new HashMap<Integer, User2>();
static {
users.put(1, new User2(1, "foo"));
users.put(2, new User2(2, "bar"));
users.put(3, new User2(3, "baz"));
}
public UserService2Impl() {
}
@Override
public Collection<User2> getUsers() {
return users.values();
}
@Override
public User2 getUser(Integer id) {
return users.get(id);
}
@Override
public Response add(User2 user) {
user.setId(users.size()+1);
users.put(user.getId(), user);
//do more stuff to add user to the system..
return Response.status(Response.Status.OK).build();
}
}
@Service("userService")
public class UserServiceImpl implements IUserService {
@Autowired
@Qualifier("userDao")
public IUserDao userDao;
public List<User> getCurrentStatuses() {
return userDao.getAllUsers();
}
public void create(User user) {
userDao.saveOrUpdate(user);
}
public List<User> getAllUsers() {
List<User> users = userDao.getAllUsers();
if (Objects.isNull(users)) {
return null;
}
return users;
}
}
error
- 我注释了 2 个具有相同 bean 名称的类
"userService"
.我不得不像这样改变它来为 bean 提供一个不同的名称,
@Service("user2Service")
public class UserService2Impl implements IUserService2 {
// some code
}
ConflictingBeanDefinitionException
由于 2 个 bean 同名,我只需要提供不同的名称。
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService': Unsatisfied dependency expressed through field 'userDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'mobi.puut.database.IUserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=userDao)}
// some consequent error messages not necessay to solve the issue
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'mobi.puut.database.IUserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=userDao)}
UnsatisfiedDependencyException
并说它无法创建名称为
userService
的 bean .好的,这是我拥有并集成到项目中的代码。通过字段表示的 Unsatisfied 依赖,即
userDao
.
userDao
是
IUserDao
的接口(interface)实例它是
@autowired
像这样,
@Autowired
public IUserDao userDao;
@Service("userService")
public class UserServiceImpl implements IUserService {
@Autowired
public IUserDao userDao;
public List<User> getCurrentStatuses() {
return userDao.getAllUsers();
}
public void create(User user) {
userDao.saveOrUpdate(user);
}
public List<User> getAllUsers() {
List<User> users = userDao.getAllUsers();
if (Objects.isNull(users)) {
return null;
}
return users;
}
}
database
中有一个接口(interface)目录和随后为用户实现的界面。接口(interface)名称是
IUserDao
看起来
soemthing like this,
public interface IUserDao {
boolean create(User user);
void saveOrUpdate(User user);
boolean create(List<User> users);
List<User> getAllUsers();
User getById(int id);
}
@Repository("userDao")
public class UserDaoImpl implements IUserDao {
@Autowired
private SessionFactory sessionFactory;
// the HQL queries
}
NoSuchBeanDefinitionException
并且应用程序没有找到
IUserDao
类型(类)的合格 bean .我有所有
HQL
查询在执行
IUserDao
并且代码之前完美运行。
database
层是
NOT
集成到应用程序中。这是
configuration
我用了,
public class WebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.addListener(new ContextLoaderListener(createWebAppContext()));
addApacheCxfServlet(servletContext);
}
private void addApacheCxfServlet(ServletContext servletContext) {
CXFServlet cxfServlet = new CXFServlet();
ServletRegistration.Dynamic appServlet = servletContext.addServlet("CXFServlet", cxfServlet);
appServlet.setLoadOnStartup(1);
Set<String> mappingConflicts = appServlet.addMapping(AppConfig.API_BASE);
}
private WebApplicationContext createWebAppContext() {
AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
// register all the config classes here
appContext.register(AppConfig.class);
return appContext;
}
}
WebInitializer
中集成了无数据库代码。 .我写了一个新类提供了
database connection
的所有信息和
hibernate integration
看起来像,
@Configuration
@EnableWebMvc
@EnableTransactionManagement
@ComponentScan(basePackages = {"mobi.puut.database"})
public class DatabaseConfig {
@Bean
public LocalSessionFactoryBean sessionFactory() {
// mobi.puut.entities
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(dataSource());
sessionFactory.setPackagesToScan(
new String[]{"mobi.puut.entities"});
sessionFactory.setHibernateProperties(hibernateProperties());
return sessionFactory;
}
@Bean
@Autowired
public HibernateTransactionManager transactionManager(
SessionFactory sessionFactory) {
HibernateTransactionManager txManager
= new HibernateTransactionManager();
txManager.setSessionFactory(sessionFactory);
return txManager;
}
@Bean
public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
return new PersistenceExceptionTranslationPostProcessor();
}
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
// dataSource.setUrl("jdbc:mysql://localhost:3306/wallet?createDatabaseIfNotExist=true");
dataSource.setUrl("jdbc:mysql://localhost:3306/Wallet");
dataSource.setUsername("testuser");
dataSource.setPassword("testpassword");
return dataSource;
}
Properties hibernateProperties() {
Properties properties = new Properties();
// properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
return properties;
}
}
WebInitializer
.这是我以前用的代码
registered
之前在
WebInitializer
中的配置,
appContext.register(AppConfig.class);
appContext.register(AppConfig.class, DatabaseConfig.class);
config
目录看起来像,
SUMMERY
i. ConflictingBeanDefinitionException
ii. UnsatisfiedDependencyException
iii. NoSuchBeanDefinitionException
ConflictingBeanDefinitionException
-> 2 个同名 bean
UnsatisfiedDependencyException
-> 有 bean
(= "userDao")
在不正确使用的类中
NoSuchBeanDefinitionException
-> 代码是正确的,但需要在配置中添加 datbase 层,所以
Spring IoC
找到 bean 。
关于java - org.apache.catalina.core.StandardContext.startInternal 一个或多个监听器启动失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45875230/
我在使用以下代码时遇到问题: function http_file_exists($url){ $f=fopen($url,"r"); if($f){ fclose($f); retu
我已经通过 Git 部署到 Azure 几个月了,没有出现重大问题,但现在我似乎遇到了一个无法克服的错误。 我创建了一个新的 Azure 网站,为正在开发的项目创建单独的预览链接。我在新站点上设置了
我已经通过flutter创建了一个App并完成了它,我想在flutter文档中阅读时进行部署。 我收到此错误: FAILURE: Build failed with an exception. * W
我在Windows 10中使用一些简单的Powershell代码遇到了这个奇怪的问题,我认为这可能是我做错了,但我不是Powershell的天才。 我有这个: $ix = [System.Net.Dn
我正在尝试使用 RapidJSON 解析从服务器接收到的数据。以下是收到的确切字符串: [ { "Node": "9478149a08f9", "Address": "172.17
我尝试为 ios 编译 OpenCV。我总是收到这些错误。我用不同版本的opencv试了一下,结果都是一样的。 我运行这个:python 平台/ios/build_framework.py ios_o
我在一台机器上做基本的发布/订阅,我的客户端是 StackExchange-Redis 的 C# 客户端,我在同一台机器上运行基于 Windows 的 Redis 服务器(服务器版本 2.8.4) 当
我有这段代码,但无法执行,请帮我解决这个问题 连接 connect_error) { die ("connection failed: " . $terhubung->connect_erro
我在 tomcat 上运行并由 maven 编译的 Web 应用程序给出了以下警告和错误。我可以在本地存储库中看到所有 JAR,但有人可以帮忙吗。 WARNING: Failed to scan JA
我正在 Windows 8 上使用 Android Studio 开发一个 android 应用程序,我正在使用一些 native 代码。突然间我无法编译我的 C 文件。当我运行 ndk-build
下面的代码对类和结构的成员进行序列化和反序列化。序列化工作正常,但我在尝试使用 oarch >> BOOST_SERIALIZATION_NVP(outObj); 反序列化时遇到了以下错误; 代码中是
如果我运行此命令“rspec ./spec/requests/api/v1/password_reset_request_spec.rb”,此文件中的所有测试都会通过。 但是,当我运行“rspec”时
我在尝试执行测试以使用 Protractor 上传文件时出错,我的代码是这个 it('it should be possible to upload a file', function() {
System.loadLibrary("nativefaceswap"); 当我运行我的应用程序时,我在 Android Studio 中发现了此类错误。在logcat中显示: java.lang.U
我希望有人能帮助我!使用任何方法或命令行的任何 SSL/HTTPS 调用均无效。 我在 Windows 10 中使用 Ubuntu Server 18.04 作为子系统。我的问题是昨天才开始出现的,因
通过删除这两个值将日期字段从 null=True 和 Blank=True 更改为 required 时,使用 db.alter 命令时遇到问题。 当以下行被注释掉时,迁移运行不会出现问题。
我第一次使用 Heroku 尝试创建应用程序(使用 SendGrid 的 Inbound Parse Webhook"和 Twilio SMS 通过电子邮件发送和接收 SMS 消息)。通过 Virtu
我正在将我的 swift 项目更新到 Xcode 7 上的 Swift 2.0。xcode 在构建项目时报告了以下错误: 命令/Applications/Xcode.app/Contents/Deve
在我的代码中,SSL 库函数 SSL_library_init() 没有按预期返回 1。我如何才能看到它返回了什么错误? 我在 SSL_library_init() 之后调用了 SSL_load_er
我正在尝试运行在以下链接中找到的答案: Asynchronously Load the Contents of a Div 但是当我这样做时,我会遇到我不太理解的错误。 我的代码: $(documen
我是一名优秀的程序员,十分优秀!