question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not override crnk resource domain

See original GitHub issue

Our application is implement with a proxy (Adnovum Proxy). So when crnk generate the URL, the resource is not accessible. That’s why we want to manually override the generated domain URL to the proxy domain.

We implement a filter, followed your (documentation)[ https://www.crnk.io/releases/stable/documentation/#_integrating_using_a_filter] We change from current crnk version 1.0.20170721162741 to 2.6.20180430102904, and implement the filter and mapping just like in your documentation

web.xml

<filter>
		<filter-name>ProjwebCrnkFilter</filter-name>
		<filter-class>ch.adnovum.projweb.jsf2app.web.util.ProjwebCrnkFilter</filter-class>
		<init-param>
			<param-name>crnk.config.core.resource.domain</param-name>
			<param-value>http://www.mydomain.com</param-value>
		</init-param>
	</filter>

The project passed the compile phase, but in phase deploy to wildfly container, it throws exception

[exec] {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"WFLYCTL0080: Failed services" => 
{"jboss.undertow.deployment.default-server.default-host./projweb" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./projweb: java.lang.IllegalStateException: already set

More information in the log file:

2018-05-07 13:23:12,231 INFO  [ServerService T] [resteasy.spi.ResteasyDeployment] Deploying javax.ws.rs.core.Application: class ch.adnovum.projweb.ws.v3.RestApplication$Proxy$_$$_WeldClientProxy
2018-05-07 13:23:12,234 INFO  [ServerService T] [resteasy.spi.ResteasyDeployment] Adding class resource ch.adnovum.projweb.ws.v3.ProjectRestService from Application class ch.adnovum.projweb.ws.v3.RestApplication$Proxy$_$$_WeldClientProxy
2018-05-07 13:23:12,235 INFO  [ServerService T] [resteasy.spi.ResteasyDeployment] Adding class resource ch.adnovum.projweb.ws.v3.SnowProjectRestService from Application class ch.adnovum.projweb.ws.v3.RestApplication$Proxy$_$$_WeldClientProxy
2018-05-07 13:23:12,235 INFO  [ServerService T] [resteasy.spi.ResteasyDeployment] Adding class resource ch.adnovum.projweb.ws.v3.MoRepRestService from Application class ch.adnovum.projweb.ws.v3.RestApplication$Proxy$_$$_WeldClientProxy
2018-05-07 13:23:12,235 INFO  [ServerService T] [resteasy.spi.ResteasyDeployment] Adding class resource ch.adnovum.projweb.ws.v3.SystemRestService from Application class ch.adnovum.projweb.ws.v3.RestApplication$Proxy$_$$_WeldClientProxy
2018-05-07 13:23:12,235 INFO  [ServerService T] [resteasy.spi.ResteasyDeployment] Adding class resource ch.adnovum.projweb.ws.v3.AdnDmsRestService from Application class ch.adnovum.projweb.ws.v3.RestApplication$Proxy$_$$_WeldClientProxy
2018-05-07 13:23:12,235 INFO  [ServerService T] [resteasy.spi.ResteasyDeployment] Adding provider class ch.adnovum.projweb.ws.v2.JacksonObjectMapperProvider from Application class ch.adnovum.projweb.ws.v3.RestApplication$Proxy$_$$_WeldClientProxy
2018-05-07 13:23:12,235 INFO  [ServerService T] [resteasy.spi.ResteasyDeployment] Adding provider class ch.adnovum.projweb.ws.v2.RestCallExceptionMapper from Application class ch.adnovum.projweb.ws.v3.RestApplication$Proxy$_$$_WeldClientProxy
2018-05-07 13:23:12,280 TRACE [ServerService T] [            org.jboss.security] PBOX00354: Setting security roles ThreadLocal: null
2018-05-07 13:23:12,281 ERROR [ServerService T] [              msc.service.fail] MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./projweb: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host.
/projweb: java.lang.IllegalStateException: already set
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.IllegalStateException: already set
    at io.crnk.core.engine.internal.utils.PreconditionUtil.fail(PreconditionUtil.java:46)
    at io.crnk.core.engine.internal.utils.PreconditionUtil.verify(PreconditionUtil.java:100)
    at io.crnk.core.engine.internal.utils.PreconditionUtil.assertTrue(PreconditionUtil.java:70)
    at io.crnk.core.engine.internal.utils.PreconditionUtil.assertNull(PreconditionUtil.java:94)
    at io.crnk.core.boot.CrnkBoot.setServiceDiscovery(CrnkBoot.java:467)
    at ch.adnovum.projweb.ws.v3.RestApplication.getSingletons(RestApplication.java:45)
    at ch.adnovum.projweb.ws.v3.RestApplication$Proxy$_$$_WeldClientProxy.getSingletons(Unknown Source)
    at org.jboss.resteasy.spi.ResteasyDeployment.processApplication(ResteasyDeployment.java:499)
    at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:327)
    at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:241)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:112)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
    at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
    at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:230)
    at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:131)
    at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:511)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
    ... 6 more

