Issue updating state on re-deployed Corda Enterprise App - corda

I have encountered an issue when re-deploying a Corda Enterprise app after changing some ledger code and trying to update a state created by the old deployment. Initially I encountered a Notary issue caused by the following TransactionBuilder constraint:
require(notary == this.notary) { "Input state requires notary \"$notary\" which does not match the transaction notary \"${this.notary}\"."
This was solved by using the NotaryChangeFlow. An example of my usage is below:
val inputNotary = inputState.state.notary
if(inputNotary != newNotary) {
subFlow(NotaryChangeFlow(inputState, newNotary))
}
However, I am now getting the error:
java.lang.IllegalArgumentException: Don't know about O=Party, L=Sydney, C=AU
at net.corda.node.services.statemachine.FlowMessagingImpl.sendSessionMessage(FlowMessaging.kt:65) ~[corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.ActionExecutorImpl.executeSendInitial(ActionExecutorImpl.kt:177) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.ActionExecutorImpl.executeAction(ActionExecutorImpl.kt:75) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.interceptors.MetricActionInterceptor.executeAction(MetricInterceptor.kt:31) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.TransitionExecutorImpl.executeTransition(TransitionExecutorImpl.kt:51) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.interceptors.HospitalisingInterceptor.executeTransition(HospitalisingInterceptor.kt:54) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.interceptors.DumpHistoryOnErrorInterceptor.executeTransition(DumpHistoryOnErrorInterceptor.kt:46) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.interceptors.MetricInterceptor.executeTransition(MetricInterceptor.kt:23) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.interceptors.FiberDeserializationCheckingInterceptor.executeTransition(FiberDeserializationCheckingInterceptor.kt:50) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.processEvent(FlowStateMachineImpl.kt:133) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.processEventsUntilFlowIsResumed(FlowStateMachineImpl.kt:162) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.suspend(FlowStateMachineImpl.kt:396) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.FlowSessionImpl.sendAndReceive(FlowSessionImpl.kt:64) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.FlowSessionImpl.sendAndReceive(FlowSessionImpl.kt:71) [corda-node-3.1.jar:?]
at net.corda.core.flows.DataVendingFlow.sendPayloadAndReceiveDataRequest(SendTransactionFlow.kt:81) [corda-core-3.1.jar:?]
at net.corda.core.flows.DataVendingFlow.call(SendTransactionFlow.kt:59) [corda-core-3.1.jar:?]
at net.corda.core.flows.DataVendingFlow.call(SendTransactionFlow.kt:42) [corda-core-3.1.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.subFlow(FlowStateMachineImpl.kt:281) [corda-node-3.1.jar:?]
at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:312) [corda-core-3.1.jar:?]
at net.corda.core.flows.AbstractStateReplacementFlow$Instigator.getParticipantSignature(AbstractStateReplacementFlow.kt:118) [corda-core-3.1.jar:?]
at net.corda.core.flows.AbstractStateReplacementFlow$Instigator.collectSignatures(AbstractStateReplacementFlow.kt:102) [corda-core-3.1.jar:?]
at net.corda.core.flows.AbstractStateReplacementFlow$Instigator.call(AbstractStateReplacementFlow.kt:78) [corda-core-3.1.jar:?]
at net.corda.core.flows.AbstractStateReplacementFlow$Instigator.call(AbstractStateReplacementFlow.kt:60) [corda-core-3.1.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.subFlow(FlowStateMachineImpl.kt:281) [corda-node-3.1.jar:?]
at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:312) [corda-core-3.1.jar:?]
at com.administration.ledger.flow.MemberUpdateFlow$Initiator.call(MemberFlow.kt:104) [administration-ledger-0.1.jar:0.1]
at com.administration.ledger.flow.MemberUpdateFlow$Initiator.call(MemberFlow.kt:80) [administration-ledger-0.1.jar:0.1]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:225) [corda-node-3.1.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:51) [corda-node-3.1.jar:?]
at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.10-jdk8.jar:0.7.10]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.22.Final.jar:4.1.22.Final]
I was wondering if anyone has seen this error before / knows what could be causing it. It seems related to the transaction referencing the original O=Party, L=Sydney, C=AU Party which was a participant in the initial state creation. This Flow worked fine in Corda OS but is causing problems after migrating to Enterprise.

