Reputation: 55
I am writing a utility jar file to be shared into multiple project. Basically it handles establishing database connection and making calculations and later return the values. Other projects will import my jar file and call my function.
Right now i am having problem when i tried to call one of the functions in the jar file.In eclipse there are no compile error but as i test it at app server i receives this error
22:16:35,177 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage RequestComplete
22:16:35,178 WARN DefaultExceptionHandler:94 - Unhandled exception caught by the Stripes default exception handler.
net.sourceforge.stripes.exception.StripesServletException: ActionBean execution threw an exception.
at net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:183)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/my/rnd/test/utils/SimplePing
at com.app.action.JbpmProcessInstanceActionBean.testTrigger(JbpmProcessInstanceActionBean.java:83)
at com.app.action.JbpmProcessInstanceActionBean.loadProcInstanceList(JbpmProcessInstanceActionBean.java:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
I export the jar file using eclipse and here's the sample function of the SimplePing
public class SimplePing {
/**
* @param args
*/
public void testSimplePing() {
// TODO Auto-generated method stub
System.out.println("This is a simple ping .");
}
}
It seems that the appserver unable to find my class even to it exists in the jar file.Any help is welcomed
Upvotes: 3
Views: 440
Reputation: 8240
If you look closely to the error stack you can see the following:
Caused by: java.lang.NoClassDefFoundError: com/my/rnd/test/utils/SimplePing
Which is a common error when you have one of the following conditions:
jar(s)
missing in your lib
jar(s)
missing from your classpath
You have some dependencies missing from your MANIFEST
file:
...
Main-Class: fully.qualified.MainClass
Class-Path: lib/dependency1-X.Y.jar lib/dependency2-W.Z.jar
...
You have a JDK
problem
Eventually all connect to the same problem: A missing jar ( JDK or third-party related jar)
You can also use maven plugin for eclipse which will manage your dependancies of your current project and your jar
able one which is needed by your project, ofcourse if you are fond of Maven.
Upvotes: 1
Reputation: 12720
Open the jar using a program like 7-zip or winzip and verify that you see this directory structure and file in it: com/my/rnd/test/utils/SimplePing.class
Upvotes: 0
Reputation: 45775
This is a good question
There are 2 ways I can think of
Try to use Maven (m2e plugin) - this will manage the dependencies for you If you do this, remember to add Maven Dependencies to the project Deployment Assembly (right click - properties)
Use Deployment Assembly and add the other project
Upvotes: 0