Java 在 Glassfish 上部署 Web 应用程序时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22655826/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 17:07:46  来源:igfitidea点击:

Error when deploying web app on Glassfish

javaexceptionglassfish

提问by Hamed Kamrava

I'm using Eclipse + Glassfish 4.0

我正在使用 Eclipse + Glassfish 4.0

When I deploying a simple project, following error appears :

当我部署一个简单的项目时,出现以下错误:

cannot Deploy Testmart 

deploy is failing=Error occurred during deployment: Exception while loading 
the app : java.lang.IllegalStateException: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: java.lang.RuntimeException: 
Servlet web service endpoint '' failure. Please see server.log for more details.

EDIT :

编辑 :

ProductCatalog.javaClass :

ProductCatalog.java类:

import org.hamed.train.service.ProductServiceImp;

@WebService
public class ProductCatalog {
    ProductServiceImp productService = new ProductServiceImp();
    @WebMethod
    public List<String> getProducts() {
        return productService.getProductCategories();
    }
    public List<String> getProducts(String category) {
        return productService.getProducts(category);
    }
}

system.logcontent : http://txs.io/B7P

system.log内容:http: //txs.io/B7P

采纳答案by Hamed Kamrava

According to @Silly Freak's comment, I found the answer.

根据@Silly Freak 的评论,我找到了答案。

These two method should not have the same name :

这两个方法不应具有相同的名称:

ProductCatalog.java

产品目录.java

public List<String> getProducts() {
        return productService.getProductCategories();
    }

public List<String> getProducts(String category) {
        return productService.getProducts(category);
    }

Solution:

解决方案:

I changed first method name to something else and worked like a charm.

我将第一个方法名称更改为其他名称并像魅力一样工作。

回答by Ravinath

I had this problem, the glassfishwas on Linux environment. check your $JAVA_HOMEit should be set in to jdk

我遇到了这个问题,glassfish在 Linux 环境中。检查你的$JAVA_HOME它应该设置为 jdk

export JAVA_HOME=/usr/java/jdk1.7.0_55

/opt/glassfish4/glassfish/bin # echo $JAVA_HOME

/usr/java/jdk1.7.0_55

then problem was solved..

然后问题解决了..

回答by balajivijayan

For me the problem was, I missed to include the no arguments constructor or "Product" class. It worked when I included the no argument constructor.

对我来说,问题是,我错过了包含无参数构造函数或“产品”类。当我包含无参数构造函数时,它起作用了。

Note: JAXB requires no arg constructor to instantiate the object.

注意:JAXB 不需要 arg 构造函数来实例化对象。

回答by balajivijayan

I also had the same problem with eclipse galileo, and I was sure that it was related to my hibernate mapping, because publishing process started to fail when I made a new mapping to a table using an HBM file, mapping was proper in HBM file but the problem was with my DAO class.

我在 eclipse galileo 上也遇到了同样的问题,我确信它与我的休眠映射有关,因为当我使用 HBM 文件对表进行新映射时发布过程开始失败,映射在 HBM 文件中是正确的,但是问题出在我的 DAO 类上。

Sample code of my DAO class :-

我的 DAO 类的示例代码:-

public class MyDAO
{
     private int id;
     private int name;
     private boolean isActive;

     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;
     }
     public boolean isActive() {
        return isActive;
     }
     public void setActive(boolean isActive) {
        this.isActive = isActive;
     }
}

You can see the getters and setters of boolean variable is different from the other two variables (all the getters and setters were developed by eclipse itself). Now viewing from framework perspective, it will take an attribute name, change its first character to uppercase and attach a get or set as a prefix to invoke the attribute's getter and setter. So in the case of boolean attribute it will go wrong.

可以看到boolean变量的getter和setter与其他两个变量不同(所有的getter和setter都是eclipse自己开发的)。现在从框架的角度来看,它将采用一个属性名称,将其第一个字符更改为大写,并附加一个 get 或 set 作为前缀以调用该属性的 getter 和 setter。所以在布尔属性的情况下它会出错。

So when I changed the existing getters and setters to default form like getIsActive()and setIsActive(), it was published properly.

因此,当我将现有的 getter 和 setter 更改为像getIsActive()andsetIsActive()这样的默认形式时,它已正确发布。