コミュニティアチーブメントバーを展開する。

解決済み

Reg : org.apache.sling.api.scripting.ScriptEvaluationException

Avatar

以前のコミュニティメンバー

I am trying to create  CQ OSGi bundle that consumes a third-party web service.  I'm getting the below exception while accessing the pages.

org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.jsp.jasper.JasperException: Unable to compile class

 

An error occurred at line: 5 in the jsp file: /apps/stoxx/components/content/weather/weather.jsp

com.cdyne.ws.weatherws.Weather cannot be resolved to a type

2: <h1><%= properties.get("title", currentPage.getTitle()) %></h1>

3: <%

4: 

5: com.cdyne.ws.weatherws.Weather ww = new com.cdyne.ws.weatherws.Weather();

6: 

7: com.cdyne.ws.weatherws.WeatherSoap ws = ww.getWeatherSoap();

8: 

 

 

An error occurred at line: 5 in the jsp file: /apps/stoxx/components/content/weather/weather.jsp

com.cdyne.ws.weatherws.Weather cannot be resolved to a type

2: <h1><%= properties.get("title", currentPage.getTitle()) %></h1>

3: <%

4: 

5: com.cdyne.ws.weatherws.Weather ww = new com.cdyne.ws.weatherws.Weather();

6: 

7: com.cdyne.ws.weatherws.WeatherSoap ws = ww.getWeatherSoap();

8: 

 

 

An error occurred at line: 7 in the jsp file: /apps/stoxx/components/content/weather/weather.jsp

com.cdyne.ws.weatherws.WeatherSoap cannot be resolved to a type

4: 

5: com.cdyne.ws.weatherws.Weather ww = new com.cdyne.ws.weatherws.Weather();

6: 

7: com.cdyne.ws.weatherws.WeatherSoap ws = ww.getWeatherSoap();

8: 

9: com.cdyne.ws.weatherws.WeatherReturn wr = ws.getCityWeatherByZIP("95101");

10: 

 

 

An error occurred at line: 9 in the jsp file: /apps/stoxx/components/content/weather/weather.jsp

com.cdyne.ws.weatherws.WeatherReturn cannot be resolved to a type

6: 

7: com.cdyne.ws.weatherws.WeatherSoap ws = ww.getWeatherSoap();

8: 

9: com.cdyne.ws.weatherws.WeatherReturn wr = ws.getCityWeatherByZIP("95101");

10: 

11: %>

12: 

 

      at org.apache.sling.scripting.jsp.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)

      at org.apache.sling.scripting.jsp.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)

      at org.apache.sling.scripting.jsp.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:419)

      at org.apache.sling.scripting.jsp.jasper.compiler.Compiler.compile(Compiler.java:313)

      at org.apache.sling.scripting.jsp.jasper.compiler.Compiler.compile(Compiler.java:291)

      at org.apache.sling.scripting.jsp.jasper.compiler.Compiler.compile(Compiler.java:278)

      at org.apache.sling.scripting.jsp.jasper.JspCompilationContext.compile(JspCompilationContext.java:599)

      at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)

      at org.apache.sling.scripting.jsp.JspServletWrapperAdapter.service(JspServletWrapperAdapter.java:59)

      at org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:233)

      at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$100(JspScriptEngineFactory.java:85)

      at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:453)

      at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:358)

      at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:170)

      at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:456)

      at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:500)

      at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45)

      at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)

      at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilterWithErrorHandling(WCMDebugFilter.java:183)

      at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:150)

      at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)

      at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:219)

      at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) . . . . . .  . . . .

I also restarted the “ Apache Sling Scripting JSP support” and “Apache Sling Dynamic Class Loader Support” bundles. No luck J

Could anyone please tell what could be the problem?

Thanks,

Anderson

1 受け入れられたソリューション

Avatar

正解者
Level 7

Did you try ti import  "com.cdyne.ws.weatherws.*" Instead? 

I don't really know anything about that third-party web service but I came across some problems when using one of my own services from a different bundle.
The thing that I had to do then was to make use of the following: 
 

MyService myService = sling.getService(MyService.class);


but that might not help in your case..

I also saw that Scott Macdonald had written some great notes about this, can probably be worth reading for you!
http://scottsdigitalcommunity.blogspot.se/2012/05/creating-adobe-cq-bundles-that-consume.html

元の投稿で解決策を見る

5 返信

Avatar

正解者
Level 7

Did you try ti import  "com.cdyne.ws.weatherws.*" Instead? 

I don't really know anything about that third-party web service but I came across some problems when using one of my own services from a different bundle.
The thing that I had to do then was to make use of the following: 
 

MyService myService = sling.getService(MyService.class);


but that might not help in your case..

I also saw that Scott Macdonald had written some great notes about this, can probably be worth reading for you!
http://scottsdigitalcommunity.blogspot.se/2012/05/creating-adobe-cq-bundles-that-consume.html

Avatar

以前のコミュニティメンバー

Yes Ojjis, it could not import Weather class itself. I am getting the below error.

org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.jsp.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 19 in the generated java file Only a type can be imported. com.cdyne.ws.weatherws.Weather resolves to a package

The Weather class available in that jar file and the  bundle status is also Active when i check the bundle status in osgi console. Please find the attached screen shot for your reference and kindly do let me know if anything wrong.

 

Thanks,

Anderson

Avatar

以前のコミュニティメンバー

Hi,

I have checked the bundle status in bundle console. It has the same folder structure. Please find the attached snap and let know what could be the problem.

Now i am getting the below exception

org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.jsp.jasper.JasperException: Unable to compile class

An error occurred at line: 5 in the jsp file: /apps/stoxx/components/content/weather/weather.jsp

com.cdyne.ws.weatherws.Weather cannot be resolved to a type

2: <%= properties.get("title", currentPage.getTitle()) %>

3: <%

4: 

5: com.cdyne.ws.weatherws.Weather ww = new com.cdyne.ws.weatherws.Weather();

Thanks.

Avatar

Level 10

This means that your server-side bundle that contains the Java proxy classes that consume the web service is not deployed to Adobe CQ. Make sure that your OSGi bundle is deployed and in a running state. Once running -- you will see it from the OSGi console and it will resemble this illustration....

 

[img]WSOSGIView.png[/img]

Once this is running -- you can invoke it from a client web page. All the steps -- including how to create and deploy the OSGi bundle -- to get this CQ web service app up and running are specified in this development article: http://scottsdigitalcommunity.blogspot.ca/2012/05/creating-adobe-cq-bundles-that-consume.html

Avatar

Level 7

Hi, sounds like something might be wrong with the finding of the class.
Just to check, is the class imported correctly on the .jsp page ?
<%@page import="com.cdyne.ws.weatherws.Weather"%>
/Johan