2

I saw this and other similar questions before and their solution didn't solve my problem because Glassfish 5 had a lot of changes.

I'm running a soap web service and getting this error:

java.lang.IllegalStateException: The lifecycle method [finalizeConfig] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void org.apache.cxf.transport.http_jetty.spring.JettyHTTPServerEngineBeanDefinitionParser$SpringJettyHTTPServerEngine.finalizeConfig() throws java.security.GeneralSecurityException,java.io.IOException] of type [METHOD]
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:503)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:423)
    at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProcess(WebArchivist.java:317)
    at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProcess(WebArchivist.java:68)
    at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:397)
    at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:372)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:247)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:256)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:217)
    at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:137)
    at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:183)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:207)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:73)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:857)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:797)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:354)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:195)
...

I'm using Glassfish 5.1.0 and using Apache cxf 3.3.5 and my IDE is Eclipse EE Version: 2019-12 (4.14.0)

I downloaded Apache CXF binary distribution and added in to eclipse CXF runtime.

This is my web service class:

package com.web.service;

import javax.jws.WebMethod; 
import javax.jws.WebService; 

@WebService(targetNamespace = "localhost:8080")
public class Service { 
    @WebMethod public String greet(String name) { 
        return "Hi," + name; 
    }
} 
hamidreza75
  • 567
  • 6
  • 15
  • Hi, I've formatted your code. Please check the general help pages for your next question. Please don't add comments to clarify; code is unreadable in comments. – Robert Jan 24 '20 at 20:59
  • Thank you very much. I read them, but need a little practice. – hamidreza75 Jan 25 '20 at 02:45

1 Answers1

0

The org.apache.cxf.transport.http_jetty.spring package causes problems when deployed to Glassfish. You need to remove that from the CXF binary distribution.

Please try the following steps:

First remove the original binary distribution from your project in Eclipse.
Then you need to open the binary distribution with some archive tool (maybe the operating system you are using contains something already) and navigate to the lib folder in the archive. Delete the file cxf-rt-transports-http-jetty-*.jar. Then add the changed binary distribution to your project like you did before with the original binary distribution.

Maybe this will already be sufficient. If not, there is another step you can try.

It is more or less the same solution that you linked already. However, I am not sure if Glassfish 5.1 will still accept the sun-web.xml file. It should be named glassfish-web.xml nowadays.

So create the file glassfish-web.xml with following content:
(if you already have that file, only add the <class-loader delegate="true"/> line to it)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
  <class-loader delegate="true"/>
</glassfish-web-app>

Put the file into the WEB-INF folder of your WAR file.

Christoph John
  • 3,003
  • 2
  • 13
  • 23
  • Thanks. I did what you said and it gets another error. java.lang.IllegalStateException: The lifecycle method [finalizeConfig] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void org.apache.cxf.transport.http_undertow.spring.UndertowHTTPServerEngineBeanDefinitionParser$SpringUndertowHTTPServerEngine.finalizeConfig() throws java.security.GeneralSecurityException,java.io.IOException] of type [METHOD] at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:503) ... – hamidreza75 Jan 25 '20 at 02:52
  • Then please also remove the undertow transport from the binary distribution. Just as you did with the jetty transport. – Christoph John Jan 25 '20 at 04:57
  • There is 3 files that have undertow on them. cxf-rt-transports-http-undertow-3.3.5.jar, undertow-core-2.0.28.Final.jar and undertow-servlet-2.0.28.Final.jar. Do I need to remove all of them? are you sure that nothing goes wrong? Cheers. – hamidreza75 Jan 25 '20 at 06:21
  • The one for the transport should be enough. What do you have to lose? ;) – Christoph John Jan 25 '20 at 07:40
  • after removing file: java.lang.RuntimeException: wsdl file classpath:/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl does not exist for web service Discovery at com.sun.enterprise.deployment.util.ModuleContentValidator.accept(ModuleContentValidator.java:181) at com.sun.enterprise.deployment.util.ModuleContentLinker.accept(ModuleContentLinker.java:67) at com.sun.enterprise.deployment.BundleDescriptor.visit(BundleDescriptor.java:617) at org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl.visit(WebBundleDescriptorImpl.java:2009) – hamidreza75 Jan 25 '20 at 14:23
  • Did you add the glassfish-web.xml? What is the structure of your WAR file? Does it contain the CXF distribution or do you deploy that separately? – Christoph John Jan 25 '20 at 17:37
  • Eclipse creates glassfish-web.xml automatically and I just added . in package explorer, I have: TestService\ src,jre, glassfishSystemLibraries, ApacheSystemLibraries, build, webContent. TestService is the name of my project. Because I added Cxf in preferences as default runtime and selected it in the facets, eclipse automatically adds it to the project. I can upload it on github or somewhere if neded. Thanks. – hamidreza75 Jan 26 '20 at 04:56
  • Yes please upload to github. – Christoph John Jan 26 '20 at 09:55