Expand my Community achievements bar.

SOLVED

java.lang.NoClassDefFoundError: Could not initialize class com.aem.ws.Weather

Avatar

Level 1

Hi Team,

        I was working on SOAP CXF webservice. I gone through the below link "http://helpx.adobe.com/experience-manager/using/creating-cxf-bundles-consume-web.html". I created the CXF osgi bundle and it's in ACTIVE state in felix console. When i was trying to call webservice through JSP, it's giving error as "java.lang.NoClassDefFoundError: Could not initialize class com.aem.ws.Weather".

http://helpx.adobe.com/experience-manager/using/creating-cxf-bundles-consume-web.html

Thanks,

Kiran Parab

1 Accepted Solution

Avatar

Correct answer by
Level 10

I just re-tested this article and it works -- as shown here:

[img]SIte.png[/img]

Now the trick is to ensure that you use package properly. In Eclipse - i changed the name of the package that contains all of the Java proxy files to com.mycompany.greeting

See:

[img]package.png[/img]

Now when i bundle this up into an OSGi bunlde using Eclipse plug-in project and deploy - notice that you will see the package in the OSGi console view:

[img]Felix.png[/img]

Now I can use this code in my CQ JSP:

<%@include file="/libs/foundation/global.jsp"%>
<h1><%= properties.get("title", currentPage.getTitle()) %></h1>
 
<h2>Here is an AEM service created from Apache CXF Java proxy classes:</h2>
<%
  
com.mycompany.greeting.Weather weather = new com.mycompany.greeting.Weather();
 
com.mycompany.greeting.WeatherSoap wsoap = weather.getWeatherSoap();
  
com.mycompany.greeting.WeatherReturn wr = wsoap.getCityWeatherByZIP("95101");
  
 
%>
  
<h2>The following describes the weather for 95101 ZIP Code</h2>
<h3><%= "The city is " +wr.getCity()%></h3>
<h3><%= "The state is " +wr.getState()%></h3>
<h3><%= "The description is " +wr.getDescription()%></h3>
<h3><%= "The wind is " +wr.getWind()%></h3>
<h3><%= "The current temp is " +wr.getTemperature()%></h3>
<h3><%= "The current Humidity is " +wr.getRelativeHumidity()%></h3>

 

This works - if you are having issues - 1 -- check to make sure that you configured your sling config file as described in the article. 2nd - make sure that your JSP logic matches the package (as shown above). Let me know if you make progress. If you do both 1 and 2 and still cannot get this, email me scottm@adobe.com

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

I just re-tested this article and it works -- as shown here:

[img]SIte.png[/img]

Now the trick is to ensure that you use package properly. In Eclipse - i changed the name of the package that contains all of the Java proxy files to com.mycompany.greeting

See:

[img]package.png[/img]

Now when i bundle this up into an OSGi bunlde using Eclipse plug-in project and deploy - notice that you will see the package in the OSGi console view:

[img]Felix.png[/img]

Now I can use this code in my CQ JSP:

<%@include file="/libs/foundation/global.jsp"%>
<h1><%= properties.get("title", currentPage.getTitle()) %></h1>
 
<h2>Here is an AEM service created from Apache CXF Java proxy classes:</h2>
<%
  
com.mycompany.greeting.Weather weather = new com.mycompany.greeting.Weather();
 
com.mycompany.greeting.WeatherSoap wsoap = weather.getWeatherSoap();
  
com.mycompany.greeting.WeatherReturn wr = wsoap.getCityWeatherByZIP("95101");
  
 
%>
  
<h2>The following describes the weather for 95101 ZIP Code</h2>
<h3><%= "The city is " +wr.getCity()%></h3>
<h3><%= "The state is " +wr.getState()%></h3>
<h3><%= "The description is " +wr.getDescription()%></h3>
<h3><%= "The wind is " +wr.getWind()%></h3>
<h3><%= "The current temp is " +wr.getTemperature()%></h3>
<h3><%= "The current Humidity is " +wr.getRelativeHumidity()%></h3>

 

This works - if you are having issues - 1 -- check to make sure that you configured your sling config file as described in the article. 2nd - make sure that your JSP logic matches the package (as shown above). Let me know if you make progress. If you do both 1 and 2 and still cannot get this, email me scottm@adobe.com

Avatar

Level 10

Did you make the adjustments in the configuration file as described in the article? 

Avatar

Level 1

Issue is render because of command mentioned in blog. I am using "apache-cxf-3.0.0-milestone2" version. When i am using mentioned command in blog, In Weather generated class files, i am getting below error :-

//This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
    //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
    //compliant code instead.

    public Weather(WebServiceFeature ... features) {
        super(WSDL_LOCATION, SERVICE);
    }

    //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
    //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
    //compliant code instead.
    public Weather(URL wsdlLocation, WebServiceFeature ... features) {
        super(wsdlLocation, SERVICE);
    }

    //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
    //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
    //compliant code instead.
    public Weather(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
        super(wsdlLocation, serviceName);
    }   

 

To remove the error from stubs, please find the new command mentioned below :-

*New command :-

wsdl2java -frontend jaxws21 -p com.aem.ws -d c:\proxy http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL