Hi,
I’m new to Unomi and trying it for a probable use case our team is working on.

I’ve tried to define a custom action that stores a list of items to profiles. 
I’ve created a maven module(named it poc-test) very similar to 
tweet-button-plugin<https://github.com/apache/unomi/tree/master/samples/tweet-button-plugin>
 example in samples.
I’ve created a jar, moved it to deploy directory and restarted Unomi. However, 
I’ve noticed the following errors.

Error Messages:
1.11.13 |  Bundle org.apache.unomi.poc-test [27] Error starting 
file:/Users/chay/workspace/poc/Unomi/unomi-1.6.0/deploy/poc-test-2.0.0-SNAPSHOT.jar
 (org.osgi.framework.BundleException: Unable to resolve 
org.apache.unomi.poc-test [27](R 27.0): missing requirement 
[org.apache.unomi.poc-test [27](R 27.0)] osgi.wiring.package; 
(&(osgi.wiring.package=org.apache.unomi.api)(version>=2.0.0)(!(version>=3.0.0)))
 Unresolved requirements: [[org.apache.unomi.poc-test [27](R 27.0)] 
osgi.wiring.package; (&(osgi.wiring.pa
org.osgi.framework.BundleException: Unable to resolve org.apache.unomi.poc-test 
[27](R 27.0): missing requirement [org.apache.unomi.poc-test [27](R 27.0)] 
osgi.wiring.package; 
(&(osgi.wiring.package=org.apache.unomi.api)(version>=2.0.0)(!(version>=3.0.0)))
 Unresolved requirements: [[org.apache.unomi.poc-test [27](R 27.0)] 
osgi.wiring.package; 
(&(osgi.wiring.package=org.apache.unomi.api)(version>=2.0.0)(!(version>=3.0.0)))]
        at 
org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4149) 
~[org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2119) 
~[org.apache.felix.framework-5.6.12.jar:?]
        at 
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1373) 
[org.apache.felix.framework-5.6.12.jar:?]
        at 
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
 [org.apache.felix.framework-5.6.12.jar:?]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_292]


org.osgi.framework.BundleException: Unable to resolve org.apache.unomi.poc-test 
[27](R 27.1): missing requirement [org.apache.unomi.poc-test [27](R 27.1)] 
osgi.wiring.package; 
(&(osgi.wiring.package=org.apache.commons.beanutils)(version>=1.9.0)(!(version>=2.0.0)))
 Unresolved requirements: [[org.apache.unomi.poc-test [27](R 27.1)] 
osgi.wiring.package; 
(&(osgi.wiring.package=org.apache.commons.beanutils)(version>=1.9.0)(!(version>=2.0.0)))]
        at 
org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4149) ~[?:?]
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2119) ~[?:?]
        at 
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1373) ~[?:?]
        at 
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
 ~[?:?]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_292]

Following is the source file and pom file.

Source file:
import org.apache.unomi.api.*;
import org.apache.unomi.api.actions.Action;
import org.apache.unomi.api.actions.ActionExecutor;
import org.apache.unomi.api.services.EventService;
import org.apache.unomi.api.services.ProfileService;

import java.util.List;
import java.util.Map;

public class CustomListAction implements ActionExecutor {

    private ProfileService service;

    @Override
    public int execute(Action action, Event event) {
        final Profile profile = event.getProfile();
        List<String> myList = (List<String>) profile.getProperty("myList");

        if (myList == null) {
            PropertyType propertyType = new PropertyType(new 
Metadata(event.getScope(), "myList", "myList", "List of all porducts viewed"));
            propertyType.setValueTypeId("list");
            propertyType.setTarget("target");
            service.setPropertyType(propertyType);
        }

        final List<String> updatedList = updateMyList(event, myList);

        profile.setProperty("myList", updatedList);

        return EventService.PROFILE_UPDATED;
    }

    private List<String> updateMyList(Event event, List<String> myList) {
        final Map<String, Object> properties = event.getProperties();

        String productId = (String) properties.get("productId");
        if (myList.contains(productId)) {
            myList.remove(productId);
        }
        myList.add(0, productId);

        return myList;
    }
}


Pom file:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0";

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";

         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>

    <parent>

        <artifactId>samples</artifactId>

        <groupId>org.apache.unomi</groupId>

        <version>2.0.0-SNAPSHOT</version>

    </parent>

    <modelVersion>4.0.0</modelVersion>



    <artifactId>poc-test</artifactId>



    <properties>

        <maven.compiler.source>8</maven.compiler.source>

        <maven.compiler.target>8</maven.compiler.target>

    </properties>



    <dependencies>

        <dependency>

            <groupId>org.apache.unomi</groupId>

            <artifactId>unomi-api</artifactId>

            <version>2.0.0-SNAPSHOT</version>

            <scope>provided</scope>

        </dependency>

    </dependencies>





    <build>

        <plugins>

            <plugin>

                <groupId>org.apache.felix</groupId>

                <artifactId>maven-bundle-plugin</artifactId>

                <version>5.1.1</version>

                <extensions>true</extensions>

                <configuration>

                    <instructions>



                    </instructions>

                </configuration>

            </plugin>

        </plugins>

    </build>

</project>


The jar that I built contains org.apache.commons.beanutils package even though 
the error says otherwise.
Please help me in understanding what the issue is.

Thanks,
Chandra Sekhar.

This message and its attachments are for the designated recipient only and may 
contain proprietary or otherwise confidential information. If you have received 
this message in error, please notify the sender immediately and delete the 
original. Any other sharing, copying or use of this message by you is strictly 
prohibited.

Reply via email to