简体   繁体   English

在未部署Glassfish的STS中创建的Web应用程序

[英]Web application created in STS with glassfish not deploying

So i have been trying to make this project work for like 4 hours. 所以我一直在努力使这个项目工作4个小时。 So help me with this : I have a project which is a web application that uses as database some xmls ( hence jabx). 因此,请为我提供帮助:我有一个项目,该项目是一个网络应用程序,使用一些xml(也就是jabx)作为数据库。 Now i made it in spring tools suite and everything is up to date ( jdk 1.8 etc.). 现在,我在spring tools套件中做到了,一切都是最新的(jdk 1.8等)。 I use as server glassfish 4.1 and i get this errors when it is trying to run it ( of course there are like 1000 lines of errors but it begins here ) : 我用作服务器glassfish 4.1,尝试运行它时出现此错误(当然有1000行错误,但从这里开始):

    Severe: log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
2016-05-18T01:58:19.498+0300|Severe: log4j:WARN Please initialize the log4j system properly.
2016-05-18T01:58:19.498+0300|Severe: log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2016-05-18T01:58:21.169+0300|Info: null
2016-05-18T01:58:21.211+0300|Severe: Startup of context /Assignement2 failed due to previous errors
2016-05-18T01:58:21.211+0300|Severe: Exception during cleanup after start failed
org.apache.catalina.LifecycleException: Manager has not yet been started

and it continues for ever. 它会永远持续下去 I will make it shorter saying that they refer to 我会简短地说他们指的是

  • "Error creating bean with name " “创建名称为bean的错误”
  • Severe: Exception during lifecycle processing 严重:生命周期处理期间发生异常
  • "Severe: Exception while invoking class com.sun.enterprise.web.WebApplication start method.." “严重:调用类com.sun.enterprise.web.WebApplication启动方法时发生异常。

Also warnings like : "Warning: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina...." 也有类似警告的警告:“警告:java.lang.IllegalStateException:ContainerBase.addChild:开始:org.apache.catalina ....”

Now i guess this happens because of some dependencies or maven or something, because i work on windows , i know that on mac it would be easier, but at the moment i do not have one . 现在我想这是由于某些依赖项或Maven之类的原因而发生的,因为我在Windows上工作,我知道在Mac上会更容易,但是目前我还没有。

I will show you the pom, security, web and everything i use to set up my project. 我将向您展示pom,安全性,网络以及我用于设置项目的所有内容。 What i suspected first was the fact that when i used in the security folder the link for spring security without -4.0, it gave me errors. 我首先怀疑的事实是,当我在安全性文件夹中使用的弹簧安全性链接不带-4.0时,它给了我错误。 After i put -4.0 it worked. 在我输入-4.0之后,它起作用了。 I know it comes from dependencies, but i just wanted to put it out there. 我知道它来自依赖项,但是我只是想把它放在那里。

I can not help with the full log of errors because is very long and is in majority about beans. 我无法提供完整的错误日志,因为它很长,而且大多数都涉及bean。 If you need more info, like the structure or something else just tell me because i really need this project to work ! 如果您需要更多信息,例如结构或其他内容,请告诉我,因为我真的需要这个项目才能工作! Thanks. 谢谢。

pom.xml pom.xml

<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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>cz.jiripinkas.jba</groupId>
  <artifactId>Assignement2</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>


    <name>SpringSecurityCusotmLoginFormAnnotationExample</name>

  <!-- Shared version number properties -->
<properties>
    <org.springframework.version>4.0.2.RELEASE</org.springframework.version>
    <spring.security.version>4.0.2.RELEASE</spring.security.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