You say in your comment above:
Just confirming the ./gradlew deployNodes command is the correct one
to re-deploy nodes after changes are made
This is incorrect. Re-running deployNodes will create a new set of nodes with a new set of certificates. This is why you're getting exceptions of the form java.lang.IllegalArgumentException: Don't know about O=Party, L=Sydney, C=AU.
You should update the CorDapp using the following process instead:
Put the node in flow-drain mode, as per the instructions here
Once flow-drain is complete, turn off the node
Build the new CorDapp JAR by following the instructions here
Install the new CorDapp JAR by following the instructions here
Restart the node

Related

States pointing to the new contract version still tries to deserialise old contract?

I have a scenario where I have upgraded my obligations from V1 to V2 and pointed to the correct V2 contracts successfully. Next I tried to do an SettleObligation on these upgraded V2 states. When the transaction is formed and sent out in CollectSignatureFlow, there's a java.lang.NoSuchMethodError found on my isGreaterThan method which is called in the verifySettle command in the contract.
This particular function initially exist on the package "com.example.base" in a file BaseHelper.kt, along the way, in V2, we migrated the function to another file MathHelper.kt, this move did not cause any unresolved references because the package is the same.
Would like to understand:
Does the contract reference the function location by file name instead of package name? and it's unchangeable once you compile the contract-v1.jar?
Why do V2 states still try to deserialise V1 contracts? Is this being done via walking the chain somehow?
Stack trace below
[WARN ] 2018-11-13T00:05:12,777Z [Node thread-1] flow.[cd538d42-1715-4ed3-bde6-38eca94ef79f].run - Flow ended due to receiving exception {}
net.corda.core.contracts.TransactionVerificationException$ContractRejection: Contract verification failed: com.example.base.BaseHelperKt.isGreaterThan(Ljava/math/BigDecimal;Ljava/math/BigDecimal;)Z,
contract: com.example.contracts.ObligationContractV1, transaction: 8B8780A16D330A93A361F747B77C227442BD310C9DAAA561376DED69F580C794
at net.corda.node.services.statemachine.FlowStateMachineImpl.erroredEnd(FlowStateMachineImpl.kt:497) ~[corda-node-3.2.1847-corda.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.confirmNoError(FlowStateMachineImpl.kt:481) ~[corda-node-3.2.1847-corda.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.waitForMessage(FlowStateMachineImpl.kt:444) ~[corda-node-3.2.1847-corda.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.receiveInternal(FlowStateMachineImpl.kt:376) ~[corda-node-3.2.1847-corda.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.receive(FlowStateMachineImpl.kt:229) ~[corda-node-3.2.1847-corda.jar:?]
at net.corda.node.services.statemachine.FlowSessionImpl.receive(FlowSessionImpl.kt:44) ~[corda-node-3.2.1847-corda.jar:?]
at net.corda.node.services.statemachine.FlowSessionImpl.receive(FlowSessionImpl.kt:48) ~[corda-node-3.2.1847-corda.jar:?]
at net.corda.core.flows.CollectSignatureFlow.call(CollectSignaturesFlow.kt:290) ~[corda-core-3.2.1847-corda.jar:?]
at net.corda.core.flows.CollectSignatureFlow.call(CollectSignaturesFlow.kt:135) ~[corda-core-3.2.1847-corda.jar:?]
at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:290) ~[corda-core-3.2.1847-corda.jar:?]
at net.corda.core.flows.CollectSignaturesFlow.call(CollectSignaturesFlow.kt:114) ~[corda-core-3.2.1847-corda.jar:?]
at net.corda.core.flows.CollectSignaturesFlow.call(CollectSignaturesFlow.kt:64) ~[corda-core-3.2.1847-corda.jar:?]
at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:290) ~[corda-core-3.2.1847-corda.jar:?]
at com.example.flows.flows.SettleObligation$Initiator.collectSignature(SettleObligation.kt:178) ~[obligation-1.0.jar:?]
at com.example.flows.flows.SettleObligation$Initiator.call(SettleObligation.kt:87) ~[obligation-1.0.jar:?]
at com.example.flows.flows.SettleObligation$Initiator.call(SettleObligation.kt:51) ~[obligation-1.0.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:96) [corda-node-3.2.1847-corda.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:44) [corda-node-3.2.1847-corda.jar:?]
at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_181]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_181]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_181]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_181]
at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:62) [corda-node-3.2.1847-corda.jar:?]
Caused by: net.corda.core.CordaRuntimeException: java.lang.NoSuchMethodError: com.example.base.BaseHelperKt.isGreaterThan(Ljava/math/BigDecimal;Ljava/math/BigDecimal;)Z
[INFO ] 2018-11-13T00:05:12,807Z [RxIoScheduler-2] network.PersistentNetworkMapCache.addNode - Previous node was identical to incoming one - doing nothing {}
[INFO ] 2018-11-13T00:05:12,807Z [RxIoScheduler-2] network.PersistentNetworkMapCache.addNode - Done adding node with info: NodeInfo
The resolveTransactionFlow.kt (when walking down the chain) will loop in sequence to fetch the Tx while verifying it. In that case one would need all the old contract codes (as a cordapp) to be present, else you won't be able to resolve the provenance of the chain.
val result = topologicalSort(newTxns)
result.forEach {
// For each transaction, verify it and insert it into the database. As we are iterating over them in a
// depth-first order, we should not encounter any verification failures due to missing data. If we fail
// half way through, it's no big deal, although it might result in us attempting to re-download data
// redundantly next time we attempt verification.
it.verify(serviceHub)
serviceHub.recordTransactions(StatesToRecord.NONE, listOf(it))
}
In Kotlin, each file is compiled to a JVM-level class. A file named Foobar.kt will become a class named FoobarKt.
When you move a top level function from one file to another, therefore, the name of the file is baked into the compiled code and such a change is not binary compatible even though it's source compatible.
Unfortunately this is one of the hidden complexities of all software development - the way the source compiler resolves symbol scopes isn't always identical to the way the runtime linker does. It happens in every language and runtime, although there are ways for the JetBrains guys to fix it in the very long run, if they choose to do so. Sorry. You'll have to move the function back, or provide an alias (look at the #JvmName annotation).

In Corda, liquibase.exception.SetupException: migration/account-application.changelog-master.xml does not exist

I have migrated from Corda Open-Source to Corda Enterprise (by adding the JARs to my local maven repository for Gradle) and made some minor adjustments to my OS project to cater for versioning. I have also created all the migration scripts but have run into a wall regarding the placement of these scripts.
I believe the scripts should be placed in the resources folder so they automatically get included in the build. I have also tried including them in the base directory for a node. However, I cannot work out the process surrounding the placement of the .xml files as I keep getting the liquibase.exception.SetupException: migration/account-application.changelog-master.xml does not exist error below:
[ERROR] 18:01:08+1000 [main] internal.Node.run - Exception during node
startup liquibase.exception.ChangeLogParseException: Error parsing
master.changelog.json at
liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:98)
~[liquibase-core-3.5.3.jar:?] at
liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:229)
~[liquibase-core-3.5.3.jar:?] at
liquibase.Liquibase.listUnrunChangeSets(Liquibase.java:1183)
~[liquibase-core-3.5.3.jar:?] at
liquibase.Liquibase.listUnrunChangeSets(Liquibase.java:1176)
~[liquibase-core-3.5.3.jar:?] at
net.corda.nodeapi.internal.persistence.SchemaMigration.doRunMigration(SchemaMigration.kt:133)
~[corda-node-api-3.1.jar:?] at
net.corda.nodeapi.internal.persistence.SchemaMigration.doRunMigration$default(SchemaMigration.kt:77)
~[corda-node-api-3.1.jar:?] at
net.corda.nodeapi.internal.persistence.SchemaMigration.checkState(SchemaMigration.kt:66)
~[corda-node-api-3.1.jar:?] at
net.corda.nodeapi.internal.persistence.SchemaMigration.nodeStartup(SchemaMigration.kt:49)
~[corda-node-api-3.1.jar:?] at
net.corda.node.internal.AbstractNodeKt.configureDatabase(AbstractNode.kt:1140)
~[corda-node-3.1.jar:?] at
net.corda.node.internal.AbstractNode.initialiseDatabasePersistence(AbstractNode.kt:852)
~[corda-node-3.1.jar:?] at
net.corda.node.internal.Node.initialiseDatabasePersistence(Node.kt:373)
~[corda-node-3.1.jar:?] at
net.corda.node.internal.AbstractNode.start(AbstractNode.kt:296)
~[corda-node-3.1.jar:?] at
net.corda.node.internal.Node.start(Node.kt:387)
~[corda-node-3.1.jar:?] at
net.corda.node.internal.EnterpriseNode.start(EnterpriseNode.kt:181)
~[corda-node-3.1.jar:?] at
net.corda.node.internal.NodeStartup.startNode(NodeStartup.kt:270)
~[corda-node-3.1.jar:?] at
net.corda.node.internal.NodeStartup.run(NodeStartup.kt:160)
[corda-node-3.1.jar:?] at net.corda.node.Corda.main(Corda.kt:25)
[corda-node-3.1.jar:?] Caused by: liquibase.exception.SetupException:
migration/account-application.changelog-master.xml does not exist at
liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:322)
~[liquibase-core-3.5.3.jar:?] at
liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:282)
~[liquibase-core-3.5.3.jar:?] at
liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:91)
~[liquibase-core-3.5.3.jar:?] ... 16 more
Where should I place the scripts and .xml files?
Your migration scripts should be placed under resources/migration, and not at the top level of the resources folder.

OSGi Spring MVC Bundle Nightmare - java.lang.ClassNotFoundException: org.springframework.context.config.ContextNamespaceHandler not found from bundle

I can not get my Spring MVC application to run as an OSGi bundle. This one has completely stumped me.
I'm trying to run a Spring 3 MVC bundle, but when starting up it can not find the namespace handlers required to use Spring. I've included the necessary import-packages, for org.springframework.context. I've checked that the org.springframework.context.config.ContextNamespaceHandler is installed on the Virgo server. There are no errors on starting the bundle in the server - so I'm pretty sure dependencies must be fulfilled.
Here's the exception I get when I try to make a request to the MVC dispatcher servlet;-
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is org.springframework.beans.FatalBeanException: NamespaceHandler class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http://www.springframework.org/schema/context] not found; nested exception is java.lang.ClassNotFoundException: org.springframework.context.config.ContextNamespaceHandler not found from bundle [com.osgi-test.spring-mvc-bundle]
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:170)
org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:140)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$301(AbstractDelegatedExecutionApplicationContext.java:60)
org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$1.run(AbstractDelegatedExecutionApplicationContext.java:168)
org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.normalRefresh(AbstractDelegatedExecutionApplicationContext.java:164)
org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$NoDependenciesWaitRefreshExecutor.refresh(AbstractDelegatedExecutionApplicationContext.java:78)
org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:157)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
javax.servlet.GenericServlet.init(GenericServlet.java:244)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
org.eclipse.virgo.web.tomcat.support.ApplicationNameTrackingValve.invoke(ApplicationNameTrackingValve.java:33)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
java.lang.Thread.run(Thread.java:722)
The Manifest file in the bundle looks like this;-
Manifest-Version: 1.0
Export-Package: com.osgi-test.external;version="0.0.1.SNAPSHOT"
Bundle-ClassPath: .,WEB-INF/classes
Built-By: seth
Tool: Bnd-1.50.0
Bundle-Name: spring-mvc-bundle
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.7.0_06
Bundle-Version: 0.0.1.SNAPSHOT
Bnd-LastModified: 1347110247719
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.osgi-test.spring-mvc-bundle
Import-Package: com.osgi-test.external,javax.servlet.http;version="
[2.4,3)",org.eclipse.virgo.web.dm;version="[3.0,4)",org.springfram
ework.context;version="[3.0,4)",org.springframework.stereotype;ver
sion="[3.0,4)",org.springframework.validation;version="[3.0,4)",or
g.springframework.web;version="[3.0,4)",org.springframework.web.bi
nd.annotation;version="[3.0,4) ",org.springframework.web.servlet;v
ersion="[3.0,4)"
Archiver-Version: Plexus Archiver
I read an article that suggested making use of the
org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext
(http://www.eclipse.org/forums/index.php/m/635463/)
might help - however made no difference for me.
I have also tried removing the ContextLoaderListener in the web.xml - but again that didn't help.
At this point, I'm lost for ideas. Any help, massively appreciated.
http://thomaskratz.blogspot.in/2012/03/osgi-spring-dispatcherservlet.html
Please check this site, I think spring has issues with registering dispatcher servlet directly. But if you use the workaround mentioned in the above blog, it should work.
I am actually adding the code snippet which I tried here for reference:
Add the following to Activator of the plugin:
Activator.context = bundleContext;
ServiceReference ref = context.getServiceReference(HttpService.class.getName());
HttpService service = (HttpService) context.getService(ref);
DispatcherServlet servlet = new DispatcherServlet();
Dictionary<String, String> initparam = new Hashtable<String, String>();
initparam.put("contextConfigLocation", "/WebContent/WEB-INF/spring-servlet.xml");
initparam.put("contextClass", "spring3osgi.BAC");
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
// this is to register the controller
service.registerServlet("/Spring3OSGi", servlet, initparam, null);
// provide alias to the WebContent folder
service.registerResources("/Spring3OSGiWebContent", "/WebContent", service.createDefaultHttpContext());
Create a class BAC
import org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext;
public class BAC extends OsgiBundleXmlWebApplicationContext {
public BAC() {
super();
setBundleContext(Activator.getContext());
}
}
I don't know much about Spring MVC, but for Spring I know there is SpringDM specially for OSGi environments. Maybe you could have a look to http://static.springsource.org/osgi/docs/1.2.1/reference/html/web.html#web:spring-mvc. Hopefully it will help you a little bit.

SmartTarget Deployment Web Service - XML deployed into root directory?

I've setup SmartTarget on a separate server and got the SmartTarget Deployment Web Service working so when content is published from Tridion, instead of dropping the XML content generated on the local file system it sends it via the web service to the server where Fredhopper is installed. All good so far...
The problem I have is the deployed XML files are being dropped in Fredhoppers root directory C:\fredhopper\instance01\FAS and not the directory where XML files are loaded from (C:\fredhopper\instance01\FAS\data\xml\incoming\batch)! The only place I've found in configuration for specifying the correct pickup directory is in the SmartTargetDeploymentWebService.properties file in SmartTargetDeploymentWebService.war, but this is setup correctly to point at C:\fredhopper\instance01\FAS\data\xml\incoming\batch
Anyone know what might be causing this? I might just be being stupid so hopefully someone with some experience will be able to point me in the right direction ;)
UPDATE: Spotted this in the logs for when the deployment service first loads:
2012-07-19 12:56:05,909 ERROR SmartTargetDeployment - Unable to load configuration for fredhopper.location
java.lang.NullPointerException: null
at java.util.Properties$LineReader.readLine(Properties.java:418) ~[na:1.6.0_23]
at java.util.Properties.load0(Properties.java:337) ~[na:1.6.0_23]
at java.util.Properties.load(Properties.java:325) ~[na:1.6.0_23]
at com.tridion.smarttarget.web.SmartTargetDeployment.<init>(SmartTargetDeployment.java:33) ~[classes/:na]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [na:1.6.0_23]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [na:1.6.0_23]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [na:1.6.0_23]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [na:1.6.0_23]
at java.lang.Class.newInstance0(Class.java:355) [na:1.6.0_23]
at java.lang.Class.newInstance(Class.java:308) [na:1.6.0_23]
at com.sun.xml.ws.api.server.InstanceResolver.createNewInstance(InstanceResolver.java:215) [webservices-rt-1.4.jar:1.0]
at com.sun.xml.ws.api.server.InstanceResolver.createDefault(InstanceResolver.java:180) [webservices-rt-1.4.jar:1.0]
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:124) [webservices-rt-1.4.jar:1.0]
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467) [webservices-rt-1.4.jar:1.0]
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253) [webservices-rt-1.4.jar:1.0]
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147) [webservices-rt-1.4.jar:1.0]
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108) [webservices-rt-1.4.jar:1.0]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3669) [tmp6105104870192773276catalina.jar:na]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4104) [tmp6105104870192773276catalina.jar:na]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759) [tmp6105104870192773276catalina.jar:na]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739) [tmp6105104870192773276catalina.jar:na]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524) [tmp6105104870192773276catalina.jar:na]
Can you check the location specified in WEB-INF/classes/SmartTargetDeploymentWebService_conf.xml?
According to the documentation, that's where the location should be set.
Generally if you find null reference exceptions in the realm of XML configuration files, it's helpful to perform schema validation of the configuration files. I don't know if the schemas are available for this specific config. #Nuno - do you know?

Eclipse RCP: ClassNotFoundException or How to make other bundle load my class

Details: I'm trying to use Jalapeno framework to connect my RCP app with Cache' database. After connection established, I'm trying to get all data from table exactly like in Jalapeno manual:
if (objManager==null) return;
DBClass cortege = null;
try {
Iterator terms = objManager.openByQuery(DBClass.class, null, null);
System.out.println("terms ok");
while (terms.hasNext()){
System.out.println("has next");
cortege = (DBClass)terms.next();
}
this code compiling, running and trowing exception
java.lang.RuntimeException: myPluginId.views.DBClass
at com.intersys.objects.POJOIterator.next(POJOIterator.java:75)
...skip...
Caused by: java.lang.ClassNotFoundException: myPlugin.views.DBClass
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.jalapeno.runtime.ObjectCopierToPojo.detach(ObjectCopierToPojo.java:76)
at com.jalapeno.runtime.ObjectCopierToPojo.findPojo(ObjectCopierToPojo.java:472)
at com.intersys.classes.CacheRootObject.detach(CacheRootObject.java:255)
at com.intersys.classes.Persistent.detach(Persistent.java:567)
at com.intersys.objects.POJOIterator.next(POJOIterator.java:59)
at terms.next();
I can't get it at all... instance of class DBClass was just created, but class cannot be loaded.
then I've tried to place this code in simple java application (not eclipse rcp) and all went ok. so I think some Eclipse part blocking class loading.
also i've tried to load class before calling terms.next();
Bundle b = Platform.getBundle("myPluginId");
try {
b.loadClass("DBClass");
} catch (ClassNotFoundException e) {
System.out.println("no class");
e.printStackTrace();
}
...and got same error. Class can not be loaded.
So, is it a known problem? Is there a solution?
Update
After some research updating the question:
How to make Jalapeno plugin to load class from My plugin?
You might want to try buddy classloading. For more info on Eclipse classloading, Alex Blewitt has written an excellent overview of the classloading system in Eclipse here. Its a few years old, but for the most part it is still relevant.
The jist of buddy classloading is this:
a plugin declares that it needs help loading classes. It does this by declaring its "buddy plugin"
the buddy plugin declares its buddy policy
when the regular loading mechanism fails, Eclipse tries to use the buddy classloading policies you have specified.
So in your case, try putting:
Eclipse-BuddyPolicy: registered
in your Jalapeno plugin's manifest.mf file
and put:
Eclipse-RegisterBuddy: id.of.jalepeno.plugin
in the manifest.mf of your plugin
I am not sure, but maybe you have to export the package in which the classes are lying.
Select in the MANIFEST "Runtime" and add all packages

Resources