• Welcome to KonaKart Community Forum. Please login or sign up.
 

New classes not being recognized, causing exceptions

Started by mvittiglio, July 02, 2020, 06:41:13 pm

Previous topic - Next topic

mvittiglio

Hey folks, I'm new to KonaKart and I'm dipping my toe into integrating an external tool into the BaseAction class. However, even with a simple addition that should require no imports (creating a static class definition in the BaseAction class itself for example)  results in a successful build but exceptions get thrown at runtime (see below). The question I have is if there's an additional step required to introduce new classes into the pipeline.

Root Cause

java.lang.NoClassDefFoundError: com/konakart/actions/FeatureFlagSupport
com.konakart.actions.BaseAction.getKKAppEng(BaseAction.java:298)
com.konakart.actions.CatalogMainPageAction.execute(CatalogMainPageAction.java:48)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:446)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:285)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.konakart.actions.interceptors.LoggingInterceptor.intercept(LoggingInterceptor.java:30)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
org.apache.struts2.json.JSONInterceptor.intercept(JSONInterceptor.java:248)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:544)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
com.konakart.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:29)

Any help would be most welcome. :-)

Brian

Could it be that you simply aren't deploying the new class that is generated when you compile the modified BaseAction class?  Maybe you will have to modify the ANT build script to include your new class file in the target jar?

mvittiglio

Thanks for getting back to me. I've tried to do the following build commands `../bin/stopkonakart.sh && ./bin/kkant -f ./build.xml build && ./bin/kkant -f ./build.xml copy_jars && ./bin/kkant -f ./build.xml make_wars && ../bin/startkonakart.sh` but it seems that the class is still not being found. What's stranger still is that the class is a public static member of BaseAction which means that it should be considered a part of the BaseAction class that's already being used. Is there some manifest that needs to be updated to include this new class?

Brian

I refer back to my first reply... 

"Could it be that you simply aren't deploying the new class that is generated when you compile the modified BaseAction class?  Maybe you will have to modify the ANT build script to include your new class file in the target jar?"

If the class isn't being found by the ANT build it won't be added to any of the jars and then copied to your webapps.

Look for the missing class file after compilation. It might be called BaseAction$FeatureFlagSupport.class for example.  Did your new class file get included in the jar? I suspect not.  If not, you need to modify the ANT build file to add it to the required jar.


BTW. You probably don't want to create wars in your case (no need to run  ./bin/kkant -f ./build.xml make_wars).

mvittiglio

Brian,
Thanks for your patience through this. I figured it out and you were correct. I had to find the place where the JAR was being created and explicitly point it to the class files. Issue resolved. The build.xml's target "make_jar_custom" needed to have the following added: `<include name="com/konakart/**/*.class" />`

Jaziro

Quote from: mvittiglio on July 10, 2020, 08:18:28 pmBrian,
Thanks for your patience through this. I figured it out and you were correct. I had to find the place where the JAR was being created and explicitly point it to the class files. Issue resolved. The build.xml's target "make_jar_custom" needed to have the following added: `<include name="com/konakart/**/*.class" />`

Thank you for posting a solution, I had a similar issue and was trying to figure it out for a while in my house in Larnaca and now I know how I can fix it.

Jaziro

Quote from: Jaziro on October 16, 2020, 05:32:48 pm
Quote from: mvittiglio on July 10, 2020, 08:18:28 pmBrian,
Thanks for your patience through this. I figured it out and you were correct. I had to find the place where the JAR was being created and explicitly point it to the class files. Issue resolved. The build.xml's target "make_jar_custom" needed to have the following added: `<include name="com/konakart/**/*.class" />`

Thank you for posting a solution, I had a similar issue and was trying to figure it out for a while in my house in Larnaca here and now I know how I can fix it.

Will try it this weekend

Brian

Just a word of caution...

When modifying the build.xml ANT file to define which class files go into which jars be very careful to ensure that classes only end up in one jar and not more than one.

The default build.xml ANT file ensures this is the case.