Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error about jsr356 when start in eclipse used RJR #216

Open
KING754 opened this issue Jun 10, 2020 · 0 comments
Open

error about jsr356 when start in eclipse used RJR #216

KING754 opened this issue Jun 10, 2020 · 0 comments

Comments

@KING754
Copy link

KING754 commented Jun 10, 2020

RJR with Jetty version
jetty version is 9.4.8v20171121

Java version
jdk 8

Question
have a error about jsr356 when start in eclipse used RJR
my project is websocket.
thanks!

the code is:
`
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;

public class WebsocketListener implements ServletContextListener {
@OverRide
public void contextDestroyed(ServletContextEvent arg0) {
}
private Server server = null;
@OverRide
public void contextInitialized(ServletContextEvent servletContextEvent) {
logger.info("initial start");
this.server = new Server(8080);
try {
ServletContext servletContext = servletContextEvent.getServletContext();
String contextPath = servletContext.getContextPath();
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath(contextPath);
server.setHandler(context);

	ServerContainer container = WebSocketServerContainerInitializer.configureContext(context);

	container.addEndpoint(EchoEndpoint.class);
	server.start();
	server.join(); // wait for server to stop
} catch (Exception e) {
	e.printStackTrace();
} finally {
	logger.info("initial end");
}

}
`

the error is :
Exception in thread "main" java.lang.LinkageError: loader constraint violation: when resolving method "org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.configureContext(Lorg/eclipse/jetty/servlet/ServletContextHandler;)Lorg/eclipse/jetty/websocket/jsr356/server/ServerContainer;" the class loader (instance of runjettyrun/ProjectClassLoader) of the current class, com/dena/server/listener/WebsocketListener, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, org/eclipse/jetty/websocket/jsr356/server/deploy/WebSocketServerContainerInitializer, have different Class objects for the type org/eclipse/jetty/servlet/ServletContextHandler used in the signature at XXX.XXXXX.listener.WebsocketListener.contextInitialized(WebsocketListener.java:51) at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:890) at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:532) at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:853) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:344) at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1515) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1477) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) at org.eclipse.jetty.server.Server.start(Server.java:418) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.server.Server.doStart(Server.java:385) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at runjettyrun.Bootstrap.main(Bootstrap.java:89)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant