在Glassfish部署期间,WEB-INF / lib中的JAR库未添加到类路径中 [英] JAR libraries in WEB-INF/lib not added to classpath during Glassfish deployment

查看:226
本文介绍了在Glassfish部署期间,WEB-INF / lib中的JAR库未添加到类路径中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很开心Glassfish和Java EE,尽管我已经使用了Java几年了。我继承了一个停滞的项目,现在我需要再次开始开发。我正在尝试按原样部署Web应用程序,以查看哪些工作和需要注意的事项。虽然有很多代码来实现各种功能,但似乎第一点需要注意的是应用程序的部署。



我正在部署的Web应用程序是 MyServer ,并打包在WAR存档中。 MyServer 中的类引用了 MyDatabase 中的类,该类实现了一个接口( InterfaceOne )从 MyInterfaces MyServer 中的类也直接引用 InterfaceOne MyInterfaces MyServer MyDatabase MyInterfaces 都是Eclipse中的所有项目,使用Maven打包。 MyServer POM文件将 MyDatabase 作为依赖关系,并将 MyDatabase 列出 MyInterfaces 作为依赖。 MyServer POM文件不会将 MyInterfaces 列为直接依赖关系,但我不认为这应该导致问题。 Eclipse在 MyServer 课程中没有显示任何错误; Eclipse似乎认为Maven依赖关系足以找到所有必需的类。



当我部署 MyServer WAR在Glassfish v3.1.2上,通过管理Web控制台,然后查看〜glassfish3 / glassfish / domains / MyDomain / logs / server.log 中的日志我遇到以下错误: / p>


[#| 2014-05-29T10:06:02.371 + 0100 | SEVERE | glassfish3.1.2 | global | _ThreadID = 80; _ThreadName =线程2; |找不到类[my / interfaces / InterfaceOne]。加载[class my.server.ControllerOne] |#]
[#| 2014-05-29T10:06:02.387 + 0100 | SEVERE | glassfish3.1.2 | global | _ThreadID = 80; _ThreadName = Thread-2 ; |找不到类[my / interfaces / InterfaceOne]。加载[class my.server.ControllerOne] |#]


尝试加载时显示与界面有关的两个错误该课程来自 MyServer 。如果我删除对 MyDatabase 的引用或直接引用 InterfaceOne MyInterfaces 从$ code> my.server.ControllerOne class然后其中一个错误消失(这是预期的,只是确认该错误与引用相关和间接地) InterfaceOne MyInterfaces



类似的问题,包括此处此处这里都提到确保所需的库( my-database.jar my-interfaces.jar )位于 WEB-INT / lib 目录中> MyServer 应用程序的WAR归档文件,但是如果我检查生成的WAR存档为 MyServer ,那么这些库确实位于 WE B-INF / lib / 目录。如果我在部署之后检查〜glassfish3 / glassfish / domains / MyDomain / applications / MyServer / WEB-INF / lib / 目录。我假设这表明它们已经从WAR存档中成功提取并放置在Glassfish服务器上。关键是图书馆绝对存在!



我可以想到的是,这些库不会添加到JVM的classpath中,试图加载 MyServer 但是如果Glassfish尝试加载一个应用程序的类,那么它还应该首先加载应用程序打包的库不应该?的确,Oracle GlassFish服务器应用程序的页面开发指南
版本3.1.2表示将应用程序的 WEB-INF / lib / 目录添加到应用程序的类路径。



我已经看到其他建议,Web应用程序需要的库被放置在〜glassfish3 / glassfish / domains / MyDomain / lib / ext / 目录。这可能非常有效,但是我的具体库仅由 MyServer 应用程序需要,而不是整个 MyDomain 。据我所知,应用程序的 WEB-INF / lib / 目录应该是有效的。



有没有人有任何想法为什么 my-database.jar my-interfaces.jar 库在部署过程中似乎没有添加到类路径中?更具体地说,有没有人知道为什么在加载 my.server.ControllerOne my.interfaces.InterfaceOne 类不可见c> class在部署期间



MyServer web.xml content:

 <?xml version =1.0encoding =UTF-8?> 
< web-app xmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexmlns =http://java.sun.com/xml/ns/javaeexmlns :web =http://java.sun.com/xml/ns/javaee/web-app_2_5.xsdxsi:schemaLocation =http://java.sun.com/xml/ns/javaee http:// java.sun.com/xml/ns/javaee/web-app_3_0.xsdid =WebApp_IDversion =3.0>
< display-name> MyServer< / display-name>
< welcome-file-list>
< welcome-file> index.xhtml< / welcome-file>
< welcome-file> default.xhtml< / welcome-file>
< / welcome-file-list>
< servlet>
< servlet-name> Faces Servlet< / servlet-name>
< servlet-class> javax.faces.webapp.FacesServlet< / servlet-class>
< load-on-startup> 1< / load-on-startup>
< / servlet>
< servlet-mapping>
< servlet-name> Faces Servlet< / servlet-name>
< url-pattern> / faces / *< / url-pattern>
< / servlet-mapping>
< context-param>
< description>状态保存方式:'client'或'server'(= default)。请参阅JSF规范2.5.2< / description>
< param-name> javax.faces.STATE_SAVING_METHOD< / param-name>
< param-value>客户端< / param-value>
< context-param>
< param-name> javax.servlet.jsp.jstl.fmt.localizationContext< / param-name>
< param-value> resources.application< / param-value>
< context-param>
< param-name> javax.faces.FACELETS_LIBRARIES< / param-name>
< param-value> /WEB-INF/balusc.taglib.xml< / param-value>
< context-param>
< param-name> javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL< / param-name>
< param-value> true< / param-value>
< filter>
< filter-name> PrimeFaces FileUpload Filter< / filter-name>
< filter-class> org.primefaces.webapp.filter.FileUploadFilter< / filter-class>
< / filter>
< filter-mapping>
< filter-name> PrimeFaces FileUpload Filter< / filter-name>
< servlet-name> Faces Servlet< / servlet-name>
< / filter-mapping>
< context-param>
< param-name> javax.faces.PARTIAL_STATE_SAVING< / param-name>
< param-value> false< / param-value>
< / web-app>

MyServer pom.xml

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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> my.webapp< / groupId>
< artifactId> my-server< / artifactId>
< version> 0.1.0-SNAPSHOT< / version>
< name> My Server< / name>
< parent>
< groupId> my.webapp< / groupId>
< artifactId> my-parent-pom< / artifactId>
< version> 1.5< / version>
< / parent>
< organization>
< name>示例< / name>
< url> http://www.example.com< / url>
< / organization>
< repositories>
< repository>
< id> eclipselink< / id>
< url> http://www.eclipse.org/downloads/download.php?r = 1& amp; amp; nf = 1& amp; amp; amp; amp; amp; amp; amp; amp; amp; URL>
< / repository>
< / repositories>
<依赖关系>
<依赖关系>
< groupId> javax< / groupId>
< artifactId> javaee-api< / artifactId>
< version> 6.0< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> javax.faces< / groupId>
< artifactId> jsf-api< / artifactId>
< version> 2.1< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> com.sun.faces< / groupId>
< artifactId> jsf-impl< / artifactId>
< version> 2.1.0< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> eclipselink< / groupId>
< artifactId> eclipselink< / artifactId>
< version> 2.3.0< / version>
< / dependency>

<依赖关系>
< groupId>实用程序< / groupId>
< artifactId>实用程序< / artifactId>
< version> 0.1.0< / version>
< / dependency>

<依赖关系>
< groupId> javax.enterprise< / groupId>
< artifactId> cdi-api< / artifactId>
< version> 1.0< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> my.webapp< / groupId>
< artifactId> my-database< / artifactId>
< version> 0.1.0-SNAPSHOT< / version>
< / dependency>
<依赖关系>
< groupId> org.primefaces< / groupId>
< artifactId>标题< / artifactId>
< version> 3.4.1< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.commons< / groupId>
< artifactId> commons-io< / artifactId>
< version> 1.3.2< / version>
< / dependency>
<依赖关系>
< groupId> commons-fileupload< / groupId>
< artifactId> commons-fileupload< / artifactId>
< version> 1.2.1< / version>
< / dependency>
< / dependencies>

< packaging> war< / packaging>
< build>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-war-plugin< / artifactId>
<! - < configuration>部分添加到
内的WEB-INF / web.xml WebContent - >
< configuration>
< webResources>
< resource>
< directory> WebContent< / directory>
< / resource>
< / webResources>
< / configuration>
< / plugin>
< / plugins>
< / build>
< scm>
< connection> scm:svn:https://svn.server/location/in/repo/my_server< / connection>
< developerConnection> scm:svn:https://svn.server/location/in/repo/my_server/trunk< / developerConnection>
< / scm>
< / project>

MyDatabase pom.xml

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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>
< artifactId> my-database< / artifactId>
< version> 0.1.0-SNAPSHOT< / version>
< parent>
< groupId> my.webapp< / groupId>
< artifactId> my-parent-pom< / artifactId>
< version> 1.5< / version>
< / parent>
<依赖关系>
<依赖关系>
< groupId> eclipselink< / groupId>
< artifactId> eclipselink< / artifactId>
< version> 2.3.0< / version>
< / dependency>
<依赖关系>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> 4.10< / version>
< scope> test< / scope>
< / dependency>
<依赖关系>
< groupId> org.mindrot< / groupId>
< artifactId> bcrypt< / artifactId>
< version> 0.2.0< / version>
< / dependency>
<依赖关系>
< groupId> my.webapp< / groupId>
< artifactId> my-interfaces< / artifactId>
< version> 0.1.0-SNAPSHOT< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.geronimo.specs< / groupId>
< artifactId> geronimo-jpa_3.0_spec< / artifactId>
< version> 1.1.1< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> mysql< / groupId>
< artifactId> mysql-connector-java< / artifactId>
< version> 5.0.5< / version>
< scope> test< / scope>
< / dependency>
< / dependencies>
< scm>
< connection> scm:svn:https://svn.server/location/in/repo/my_database< / connection>
< developerConnection> scm:svn:https://svn.server/location/in/repo/my_database/trunk/< / developerConnection>
< / scm>
< groupId> my.webapp< / groupId>
< / project>

MyInterfaces pom.xml

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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> my.webapp< / groupId>
< artifactId> my-interfaces< / artifactId>
< version> 0.1.0-SNAPSHOT< / version>
< packaging> jar< / packaging>
将亲本GT;
< groupId> my.webapp< / groupId>
< artifactId> my-parent-pom< / artifactId>
< version> 1.5< / version>

< / parent>
将SCM>
将连接> SCM:SVN:HTTPS://svn.server/location/in/repo/my_interfaces< /连接>
< developerConnection> scm:svn:https://svn.server/location/in/repo/my_interfaces/trunk< / developerConnection>
将/ SCM>
将依赖>
<依赖关系>
< groupId> my.webapp< / groupId>
< artifactId> my-utilities< / artifactId>
< version> 0.1.2< / version>
< classifier> me< / classifier>
< / dependency>
将依赖>
< groupId> javax< / groupId>
< artifactId> javaee-api< / artifactId>
< version> 6.0< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> 4.10< / version>
< scope> test< / scope>
< / dependency>
< / dependencies>
< / project>

MyInterfaces POM列出了对 MyUtilities 。我认为这可以安全地忽略这个问题,因为没有一个类出现在我描述的错误消息中。当我的应用程序部署时,它也被放置在Glassfish服务器上的 WEB-INT / lib / 目录中。



(Glassfish的问题似乎需要很多信息,如web.xml文件和pom.xml等等。感谢您抽出时间筛选所有这些。)

解决方案

似乎有两个问题:


  1. 首先 MyServer的 web.xml < display-name> 不正确。这个
    在我的问题中是不可见的,因为我更改了图书馆名称
    (包含客户端名称)。给项目
    的部分要求是对项目进行重新标注,并且我错过了
    < display-name> 元素。糟糕。


  2. 第二个问题是,当
    调查此问题时,我移动了 MyDatabase MyInterfaces MyServer $ code> WEB-INF / lib /
    目录到该域的 LIB / EXT / 目录和背部。这个
    更改了部署过程中记录的错误(由于尽管< display-name> 不正确,
    可见,但是
    当我将数据库和接口库
    移回到 MyServer 应用程序时,没有重新出现,我认为Glassfish缓存
    库,而不是更新
    部署期间缓存的库。停止/启动域更新缓存。


总而言之,一旦MyServer的< display-name> 已更改,Glassfish库缓存已更新,类加载错误显示已解决。


I'm new to Glassfish and Java EE although I've been using Java for a few years. I've inherited a project that stalled and now I need to start development on it again. I'm trying to deploy the web application as-is to see what works and what needs attention. While there is a lot of code to implement various functions, it appears that the first point needing attention is deployment of the application.

The web application I'm trying to deploy is MyServer and is packaged in a WAR archive. A class in MyServer has a reference to a class in MyDatabase which implements an interface (InterfaceOne) from MyInterfaces. The class in MyServer also has a direct reference to InterfaceOne from MyInterfaces. MyServer, MyDatabase and MyInterfaces are all projects in Eclipse and packaged using Maven. The MyServer POM file lists MyDatabase as a dependency and the POM file for MyDatabase lists MyInterfaces as a dependency. The MyServer POM file doesn't list MyInterfaces as an immediate dependency but I don't think that this should cause an issue. Eclipse doesn't show any errors in the MyServer class concerned; Eclipse appears to consider the Maven dependencies to be sufficient to locate all necessary classes.

When I deploy the MyServer WAR on Glassfish v3.1.2 via the Admin web console and then view the logs in ~glassfish3/glassfish/domains/MyDomain/logs/server.log I encounter the following errors:

[#|2014-05-29T10:06:02.371+0100|SEVERE|glassfish3.1.2|global|_ThreadID=80;_ThreadName=Thread-2;| Class [ my/interfaces/InterfaceOne] not found. Error while loading [ class my.server.ControllerOne ]|#] [#|2014-05-29T10:06:02.387+0100|SEVERE|glassfish3.1.2|global|_ThreadID=80;_ThreadName=Thread-2;|Class [ my/interfaces/InterfaceOne ] not found. Error while loading [ class my.server.ControllerOne ]|#]

There are two errors shown relating to the interface while trying to load the class from MyServer. If I remove either the reference to MyDatabase or the direct reference to InterfaceOne from MyInterfaces from the my.server.ControllerOne class then one of the errors above disappears (which is expected and just confirms that the error is related to the references (directly and indirectly) of the InterfaceOne from MyInterfaces.

Similar questions including here, here and here all mention ensuring that the required libraries (my-database.jar and my-interfaces.jar) are located in the WEB-INT/lib directory of the MyServer application's WAR archive. However, if I inspect the generated WAR archive for MyServer then the libraries are indeed located in the WEB-INF/lib/ directory. If I inspect the ~glassfish3/glassfish/domains/MyDomain/applications/MyServer/WEB-INF/lib/ directory after deployment the libraries are there too. I assume this indicates that they were successfully extracted from the WAR archive and placed on the Glassfish server. The point is the libraries are definitely there!

All I can think of is that the libraries are not added to classpath of the JVM trying to load the classes of MyServer but surely if Glassfish tries to load classes of an application then it should also first load the libraries packaged with the application shouldn't it? Indeed this page from the Oracle GlassFish Server Application Development Guide Release 3.1.2 indicates that the WEB-INF/lib/ directory of an application is added to the application's classpath.

I've seen other suggestions that libraries required by web applications be placed in the ~glassfish3/glassfish/domains/MyDomain/lib/ext/ directory. That might very well work but my specific libraries are required by the MyServer application only, not the whole of MyDomain. As far as I can tell, it should be valid to place them in the WEB-INF/lib/ directory of my application.

Does anyone have any ideas about why the my-database.jar and my-interfaces.jar libraries don't seem to be added to the classpath during deployment? More specifically, does anyone know why the my.interfaces.InterfaceOne class isn't visible while loading the my.server.ControllerOne class during deployment?

MyServer's web.xml content:

<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>MyServer</display-name>
  <welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
    <welcome-file>default.xhtml</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/balusc.taglib.xml</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
  </context-param>
  <filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
  </filter-mapping>
  <context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
  </context-param>
</web-app>

MyServer 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>my.webapp</groupId>
    <artifactId>my-server</artifactId>
    <version>0.1.0-SNAPSHOT</version>
    <name>My Server</name>
    <parent>
        <groupId>my.webapp</groupId>
        <artifactId>my-parent-pom</artifactId>
        <version>1.5</version>
    </parent>
    <organization>
        <name>Example</name>
        <url>http://www.example.com</url>
    </organization>
    <repositories>
        <repository>
            <id>eclipselink</id>
            <url>http://www.eclipse.org/downloads/download.php?r=1&amp;nf=1&amp;file=/rt/eclipselink/maven.repo/</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>eclipselink</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.3.0</version>
        </dependency>

        <dependency>
            <groupId>utilities</groupId>
            <artifactId>utilities</artifactId>
            <version>0.1.0</version>
        </dependency>

        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>my.webapp</groupId>
            <artifactId>my-database</artifactId>
            <version>0.1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>3.4.1</version>
        </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.2.1</version>
    </dependency>
    </dependencies>

    <packaging>war</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <!-- <configuration> section added to pick up the WEB-INF/web.xml inside
                    WebContent -->
                <configuration>
                    <webResources>
                        <resource>
                            <directory>WebContent</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <scm>
        <connection>scm:svn:https://svn.server/location/in/repo/my_server</connection>
        <developerConnection>scm:svn:https://svn.server/location/in/repo/my_server/trunk</developerConnection>
    </scm>
</project>

MyDatabase 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>
  <artifactId>my-database</artifactId>
  <version>0.1.0-SNAPSHOT</version>
  <parent>
    <groupId>my.webapp</groupId>
    <artifactId>my-parent-pom</artifactId>
    <version>1.5</version>
  </parent>
  <dependencies>
    <dependency>
      <groupId>eclipselink</groupId>
      <artifactId>eclipselink</artifactId>
      <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mindrot</groupId>
      <artifactId>bcrypt</artifactId>
      <version>0.2.0</version>
    </dependency>
    <dependency>
        <groupId>my.webapp</groupId>
        <artifactId>my-interfaces</artifactId>
        <version>0.1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-jpa_3.0_spec</artifactId>
        <version>1.1.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.0.5</version>
        <scope>test</scope>
    </dependency>
  </dependencies>
  <scm>
    <connection>scm:svn:https://svn.server/location/in/repo/my_database</connection>
    <developerConnection>scm:svn:https://svn.server/location/in/repo/my_database/trunk/</developerConnection>
  </scm>
  <groupId>my.webapp</groupId>
</project>

MyInterfaces 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>my.webapp</groupId>
  <artifactId>my-interfaces</artifactId>
  <version>0.1.0-SNAPSHOT</version>
   <packaging>jar</packaging>
  <parent>
      <groupId>my.webapp</groupId>
      <artifactId>my-parent-pom</artifactId>
      <version>1.5</version>

  </parent>
  <scm>
    <connection>scm:svn:https://svn.server/location/in/repo/my_interfaces</connection>
    <developerConnection>scm:svn:https://svn.server/location/in/repo/my_interfaces/trunk</developerConnection>
  </scm>
  <dependencies>
    <dependency>
        <groupId>my.webapp</groupId>
        <artifactId>my-utilities</artifactId>
        <version>0.1.2</version>
        <classifier>me</classifier>
    </dependency>
      <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
      </dependencies>
</project>

The MyInterfaces POM lists a dependency on MyUtilities. I think this can be safely ignored for this question since none of it's classes appear in the error messages I've described. It is also placed in the WEB-INT/lib/ directory on the Glassfish server when my application is deployed.

(Glassfish questions appear to require a lot of info like web.xml files and pom.xml etc. Thanks for taking the time to sift through all of this.)

解决方案

It appears that there were two issues at play:

  1. Firstly MyServer's web.xml <display-name> was incorrect. This wasn't visible in my question because I'd changed the library names (which contain client names). Part of the requirements given to me for the project were to rebrand the project and I missed the <display-name> element. Oops.

  2. The second issue was that, while investigating this issue, I moved the MyDatabase and MyInterfaces libraries from the MyServer WEB-INF/lib/ directory to the domain's lib/ext/ directory and back. This changed the errors logged during deployment (since the libraries were visible despite the incorrect <display-name> but they errors didn't reappear when I moved the database and interface libraries back into the MyServer application. I think Glassfish was caching the libraries and not updating the cached libraries during deployment. Stopping/starting the domain updated the cache.

To summarise, once the <display-name> of MyServer was changed and the Glassfish library cache was updated, the class loading errors appear resolved.

这篇关于在Glassfish部署期间,WEB-INF / lib中的JAR库未添加到类路径中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