JAR包不全!Unable to load configuration.-bean-jar:file:/.../struts2-core-2.2.1.jar!/struts-default.xml:7

【现象】

eclipse+jetty启动一个java web工程的时候,报错如下:

2015-09-06 13:29:22.884:WARN::failed struts2: Unable to load configuration. - bean - jar:file:/D:/jars/omch_hubei/struts2-core-2.2.1.jar!/struts-default.xml:71:140
2015-09-06 13:29:22.884:WARN::Failed startup of context org.mortbay.jetty.webapp.WebAppContext@6c8f4c{/omch,D:\SVN\IP_AIOBSJP\src\aiip-apps\aiip-apps-report-hadoop\src\main\webapp}
Unable to load configuration. - bean - jar:file:/D:/jars/.../struts2-core-2.2.1.jar!/struts-default.xml:71:140
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at runjettyrun.Bootstrap.main(Bootstrap.java:86)
2015-09-06 13:29:22.907:INFO::Started SelectChannelConnector@0.0.0.0:8080

 

【原因分析】

工程没有使用maven库,所有jar包都在自己创建的user library下。

使用的是struts-2.2.1,怀疑是引用的jar包不全。

 

【解决办法】,查看用到了哪些jar包。

查看struts2自带示例程序struts2-blank.war,用rar解压后会看到用到了如下基本的jar包:
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
freemarker-2.3.16.jar
javassist-3.7.ga.jar
ognl-3.0.jar  ----------------------------------->>>> 我少的就是这个。添加到自己的user library下,重新编译,就OK啦。
struts2-core-2.2.1.jar
xwork-core-2.2.1.jar

 

 