2018-05-07 13:23:12,294 ERROR [management-hand] [as.controller.management-operation] WFLYCTL0013: Operation ("deploy") failed - address: ({"deployment" => "projweb-web.war"}) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.defaul
t-host./projweb" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./projweb: java.lang.IllegalStateException: already set
    Caused by: java.lang.IllegalStateException: already set"}}
2018-05-07 13:23:12,297 ERROR [management-hand] [               jboss.as.server] WFLYSRV0021: Deploy of deployment "projweb-web.war" was rolled back with the following failure message: 
{"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./projweb" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./projweb: java.lang.IllegalStateException: already set
    Caused by: java.lang.IllegalStateException: already set"}}
2018-05-07 13:23:12,319 INFO  [MSC service thr] [      connector.deployers.jdbc] WFLYJCA0019: Stopped Driver service with driver-name = projweb-web.war_org.h2.Driver_1_3
2018-05-07 13:23:12,331 TRACE [MSC service thr] [            org.jboss.security] PBOX00337: nextState for action getPolicyConfiguration: open
2018-05-07 13:23:12,331 TRACE [MSC service thr] [            org.jboss.security] PBOX00315: delete, contextID: projweb-web.war
2018-05-07 13:23:12,331 TRACE [MSC service thr] [            org.jboss.security] PBOX00337: nextState for action delete: deleted
2018-05-07 13:23:12,397 INFO  [MSC service thr] [internal.xml.ValidationXmlParser] HV000007: META-INF/validation.xml found. Parsing XML based configuration.
2018-05-07 13:23:12,461 INFO  [MSC service thr] [internal.xml.ValidationBootstrapParameters] HV000004: Using ch.adnovum.projweb.business.internal.ProjectWebMessageInterpolator as message interpolator.
2018-05-07 13:23:12,487 INFO  [ServerService T] [                  jboss.as.jpa] WFLYJPA0011: Stopping Persistence Unit (phase 2 of 2) Service 'projweb-web.war#PROJWEB-UNIT'
2018-05-07 13:23:12,529 INFO  [ServerService T] [                  jboss.as.jpa] WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'projweb-web.war#PROJWEB-UNIT'
2018-05-07 13:23:12,530 INFO  [MSC service thr] [           jboss.weld.deployer] WFLYWELD0010: Stopping weld service for deployment projweb-web.war
2018-05-07 13:23:12,718 INFO  [MSC service thr] [          as.server.deployment] WFLYSRV0028: Stopped deployment projweb-web.war (runtime-name: projweb-web.war) in 419ms
2018-05-07 13:23:12,722 INFO  [management-hand] [           jboss.as.controller] WFLYCTL0183: Service status report

This is the RestApplication.java class , the location of exception:

@ApplicationPath("/api/v3")
@ApplicationScoped
public class RestApplication extends Application {	
	@Override
	public Set<Class<?>> getClasses() {
		Set<Class<?>> classes = new HashSet<>();

		classes.add(JacksonObjectMapperProvider.class);
		classes.add(RestCallExceptionMapper.class);
		classes.add(MoRepRestService.class);
		classes.add(SystemRestService.class);
		classes.add(ProjectRestService.class);
		classes.add(SnowProjectRestService.class);
		classes.add(AdnDmsRestService.class);


		return classes;
	}

	@Override
	public Set<Object> getSingletons() {
		CrnkFeature crnk = new CrnkFeature();
		((DefaultQuerySpecUrlMapper) crnk.getUrlMapper()).setAllowUnknownAttributes(true);
		crnk.getBoot().setServiceDiscovery(new CdiServiceDiscovery());
		Set<Object> singletons = new HashSet<>();
		singletons.add(crnk);
		return singletons;
	}
}

This is weird since the exception said that the setServiceDiscovery() got a null object, but we actually instantiated it.

Can you please help us out ? Thank you

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
remmeiercommented, May 7, 2018

alternatively you can make use of CrnkFeature.setServiceUrlProvider(new ConstantServiveUrlProvider(“…”)), the property is a shortcut for it.

1reaction
remmeiercommented, May 7, 2018

sorry, did not notice that at first, but there is a mixup of servlet-based (filter in web.xml) vs jaxrs-based (CrnkFeature) setup. Only one is needed, not sure which of you actualy make use of. Probably the jaxrs one? then you have to set it up according to http://www.crnk.io/releases/stable/documentation/#_integration_with_jax_rs, meaning setting a jaxrs property with ResourceConfig. property(…)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Crnk Documentation
Crnk is a native resource-oriented rest library where resources, their relationships and repositories are the main building blocks. In that ...
Read more >
crnk-io/Lobby - Gitter
We can't use X-Forward-Headers.. and we were unsuccessful overriding domain-name (crnk resource domain name). Can you give us any possible solution for this ......
Read more >
CrnkProperties (crnk-core 2.3.20171103140100 API)
Set a boolean whether crnk will try to overwrite a value previously assigned to a relationship field that has been included in the...
Read more >
crnk-framework/HistoryResourceRepository.java at master
Contribute to crnk-project/crnk-framework development by creating an account on GitHub. ... Cannot retrieve contributors at this time ... @Override.
Read more >
Recently Active 'crnk' Questions - Stack Overflow
How to override resourcePath in CRNK json api? ... Querying on one to many relationship does not include parent table column name in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found