</properties>

 <dependencies>
        <!-- pdf -->
         <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itextpdf</artifactId>
            <version>5.0.6</version>
        </dependency>

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.1.0.Final</version>
        </dependency>


     <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>4.0.2.RELEASE</version>
     </dependency>

     <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>4.0.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>4.0.2.RELEASE</version>
    </dependency>

     <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
     </dependency>

     <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
     </dependency>

     <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.2.1</version>
        <scope>provided</scope>
     </dependency>

     <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>jstl</artifactId>
          <version>1.2</version>
    </dependency>

      <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-core</artifactId>
        <version>3.0.5</version>
      </dependency>

      <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>3.0.5</version>
      </dependency>



      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.21</version>
      </dependency>


      <!--
        Core utilities used by other modules.
        Define this if you use Spring Utility APIs (org.springframework.core.*/org.springframework.util.*)
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Expression Language (depends on spring-core)
        Define this if you use Spring Expression APIs (org.springframework.expression.*)
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-expression</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!-- 
        Bean Factory and JavaBeans utilities (depends on spring-core)
        Define this if you use Spring Bean APIs (org.springframework.beans.*) 
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Aspect Oriented Programming (AOP) Framework (depends on spring-core, spring-beans)
        Define this if you use Spring AOP APIs (org.springframework.aop.*)
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Application Context (depends on spring-core, spring-expression, spring-aop, spring-beans) 
        This is the central artifact for Spring's Dependency Injection Container and is generally always defined
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Various Application Context utilities, including EhCache, JavaMail, Quartz, and Freemarker integration
        Define this if you need any of these integrations
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Transaction Management Abstraction (depends on spring-core, spring-beans, spring-aop, spring-context)
        Define this if you use Spring Transactions or DAO Exception Hierarchy
        (org.springframework.transaction.*/org.springframework.dao.*)
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, spring-tx)
        Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*)
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, and iBatis.
        (depends on spring-core, spring-beans, spring-context, spring-tx)
        Define this if you need ORM (org.springframework.orm.*)
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Object-to-XML Mapping (OXM) abstraction and integration with JAXB, JiBX, Castor, XStream, and XML Beans.
        (depends on spring-core, spring-beans, spring-context)
        Define this if you need OXM (org.springframework.oxm.*)
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-oxm</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Web application development utilities applicable to both Servlet and Portlet Environments
        (depends on spring-core, spring-beans, spring-context)
        Define this if you use Spring MVC, or wish to use Struts, JSF, or another web framework with Spring (org.springframework.web.*)
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Spring MVC for Servlet Environments (depends on spring-core, spring-beans, spring-context, spring-web)
        Define this if you use Spring MVC with a Servlet Container such as Apache Tomcat (org.springframework.web.servlet.*)
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Spring MVC for Portlet Environments (depends on spring-core, spring-beans, spring-context, spring-web)
        Define this if you use Spring MVC with a Portlet Container (org.springframework.web.portlet.*)
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc-portlet</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

    <!--
        Support for testing Spring applications with tools such as JUnit and TestNG
        This artifact is generally always defined with a 'test' scope for the integration testing framework and unit testing stubs
    -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${org.springframework.version}</version>
      <scope>test</scope>
    </dependency>

</dependencies>

  <build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.jetty.toolchain</groupId>
            <artifactId>jetty-version-maven-plugin</artifactId>
            <version>1.1</version>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>

web.xml web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>Assignement2</display-name>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

  <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
  </servlet>

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>*.html</url-pattern>
        <url-pattern>*.htl</url-pattern>
        <url-pattern>*.json</url-pattern>
        <url-pattern>*.xml</url-pattern>
    </servlet-mapping>

    <listener>
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>

security.xml security.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-4.0.xsd">



<!-- http use-expressions="true" -->
<http auto-config="true">
    <intercept-url pattern="/" access="permitAll" />
    <intercept-url pattern="/index" access="permitAll" />
    <intercept-url pattern="/login" access="permitAll" />
    <intercept-url pattern="/library" access="hasRole('USER')" />
    <!--here are the pages for admin -->
    <intercept-url pattern="/admin**" access="hasRole('ADMIN')" />
    <intercept-url pattern="/addBook**" access="hasRole('ADMIN')" />
    <intercept-url pattern="/editBook**" access="hasRole('ADMIN')" />
    <intercept-url pattern="/users**" access="hasRole('ADMIN')" />
    <intercept-url pattern="/addUser**" access="hasRole('ADMIN')" />
    <intercept-url pattern="/editUser**" access="hasRole('ADMIN')" />
    <form-login login-page="/login.html" username-parameter="ssoId" password-parameter="password" authentication-failure-url="/index.html"/>
    <logout logout-url="/logout"/>
    <csrf/>
</http>


<!--authentication-manager>
    <authentication-provider>
        <user-service>
            <user name="admin" password="admin" authorities="ROLE_ADMIN" />
        </user-service>
    </authentication-provider>
</authentication-manager-->
    <authentication-manager>
        <authentication-provider user-service-ref="userDetailsService" />
    </authentication-manager>

    <beans:bean id="userDetailsService" class="scan.security.UserDetailsServiceImpl" />

</beans:beans>

I finally found the problem. 我终于找到了问题。 Because i use jabx to read from xml files i did not put the correct path for the xmls. 因为我使用jabx读取xml文件,所以没有为xmls放置正确的路径。 So if you encounter this problem look first for all data to be correct and then for other incompatibilities. 因此,如果遇到此问题,请首先查看所有数据是否正确,然后再查找其他不兼容性。 I learnt it the hard way ( 4 hours of search ) 我通过艰辛的方式学习(搜索了4个小时)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM