Liferay 7.0 service builder: how to properly reference entity from another module - liferay-7

I'm new to liferay, trying some simple form creation.
First I created Dictionaries module with several dictionaries. They are all similar: TBL_NAME {id, description}. It worked well, tables within DB was created.
Then I created second module (service builder type) and tried to reference some fields to that dictionaries (one-to-many).
But I keep getting "Unable to find X in Y" error on build.
They are both in the same package-path. I tried to put them into the same namespace, added dictionary project to build path, even added
compileOnly project(":modules:dictionary:dictionary-api")
compileOnly project(":modules:dictionary:dictionary-service")
to build.gradle.
<service-builder package-path="my.path">
<namespace>TN</namespace>
<entity name="Tblname" local-service="true" table="_TBLNAME">
<column name="city" type="Collection" entity="my.path.City"></column>
<!-- References -->
<reference package-path="my.path" entity="City" />
What I'm doing wrong?
Also - should they both have the same namespace ("TN")?

The modules should have a different namespace and most importantly different package. Otherwise, you run into split bundle scenario.

Related

ClassCastException with ECIConnectionFactory running in Liberty

The problem - I am receiving the following message:
java.lang.ClassCastException: com.ibm.connector2.cics.ECIConnectionFactory incompatible with com.ibm.connector2.cics.ECIConnectionFactory
I am receiving it when trying to make the following statement:
eisDci = (ECIConnectionFactory)ctx.lookup(eisn);
The 'eisDci' has been defined previously:
private static ECIConnectionFactory eisDci = null;
And the 'eisn' is the String with the name of the conection like 'eis/DCIXxxxECI'
These connection is defined in the Server.xml:
<connectionFactory id="DCIXxxxECI" jndiName="eis/DCIXxxxECI">
<properties.cicseci ServerName="XXXX" TPNName="xx" connectionUrl="url" portNumber="2006"/>
</connectionFactory>
I understand that this is warning me that the cast is not possible. What I don't know is what I'm doing wrong. That must be comparing one version of the ECIConnectionFactory class with a different version of ECIConnectionFactory.
The server I'm working with is a Liberty, I'm going crazy, I can't figure out why Eclipse is comparing two different versions.
Similar problems I have searched for:
ClassCastException when casting to the same class
Waxwing's answer seems good, but I don't have access to make those changes, This connection is carried out by an external library.
First Thank you for your answer Ben Cox, in Liberty's server.xml (for LOCAL) I have declared the library:
<fileset caseSensitive="false" dir="C:\CICSECI"/>
And in the Liberty Runtime/Shared/resources I have cicseci.rar which I have declared in the server.xml as a resourceAdapter:
<resourceAdapter autoStart="true" id="cicseci" location="${shared.resource.dir}/cicseci.rar">
<classloader apiTypeVisibility="spec, ibm-api, api, third-party"/>
</resourceAdapter>
I have checked the rest of the libraries that I am importing into the project, and so far I have not seen that I have the repeated library.
I think the issue here has to do with classloading between your resource adapter and your application. This is something we more commonly see with DataSources but the results are the same.
The problem is that the same jar is being loaded by two different classloaders. One classloader for the resource adapter, and another classloader for your application. The solution is to use a commonLibraryRef
<library id=cicseci>
<file name="${shared.resource.dir}/cicseci.rar"/>
</library>
<resourceAdapter autoStart="true" id="cicseciRA">
<classloader commonLibraryRef="cicseci"/>
</resourceAdapter>
<connectionFactory id="DCIXxxxECI" jndiName="eis/DCIXxxxECI">
<properties.cicseci ServerName="XXXX" TPNName="xx" connectionUrl="url" portNumber="2006"/>
</connectionFactory>
<!-- Location of app that is trying to cast ECIConnectionFactory -->
<application location="${shared.resource.dir}/cicseci.rar">
<classloader commonLibraryRef="cicseci"/>
</application>
In this configuration, the cicseci.rar will only be loaded once.
ClassCastException can happen when the same class is loaded by two different class loaders, making what otherwise looks like the same class incompatible.
The mechanism that you should be using to avoid this involves configuring the application's class loader with a classProviderRef to the resourceAdapter, which is documented here. For example,
<application location=...>
<classloader classProviderRef="cicseci"/>
</application>
Already resolved
I import global libraries from different directories of my computer, in two of them the libraries were repeated with different versions, the obsolete versions were renamed, but it doesn't matter, the system recognized them as .jar and loaded them, producing the conflict.
I deleted the leftover libraries and it started working.
You have helped me a lot, and for that, Thank you.

GWT module xml source element to specify single class

I have a GWT application (FooGwtApp) and a library module (FooLib) used as a dependency in FooGwtApp. The package structure of FooLib looks like this:
packageFoo.ImportantClass
packageFoo.UnimportantClass
packageBar.OtherClass
I want ImportantClass (and only ImportantClass) to be compiled to JS by the GWT compiler. Moving ImportantClass to another package is not an option.
I created ImportantClass.gwt.xml within packageFoo with the following content:
<module>
<inherits name="com.google.gwt.user.User"/>
<source path="" includes="**/ImportantClass*"/>
</module>
Next I put an inherited reference to the ImportantClass module definition in FooGwtApp.gwt.xml (this seems to work: the IDE recognizes it, and is able to parse the reference to ImportantClass.gwt.xml).
Now If I put references to ImportantClass into FooGwtApp's client code, the GWT compiler fails, because it does not find ImportantClass on the source path:
No source code is available for type packageFoo.ImportantClass; did you forget to inherit a required module?
I likely messed up sommething in the source path / includes attribute in ImportantClass.gwt.xml - either defining the current package as root package with path="" is not a valid notation or something's wrong with the includes attribute. Or both. Or neither.
Can you give me a clue about where it all went wrong?
It turns out the problem was not in ImportantClass.gwt.xml, but in other Maven related stuff:
ImportantClass.gwt.xml should be placed under src/main/resources/packageFoo, not src/main/java/packageFoo, otherwise it won't be packaged into the binary jar.
GWT compiler compiles from Java source to Javascript source. This means we don't just need ImportantClass.class in FooLib.jar, but also its source. Best solution for this is to use maven-source-plugin in FooLib's pom.xml and also to import the FooLib dependency into FooGwtApp with sources classifier.
On the latter topic, see the following SO answers:
Maven: Distribute source code with with jar-with-dependencies
How to properly include Java sources in Maven?
After fixing the above problems, the source path declaration present in the question works.

What is the physical path of Odoo webserver?

I'm building a custom odoo module that will be using several Javascript libraries.
I need to add references to those libraries (local references) but I don't know exactly where to place those libraries and how to refer to their location.
What I tried:
- I created the new module and placed the libraries inside the module directory but it didn't work.
- I also placed the libraries in the home directory of odoo.
As I understand, the problem would be solved if I could get the default directory of the webserver that odoo runs on.
If module is using js files, then you must put these files inside your module. And still if you cant reach these files from your module its your technical error and you have to fix it yourself, also note that odoo has its js libraries already
I found this page: how to add css and js files in Openerp 7 / Odoo module maybe can help you.
Below is the content.
Store files correctly:
CSS and JS files should be reside under 'static' directory in the module(the rest of subdirectory tree under 'static' is an optional convention):
static/src/css/your_file.css
static/src/js/your_file.js
Add files in manifest (v7.0) or in XML(v8.0)
Openerp v7.0 way is to add following entries in manifest (in openerp.py):
...
'css': ['static/src/css/your_file.css'],
'js': [static/src/js/your_file.js'],
...
Odoo v8.0 way is to add corresponding record in the XML:
Add XML to the manifest (openerp.py):
...
'data': [ 'your_file.xml'],
...
Then add following record in 'your_file.xml':
<data>
<template id="assets_backend" name="your_module_name assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel='stylesheet' href="/your_module_name/static/src/css/your_file.css"/>
<script type="text/javascript" src="/your_module_name/static/src/js/your_file.js"></script>
</xpath>
</template>
....
....
</data>

specflow plugin with nunit and TFS build

I am in the middle of trying to get specflow UI tests working with TFS build and I am very very close.
I wanted to be able to run the same test on a number of browsers, and so after some research I found this:
http://www.baseclass.ch/blog/Lists/Beitraege/Post.aspx?ID=4&mobile=0
And it works like a dream for local test runs. the next step was to get this to call a selenium grid during a TFS 2010 build.
After getting the nunit community build task into my build template, I am now stuck with an error I can't seem to resolve. The build reports the following error:
Error: The system cannot find the file specified. Stack Trace: at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at TfsBuildExtensions.Activities.CodeQuality.NUnit.RunProcess(String fullPath, String workingDirectory, String arguments) in d:\Projects\CodePlex\teambuild2010contrib\CustomActivities\Legacy\VS2010\Source\Activities\CodeQuality\NUnit\NUnit.cs:line 339 at TfsBuildExtensions.Activities.CodeQuality.NUnit.PublishMSTestResults(String resultTrxFile, String collectionUrl, String buildNumber, String teamProject, String platform, String flavor) in d:\Projects\CodePlex\teambuild2010contrib\CustomActivities\Legacy\VS2010\Source\Activities\CodeQuality\NUnit\NUnit.cs:line 394 at TfsBuildExtensions.Activities.CodeQuality.NUnit.PublishTestResultsToTFS(ActivityContext context, String folder) in d:\Projects\CodePlex\teambuild2010contrib\CustomActivities\Legacy\VS2010\Source\Activities\CodeQuality\NUnit\NUnit.cs:line 387 at TfsBuildExtensions.Activities.CodeQuality.NUnit.InternalExecute() in d:\Projects\CodePlex\teambuild2010contrib\CustomActivities\Legacy\VS2010\Source\Activities\CodeQuality\NUnit\NUnit.cs:line 299 at TfsBuildExtensions.Activities.BaseCodeActivity.Execute(CodeActivityContext context) in d:\Projects\CodePlex\teambuild2010contrib\CustomActivities\Legacy\VS2010\Source\Common\BaseCodeActivity.cs:line 67.
however, this seems to be masking a deeper error as to me it simply says that nunit can't load a custom assembly. So I had a look through the binaries folder on the build server for the nunit logs, and sure enough in my test run .xml file I find another error:
System.Configuration.ConfigurationErrorsException : The type 'OpenQA.Selenium.Remote.RemoteWebDriver, Baseclass.Contrib.SpecFlow.Selenium.NUnit.SpecFlowPlugin' could not be found. It may require assembly qualification, e.g. "MyType, MyAssembly".
at Autofac.Configuration.ConfigurationRegistrar.LoadType(String typeName, Assembly defaultAssembly)
at Autofac.Configuration.ConfigurationRegistrar.RegisterConfiguredComponents(ContainerBuilder builder, SectionHandler configurationSection)
at Autofac.Configuration.ConfigurationRegistrar.RegisterConfigurationSection(ContainerBuilder builder, SectionHandler configurationSection)
at Autofac.Configuration.Core.ConfigurationModule.Load(ContainerBuilder builder)
at Autofac.Module.Configure(IComponentRegistry componentRegistry)
at Autofac.ContainerBuilder.Build(IComponentRegistry componentRegistry, Boolean excludeDefaultModules)
at Autofac.ContainerBuilder.Build(ContainerBuildOptions options)
at RegistrationForm.Tests.Acceptance.Features.UserRegistrationFeature.FeatureSetup() in c:\Builds\1\Testing\RegistrationForm - Nightly - Main\Sources\Testing\RegistrationForm\Main\RegistrationForm.Tests.Acceptance\Features\UserRegistration.feature.cs:line 0
From this I started to look at the path to the custom assembly. This is specified in the app.config file for the project (which is transformed during the build. I also checked to ensure the file is being transformed, and in the binaries directory on the build server it is). the relevant section of the file is this.
<specFlow>
<stepAssemblies>
<stepAssembly assembly="SpecFlow.Assist.Dynamic" />
<stepAssembly assembly="Baseclass.Contrib.SpecFlow.Selenium.NUnit.Bindings" />
</stepAssemblies>
<unitTestProvider name="SeleniumNUnit" />
<plugins>
<add name="Baseclass.Contrib.SpecFlow.Selenium.NUnit" path="..\packages\Baseclass.Contrib.SpecFlow.Selenium.NUnit.1.2.0\tools" />
</plugins>
Which works locally. I figured I just need to change the path in the transformed file. At first I assumed the working directory was the binaries directory so in the transform file I have this:
<specFlow>
<plugins xdt:Transform="Replace">
<add name="Baseclass.Contrib.SpecFlow.Selenium.NUnit" path="." />
</plugins>
The dll is in the same dir (binaries) so I tried ".", "", ".\" - none of these worked. So after thinking a little more and reading the errors more carefully I thought I needed to look in the Sources folder on the build server. The Dll is in the packages folder (nuget package restore), and so the path should be the same as I use locally. this didn't work either. So what about a path relative to the ".feature" file throwing the error? this simply needed an extra "..\" - still no luck.
So i am at a bit of a loss, I feel I have tried all the paths i can think of, but my knowledge of specflow plugins and TFS build is letting me down. can anyone give me any pointers?
But the initial error is basically saying the TFSs nunit support cant find a file when it calls CreateProcess, and as you say it works for local test runs, so is it as simple as NUnit isn't installed on the machine that is running the test for you?
I got there in the end!
So somewhere along the lines of setting this up I endded up with something like this in my app.config:
<component
name="IE"
type="Baseclass.Contrib.SpecFlow.Selenium.NUnit.RemoteWebDriver, Baseclass.Contrib.SpecFlow.Selenium.NUnit.SpecFlowPlugin"
service="OpenQA.Selenium.Remote.RemoteWebDriver, WebDriver"
instance-scope="per-dependency">
<parameters>
<parameter name="browser" value="InternetExplorer" />
<parameter name="url" value="http://192.168.1.3:4444/wd/hub" />
</parameters>
</component>
The problem (as it says in the error) is that it could not find OpenQA.Selenium.Remote.RemoteWebDriver. I belive I saw this in one of the examples I found on the bassclass page. After changing it to OpenQA.Selenium.IWebDriver everything worked fine, and nUnit was able to run my specFlow tests on my TFS 2010 build server. I did hit another snag in that when the build tried to parse the results, it tried to use MSTest 11 rather than 10 (prob because I was using VS 2012). However, this TFS machine was just a proof of concept and was a windows 2008 32bit edition running on Virtual PC on windows 7. (I could therfor not run 64bit, and so could not install VS2012 on my build server). I resolved this by creating a new environment variable for MStest 11 and pointing it at MSTest 10. The entire process now works perfectly.

xjc errors out when using scd in binding customization

When customizing a binding using scd, non-Sun jaxb plugins are not recognized
For example, this does NOT work:
<jaxb:bindings
scd="/~fpml:TradeHeader">
<ext:interfaces>
example.TradeHeaderDelegateInterface
</ext:interfaces>
</jaxb:bindings>
However, this works:
<jaxb:bindings
schemaLocation="../schemas/fpml-5-1/fpml-doc-5-1.xsd"
node="/xsd:schema//xsd:complexType[#name='TradeHeader']">
<ext:interfaces>
example.TradeHeaderDelegateInterface
</ext:interfaces>
</jaxb:bindings>
and, this works:
<jaxb:bindings
scd="/~fpml:CommodityMarketDisruption//fpml:marketDisruptionEvent">
<jaxb:property name="marketDisruptionEvent"/>
</jaxb:bindings>
which makes me think that scd and third party plugins don't get along:
The error I get is:
[ERROR] Error while parsing schema(s).Location [ file:/C:/projects/domain-fpml-5-1/src/main/resources/xjb/fpml-5-1.xjb{40,19}].
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ext:interfaces'.
My .xjb file does declare the namespace for the "ext" prefix, so that's not the issue.
Has anyone worked with xjc plugins (e.g. the jaxb commons ones like Copyable etc.) and gotten it to work with scd based customization?
My xjc version is: 2.2.2 and I'm using the maven-jaxb2-plugin (version 0.8.0) plugin to generate bindings.
Thanks for any help,
aravind
maven-jaxb22-plugin:jar:0.8.1:runtime, com.sun.xml.bind:jaxb-impl:jar:2.2.5-b10:runtime, com.sun.xml.bind:jaxb-xjc:jar:2.2.5-b10:runtime] still exhibit this issue.
From looking at the xjc source code (some time ago) this is NOT an easy fix, because the customizations are not "imported" into the target xsd and the processing occurs in the context of the matched component.
This is the case with the Schema parser where by the schema is "imported" into the bindings context so all the namespaces are valid.
I have reverted all customizations back to schema style. I remember this had painful implications when trying to do both wsdl and xsd in the same bindings file.