另附struts2-core-2.2.1.jar编译打包用的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
 * $Id: pom.xml 965058 2010-07-17 11:57:54Z lukaszlenart $
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
-->
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-parent</artifactId>
        <version>2.2.1</version>
    </parent>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <packaging>jar</packaging>
    <name>Struts 2 Core</name>

    <scm>
       <connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_1/core</connection>
       <developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_1/core</developerConnection>
       <url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_2_1/core</url>
    </scm>

    <properties>
        <tlib.version>2.2</tlib.version>
        <ognl.version>3.0</ognl.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.myfaces.tobago</groupId>
                <artifactId>maven-apt-plugin</artifactId>
                <version>1.0.15</version>
                <configuration>
                    <A>uri=/struts-tags,tlibVersion=${tlib.version},jspVersion=2.0,shortName=s,displayName="Struts Tags",
                    outFile=${basedir}/target/classes/META-INF/struts-tags.tld,
                    description="To make it easier to access dynamic data;
                    the Apache Struts framework includes a library of custom tags.
                    The tags interact with the framework's validation and internationalization features;
                    to ensure that input is correct and output is localized.
                    The Struts Tags can be used with JSP FreeMarker or Velocity.",
                    outTemplatesDir=${basedir}/src/site/resources/tags
                    </A>
                    <resourceTargetPath>target</resourceTargetPath>
                    <fork>false</fork>
                    <force>true</force>
                    <nocompile>true</nocompile>
                    <showWarnings>true</showWarnings>
                    <factory>org.apache.struts.annotations.taglib.apt.TLDAnnotationProcessorFactory</factory>
                    <target>1.5</target>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <sourcepath>${basedir}/src/main/java;${basedir}/../xwork-core/src/main/java</sourcepath>
                    <encoding>UTF-8</encoding>
                    <groups>
                        <group>
                            <title>Struts Packages</title>
                            <packages>org.apache.struts2*</packages>
                        </group>
                        <group>
                            <title>XWork Packages</title>
                            <packages>com.opensymphony.xwork2*</packages>
                        </group>
                    </groups>
                    <show>private</show>
                    <links>
                        <link>http://java.sun.com/j2se/1.5.0/docs/api</link>
                        <link>http://java.sun.com/javaee/5/docs/api/</link>
                        <link>http://jakarta.apache.org/commons/logging/apidocs/</link>
                        <link>http://logging.apache.org/log4j/docs/api/</link>
                    </links>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>rat-maven-plugin</artifactId>
                <version>1.0-alpha-2</version>
                <configuration>
                    <includes>
                        <include>pom.xml</include>
                        <include>src/**</include>
                    </includes>
                    <excludes>
                        <exclude>src/test/resources/org/apache/struts2/views/jsp/ui/*</exclude>
                        <exclude>src/main/resources/org/apache/struts2/static/domTT.js</exclude>
                        <exclude>src/test/resources/org/apache/struts2/interceptor/validation/*</exclude>
                        <exclude>src/site/resources/tags/**</exclude>
                        <exclude>src/main/resources/*LICENSE.txt</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

    <profiles>
        <profile>
            <id>alljars</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.2</version>
                        <executions>
                            <execution>
                                <id>attach-source</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <sourcepath>${basedir}/src/main/java;${basedir}/../xwork-core/src/main/java</sourcepath>
                            <encoding>UTF-8</encoding>
                            <groups>
                                <group>
                                    <title>Struts Packages</title>
                                    <packages>org.apache.struts2*</packages>
                                </group>
                                <group>
                                    <title>XWork Packages</title>
                                    <packages>com.opensymphony.xwork2*</packages>
                                </group>
                            </groups>
                            <show>private</show>
                            <links>
                                <link>http://java.sun.com/j2se/1.5.0/docs/api</link>
                                <link>http://java.sun.com/javaee/5/docs/api/</link>
                                <link>http://jakarta.apache.org/commons/logging/apidocs/</link>
                                <link>http://logging.apache.org/log4j/docs/api/</link>
                            </links>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-source</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>default-tools.jar</id>
            <activation>
                <property>
                    <name>java.vendor</name>
                    <value>Sun Microsystems Inc.</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.sun</groupId>
                    <artifactId>tools</artifactId>
                    <version>1.5.0</version>
                    <scope>system</scope>
                    <systemPath>${java.home}/../lib/tools.jar</systemPath>
                </dependency>
            </dependencies>
        </profile>

    </profiles>


    <dependencies>
        <dependency>
            <groupId>org.apache.struts.xwork</groupId>
            <artifactId>xwork-core</artifactId>
            <version>${version}</version>
        </dependency>

        <!--<dependency>-->
            <!--<groupId>org.apache.struts</groupId>-->
            <!--<artifactId>struts2-api</artifactId>-->
            <!--<version>${pom.version}</version>-->
        <!--</dependency>-->

        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.16</version>
        </dependency>

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

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

        <dependency>
            <groupId>ognl</groupId>
            <artifactId>ognl</artifactId>
            <version>${ognl.version}</version>
        </dependency>

        <!-- Velocity -->
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>1.6.3</version>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-tools</artifactId>
            <version>1.3</version>
            <optional>true</optional>
            <exclusions>
                <exclusion>
                    <groupId>struts</groupId>
                    <artifactId>struts</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>velocity</groupId>
                    <artifactId>velocity</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- File upload -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>
        
        <!-- Mocks for unit testing (by Spring) -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${struts2.springPlatformVersion}</version>
            <scope>test</scope>
        </dependency>




        <!-- Test dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
              <scope>compile</scope>
            <optional>true</optional>
          <version>3.8.2</version>
        </dependency>

        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>2.4</version>
            <scope>test</scope>
        </dependency>
        <!--dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymockclassextension</artifactId>
            <version>1.1</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.easymock</groupId>
                    <artifactId>easymock</artifactId>
                </exclusion>
            </exclusions>
        </dependency-->

        <dependency>
            <groupId>mockobjects</groupId>
            <artifactId>mockobjects-core</artifactId>
            <version>0.09</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>mockobjects</groupId>
            <artifactId>mockobjects-jdk1.3</artifactId>
            <version>0.09</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>mockobjects</groupId>
            <artifactId>mockobjects-alt-jdk1.3</artifactId>
            <version>0.09</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>mockobjects</groupId>
            <artifactId>mockobjects-alt-jdk1.3-j2ee1.3</artifactId>
            <version>0.09</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>mockobjects</groupId>
            <artifactId>mockobjects-jdk1.3-j2ee1.3</artifactId>
            <version>0.09</version>
            <scope>test</scope>
        </dependency>

    <dependency>
            <groupId>jmock</groupId>
            <artifactId>jmock</artifactId>
            <version>1.0.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.9</version>
            <scope>test</scope>
        </dependency>

        <!-- These jars have to be in the compile scope in order to work with apt plugin
             (struts-annotations) and javadoc (the rest to process xwork sources). Marking
             them optional to exclude them from transitive dependency resolution -->

        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts-annotations</artifactId>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>5.1</version>
             <scope>compile</scope>
            <optional>true</optional>
           <classifier>jdk15</classifier>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>${struts2.springPlatformVersion}</version>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>

    </dependencies>
</project>

 

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jason9211

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值