Can't load contextConfigLocation class on ServletContextHandler from a Service Class Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Java inner class and static nested classCreate ArrayList from arrayHow do I call one constructor from another in Java?ServletContext is null when using spring to load jetty with jersey/jax-wsWhat's the difference between @Component, @Repository & @Service annotations in Spring?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?Deploying a servlet programmatically with JettyWhat does “Could not find or load main class” mean?How to combine Jetty with embedding ServletContextHandler and AbstractHandler?Migration from CXFNonSpringJaxrsServlet to CXFServlet with Spring
Would color changing eyes affect vision?
The Nth Gryphon Number
"klopfte jemand" or "jemand klopfte"?
What is the chair depicted in Cesare Maccari's 1889 painting "Cicerone denuncia Catilina"?
How can I prevent/balance waiting and turtling as a response to cooldown mechanics
Random body shuffle every night—can we still function?
Monty Hall Problem-Probability Paradox
How much damage would a cupful of neutron star matter do to the Earth?
After Sam didn't return home in the end, were he and Al still friends?
What initially awakened the Balrog?
Why is std::move not [[nodiscard]] in C++20?
NERDTreeMenu Remapping
What is a more techy Technical Writer job title that isn't cutesy or confusing?
How many time has Arya actually used Needle?
Resize vertical bars (absolute-value symbols)
If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?
Positioning dot before text in math mode
Are the endpoints of the domain of a function counted as critical points?
Can you force honesty by using the Speak with Dead and Zone of Truth spells together?
New Order #6: Easter Egg
Why weren't discrete x86 CPUs ever used in game hardware?
Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?
What is the difference between CTSS and ITS?
Mounting TV on a weird wall that has some material between the drywall and stud
Can't load contextConfigLocation class on ServletContextHandler from a Service Class
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Java inner class and static nested classCreate ArrayList from arrayHow do I call one constructor from another in Java?ServletContext is null when using spring to load jetty with jersey/jax-wsWhat's the difference between @Component, @Repository & @Service annotations in Spring?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?Deploying a servlet programmatically with JettyWhat does “Could not find or load main class” mean?How to combine Jetty with embedding ServletContextHandler and AbstractHandler?Migration from CXFNonSpringJaxrsServlet to CXFServlet with Spring
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a project with Spring and several services. I'm trying to include a bunch of rest services in it. The thing is the embedded jetty server is within a @Service instance and for many reasons I can't touch it. So, I've tried to configure that server with my new requirements and I can't.
I've tried for discard with the classic approach outside the project logic, and it works:
public class Starter
public static void main( final String[] args ) throws Exception
Server server = new Server( 8888 );
// Register and map the dispatcher servlet
final ServletHolder servletHolder = new ServletHolder( new CXFServlet() );
final ServletContextHandler context = new ServletContextHandler();
context.setContextPath( "/" );
context.addServlet( servletHolder, "/rest/*" );
context.addEventListener( new ContextLoaderListener() );
context.setInitParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() );
context.setInitParameter( "contextConfigLocation", AppConfig.class.getName() );
server.setHandler( context );
server.start();
server.join();
But, if I try to make the same thing within a spring context Service it doesn't work.
If I use the same initialization inside it, I get:
WARN Can't find the the request for http://localhost:8888/rest/api/people's Observer
I've tried to modify in applicationContext.xml to include rest needed classes but in that case the /api/ resource was registered twice.
I'm sure I'm not understanding something :)
java spring rest
add a comment |
I have a project with Spring and several services. I'm trying to include a bunch of rest services in it. The thing is the embedded jetty server is within a @Service instance and for many reasons I can't touch it. So, I've tried to configure that server with my new requirements and I can't.
I've tried for discard with the classic approach outside the project logic, and it works:
public class Starter
public static void main( final String[] args ) throws Exception
Server server = new Server( 8888 );
// Register and map the dispatcher servlet
final ServletHolder servletHolder = new ServletHolder( new CXFServlet() );
final ServletContextHandler context = new ServletContextHandler();
context.setContextPath( "/" );
context.addServlet( servletHolder, "/rest/*" );
context.addEventListener( new ContextLoaderListener() );
context.setInitParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() );
context.setInitParameter( "contextConfigLocation", AppConfig.class.getName() );
server.setHandler( context );
server.start();
server.join();
But, if I try to make the same thing within a spring context Service it doesn't work.
If I use the same initialization inside it, I get:
WARN Can't find the the request for http://localhost:8888/rest/api/people's Observer
I've tried to modify in applicationContext.xml to include rest needed classes but in that case the /api/ resource was registered twice.
I'm sure I'm not understanding something :)
java spring rest
add a comment |
I have a project with Spring and several services. I'm trying to include a bunch of rest services in it. The thing is the embedded jetty server is within a @Service instance and for many reasons I can't touch it. So, I've tried to configure that server with my new requirements and I can't.
I've tried for discard with the classic approach outside the project logic, and it works:
public class Starter
public static void main( final String[] args ) throws Exception
Server server = new Server( 8888 );
// Register and map the dispatcher servlet
final ServletHolder servletHolder = new ServletHolder( new CXFServlet() );
final ServletContextHandler context = new ServletContextHandler();
context.setContextPath( "/" );
context.addServlet( servletHolder, "/rest/*" );
context.addEventListener( new ContextLoaderListener() );
context.setInitParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() );
context.setInitParameter( "contextConfigLocation", AppConfig.class.getName() );
server.setHandler( context );
server.start();
server.join();
But, if I try to make the same thing within a spring context Service it doesn't work.
If I use the same initialization inside it, I get:
WARN Can't find the the request for http://localhost:8888/rest/api/people's Observer
I've tried to modify in applicationContext.xml to include rest needed classes but in that case the /api/ resource was registered twice.
I'm sure I'm not understanding something :)
java spring rest
I have a project with Spring and several services. I'm trying to include a bunch of rest services in it. The thing is the embedded jetty server is within a @Service instance and for many reasons I can't touch it. So, I've tried to configure that server with my new requirements and I can't.
I've tried for discard with the classic approach outside the project logic, and it works:
public class Starter
public static void main( final String[] args ) throws Exception
Server server = new Server( 8888 );
// Register and map the dispatcher servlet
final ServletHolder servletHolder = new ServletHolder( new CXFServlet() );
final ServletContextHandler context = new ServletContextHandler();
context.setContextPath( "/" );
context.addServlet( servletHolder, "/rest/*" );
context.addEventListener( new ContextLoaderListener() );
context.setInitParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() );
context.setInitParameter( "contextConfigLocation", AppConfig.class.getName() );
server.setHandler( context );
server.start();
server.join();
But, if I try to make the same thing within a spring context Service it doesn't work.
If I use the same initialization inside it, I get:
WARN Can't find the the request for http://localhost:8888/rest/api/people's Observer
I've tried to modify in applicationContext.xml to include rest needed classes but in that case the /api/ resource was registered twice.
I'm sure I'm not understanding something :)
java spring rest
java spring rest
edited Mar 9 at 0:33
Joakim Erdfelt
33.7k46097
33.7k46097
asked Mar 8 at 23:06
kadellkadell
61
61
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Found it!
@Bean
@DependsOn( "cxf" )
public Server jaxRsServer()
JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class );
factory.setBus(cxf()); // <-- THIS!
factory.setServiceBeans( Arrays.< Object >asList( peopleRestService() ) );
factory.setProviders( Arrays.< Object >asList( jsonProvider() ) );
return factory.create();
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072237%2fcant-load-contextconfiglocation-class-on-servletcontexthandler-from-a-service-c%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Found it!
@Bean
@DependsOn( "cxf" )
public Server jaxRsServer()
JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class );
factory.setBus(cxf()); // <-- THIS!
factory.setServiceBeans( Arrays.< Object >asList( peopleRestService() ) );
factory.setProviders( Arrays.< Object >asList( jsonProvider() ) );
return factory.create();
add a comment |
Found it!
@Bean
@DependsOn( "cxf" )
public Server jaxRsServer()
JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class );
factory.setBus(cxf()); // <-- THIS!
factory.setServiceBeans( Arrays.< Object >asList( peopleRestService() ) );
factory.setProviders( Arrays.< Object >asList( jsonProvider() ) );
return factory.create();
add a comment |
Found it!
@Bean
@DependsOn( "cxf" )
public Server jaxRsServer()
JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class );
factory.setBus(cxf()); // <-- THIS!
factory.setServiceBeans( Arrays.< Object >asList( peopleRestService() ) );
factory.setProviders( Arrays.< Object >asList( jsonProvider() ) );
return factory.create();
Found it!
@Bean
@DependsOn( "cxf" )
public Server jaxRsServer()
JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class );
factory.setBus(cxf()); // <-- THIS!
factory.setServiceBeans( Arrays.< Object >asList( peopleRestService() ) );
factory.setProviders( Arrays.< Object >asList( jsonProvider() ) );
return factory.create();
answered Mar 12 at 10:10
kadellkadell
61
61
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072237%2fcant-load-contextconfiglocation-class-on-servletcontexthandler-from-a-service-c%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown