GlassFish 3.1.2.2战争无法在耳内找到瓶子 [英] GlassFish 3.1.2.2 war can't find jar inside ear

查看:85
本文介绍了GlassFish 3.1.2.2战争无法在耳内找到瓶子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个结构构建了一个耳朵(并非这里显示的所有文件):

  myapp.ear / 
myapp-ejb.jar
myapp-web.war
META-INF /
application.xml
lib
myapp-common.jar
code>

问题是,当战争中的代码试图引用myapp-common.jar中的类时,它会抛出 java.lang.ClassNotFoundException



请注意 META-INF / application.xml $ b

<?xml version =1.0encoding =UTF-8 >?;
< application xmlns =http://java.sun.com/xml/ns/javaee
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/application_6.xsd
version =6>
< display-name> pncr-portal-ear< / display-name>
< module>
< web>
< web-uri> myapp-web.war< / web-uri>
< context-root> /< / context-root>
< / web>
< / module>
< module>
< ejb> myapp-ejb.jar< / ejb>
< / module>
< library-directory> / lib< / library-directory>
< / application>

库目录在这里被定义为位于 / lib 目录相对于ear的根目录,这正是它的位置,尽管Java EE 5(可能是6)规范说它应该被加载到类路径中,但它仍然没有加载到类路径中。 / p>

解决方案

事实证明,我引用了一个与我认为的稍有不同的软件包。该软件包已不复存在,但Maven正在编译它而没有抱怨。所以我吹走了我的本地存储库并再次尝试。我仍然有错误。然后我发现了这个问题:在myapp.taglib.xml中,我仍然在myapp-common.jar中引用旧版本的类,它现在位于不同的包中。



<所以课程是:如果你看到 ClassNotFoundException ,也可以在你的taglib.xml文件中找到。


I have built an ear with this structure (not all files shown here):

myapp.ear/
    myapp-ejb.jar
    myapp-web.war
    META-INF/
        application.xml
    lib
        myapp-common.jar

The problem is, when code in the war tries to reference classes in myapp-common.jar, it throws java.lang.ClassNotFoundException.

Note the contents of META-INF/application.xml:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                                 http://java.sun.com/xml/ns/javaee/application_6.xsd"
             version="6">
  <display-name>pncr-portal-ear</display-name>
  <module>
    <web>
      <web-uri>myapp-web.war</web-uri>
      <context-root>/</context-root>
    </web>
  </module>
  <module>
    <ejb>myapp-ejb.jar</ejb>
  </module>
  <library-directory>/lib</library-directory>
</application>

The library directory is defined here as being in the /lib directory relative to the root of the ear, which is exactly where it is, yet it is not loaded into the classpath despite the Java EE 5 (and presumably 6) spec saying that it should be loaded into the classpath.

解决方案

As it turns out, I was referencing a class in a slightly different package than the one I thought. The package no longer existed, yet Maven was compiling it without complaining. So I blew away my local repository and tried again. I still got the error. Then I found the problem: In myapp.taglib.xml, I am still referencing an old version of a class in myapp-common.jar that is now in a different package.

So the lesson is: If you see ClassNotFoundException, also look in your taglib.xml file(s).

这篇关于GlassFish 3.1.2.2战争无法在耳内找到瓶子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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