简体   繁体   English

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

[英]Error when deploying web app on Glassfish

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.java Class : 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.log content : http://txs.io/B7P system.log内容: http : //txs.io/B7P

According to @Silly Freak's comment, I found the answer. 根据@Silly Freak的评论,我找到了答案。

These two method should not have the same name : 这两个方法不应具有相同的名称:

ProductCatalog.java ProductCatalog.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. 我将第一个方法的名称更改为其他名称,并像魅力一样工作。

For me the problem was, I missed to include the no arguments constructor or "Product" class. 对我来说,问题是,我错过了包含无参数构造函数或“ Product”类的问题。 It worked when I included the no argument constructor. 当我包含no参数构造函数时,它起作用了。

Note: JAXB requires no arg constructor to instantiate the object. 注意:JAXB不需要arg构造函数来实例化该对象。

I had this problem, the glassfish was on Linux environment. 我有这个问题, glassfish在Linux环境中。 check your $JAVA_HOME it should be set in to jdk 检查您的$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.. 然后问题解决了..

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). 您可以看到boolean变量的getter和setter与其他两个变量不同(所有的getter和setter都是由eclipse本身开发的)。 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. 现在从框架的角度来看,它将使用一个属性名称,将其第一个字符更改为大写,并附加一个get或set作为前缀,以调用该属性的getter和setter。 So in the case of boolean attribute it will go wrong. 因此,在布尔属性的情况下,它将出错。

So when I changed the existing getters and setters to default form like getIsActive() and setIsActive() , it was published properly. 因此,当我将现有的getter和setter更改为默认形式(如getIsActive()setIsActive() ,它已正确发布。

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

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