I just added a custom predicate class to my project and the maven build just broke with this error. Do I need to add some more dependencies ?
[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.21.0:scr (generate-scr-descriptor) on project data-providers: Execution generate-scr-descriptor of goal org.apache.felix:maven-scr-plugin:1.21.0:scr failed: An API incompatibility was encountered while executing org.apache.felix:maven-scr-plugin:1.21.0:scr: java.lang.VerifyError: Constructor must call super() or this() before return
[ERROR] Exception Details:
[ERROR] Location:
[ERROR] com/day/cq/search/eval/AbstractPredicateEvaluator.<init>()V #1: return
[ERROR] Reason:
[ERROR] Error exists in the bytecode
[ERROR] Bytecode:
[ERROR] 0x0000000: 2ab1
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.felix:maven-scr-plugin:1.21.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/rmahna/.m2/repository/org/apache/felix/maven-scr-plugin/1.21.0/maven-scr-plugin-1.21.0.jar
[ERROR] urls[1] = file:/C:/Users/rmahna/.m2/repository/org/apache/maven/maven-archiver/2.2/maven-archiver-2.2.jar
[ERROR] urls[2] = file:/C:/Users/rmahna/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[3] = file:/C:/Users/rmahna/.m2/repository/org/codehaus/plexus/plexus-archiver/1.0-alpha-7/plexus-archiver-1.0-alpha-7.jar
[ERROR] urls[4] = file:/C:/Users/rmahna/.m2/repository/org/apache/felix/org.apache.felix.scr.generator/1.13.0/org.apache.felix.scr.generator-1.13.0.jar
[ERROR] urls[5] = file:/C:/Users/rmahna/.m2/repository/org/ow2/asm/asm-all/5.0.2/asm-all-5.0.2.jar
[ERROR] urls[6] = file:/C:/Users/rmahna/.m2/repository/org/osgi/org.osgi.core/4.2.0/org.osgi.core-4.2.0.jar
[ERROR] urls[7] = file:/C:/Users/rmahna/.m2/repository/org/osgi/org.osgi.compendium/4.2.0/org.osgi.compendium-4.2.0.jar
[ERROR] urls[8] = file:/C:/Users/rmahna/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] urls[9] = file:/C:/Users/rmahna/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.8/plexus-utils-1.5.8.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[project>com.kpmg.cmi.bundles:data-providers:2.0.4, parent: ClassRealm[maven.api, parent: null]]]
[ERROR]
[ERROR] -----------------------------------------------------
My sample Java class is below. I've removed the business logic but even this exact file causes the error.
package my.project.custom.predicates;
import java.util.Comparator;
import javax.jcr.query.Row;
import org.apache.felix.scr.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.search.Predicate;
import com.day.cq.search.eval.AbstractPredicateEvaluator;
import com.day.cq.search.eval.EvaluationContext;
#Component(metatype =false, factory="com.day.cq.search.eval.PredicateEvaluator/mypredicate_eval")
public class MyCustomPredicate extends AbstractPredicateEvaluator {
private static final Logger log = LoggerFactory.getLogger(MyCustomPredicate.class);
public static final String MY_PROPERTY = "my_property";
#Override
public boolean includes(Predicate predicate, Row row, EvaluationContext context) {
if(predicate.hasNonEmptyValue(MY_PROPERTY)){
return true;
}
return super.includes(predicate, row, context);
}
#Override
public String getXPathExpression(Predicate predicate, EvaluationContext context) {
if(!predicate.hasNonEmptyValue(MY_PROPERTY)){
return null;
}
/**
* Some generic string comparisons and processing
*/
return super.getXPathExpression(predicate, context);
}
#Override
public Comparator<Row> getOrderByComparator(final Predicate predicate, final EvaluationContext context) {
return new Comparator<Row>() {
public int compare(Row r1, Row r2) {
String[] property1;
String[] property2;
try {
log.info("inside try method");
//lots of string comparisons
} catch (Exception e) {
log.error(e.getMessage());
e.printStackTrace();
}
return 1;
}
};
}
}
I see that you're using the maven-scr-plugin. This plugin has been entirely replaced by standard annotations for the last two releases of the OSGi specification and is now in maintenance mode. My recommendation would be to use the standard annotations instead. The standard annotations are very similar in their use, and will be processed by tools such as the bnd-maven-plugin or maven-bundle-plugin. You are almost certainly already using one of these plugins - the current version (at time of writing) for both plugins is 3.5.0. I would recommend using this version if you need to process Java 8 or Java 9 byte code.
The resulting file will look like this:
package my.project.custom.predicates;
import java.util.Comparator;
import javax.jcr.query.Row;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.search.Predicate;
import com.day.cq.search.eval.AbstractPredicateEvaluator;
import com.day.cq.search.eval.EvaluationContext;
#Component
public class MyCustomPredicate extends AbstractPredicateEvaluator {
// Your implementation in here
}
Related
I am trying to learn how to test custom resource watcher in the Fabric8, I follow the example from this link https://github.com/r0haaaan/kubernetes-mockserver-demo/blob/master/src/test/java/io/fabric8/demo/kubernetes/mockserver/CustomResourceMockTest.java
My custom resource is "UserACL", I am using Java junit5, this is my fabric8 version.
implementation group: 'io.fabric8', name: 'kubernetes-client', version: '5.9.0'
implementation group: 'io.fabric8', name: 'kubernetes-api', version: '3.0.12'
testImplementation group: 'io.fabric8', name: 'kubernetes-server-mock', version: '5.9.0'
This test case failed, seem there is no any WatchEvent emitted, so countLatch never count down.
Could anybody help take a look and point out what's wrong here? Anything is missing in the following code. I appreciate it in advanced.
import io.fabric8.kubernetes.api.model.Condition;
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.api.model.WatchEvent;
import io.fabric8.kubernetes.api.model.WatchEventBuilder;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import io.fabric8.kubernetes.internal.KubernetesDeserializer;
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.Kind;
import io.fabric8.kubernetes.model.annotation.Version;
import io.vertx.junit5.VertxExtension;
import java.net.HttpURLConnection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
public class TestKafkaHelperUtilFourth {
#Rule
public KubernetesServer server = new KubernetesServer(true, true);
#Test
#DisplayName("Should watch all custom resources")
public void testWatch() throws InterruptedException {
// Given
server.expect().withPath("/apis/custom.example.com/v1/namespaces/default/useracls?watch=true")
.andUpgradeToWebSocket()
.open()
.waitFor(10L)
.andEmit(new WatchEvent(getUserACL("test-resource"), "ADDED"))
.waitFor(10L)
.andEmit(new WatchEventBuilder()
.withNewStatusObject()
.withMessage("410 - the event requested is outdated")
.withCode(HttpURLConnection.HTTP_GONE)
.endStatusObject()
.build()).done().always();
KubernetesClient client = server.getClient();
MixedOperation<
UserACL,
KubernetesResourceList<UserACL>,
Resource<UserACL>>
userAclClient = client.resources(UserACL.class);
// When
CountDownLatch eventRecieved = new CountDownLatch(1);
KubernetesDeserializer.registerCustomKind("custom.example.com/v1", "UserACL", UserACL.class);
Watch watch = userAclClient.inNamespace("default").watch(new Watcher<UserACL>() {
#Override
public void eventReceived(Action action, UserACL userAcl) {
if (action.name().contains("ADDED"))
eventRecieved.countDown();
}
#Override
public void onClose(WatcherException e) { }
});
// Then
eventRecieved.await(20, TimeUnit.SECONDS);
Assertions.assertEquals(0, eventRecieved.getCount());
watch.close();
}
private UserACL getUserACL(String resourceName) {
UserACLSpec spec = new UserACLSpec();
spec.setUserName("test-user-name");
UserACL createdUserACL = new UserACL();
createdUserACL.setMetadata(
new ObjectMetaBuilder().withName(resourceName).build());
createdUserACL.setSpec(spec);
Condition condition = new Condition();
condition.setMessage("Last reconciliation succeeded");
condition.setReason("Successful");
condition.setStatus("True");
condition.setType("Successful");
UserACLStatus status = new UserACLStatus();
status.setCondition(new Condition[]{condition});
createdUserACL.setStatus(status);
return createdUserACL;
}
#Group("custom.example.com")
#Version("v1")
#Kind("UserACL")
public static final class UserACL
extends CustomResource<UserACLSpec, UserACLStatus> {
}
public static final class UserACLSpec {
private String userName;
public UserACLSpec() {}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
public static final class UserACLStatus {
Condition[] condition;
public UserACLStatus() {};
public Condition[] getCondition() {
return condition;
}
public void setCondition(Condition[] condition) {
this.condition = condition;
}
}
}
I checked your code; after resolving these problems I was able to get test working:
You're setting MockServer expectations using server.expect() for mocking watch call. But you've initialized KubernetesMockServer to enable CRUD mode (this doesn't require any expectations). You need to do this instead (see false being passed as second argument which disables CRUD mode):
#Rule
public KubernetesServer server = new KubernetesServer(true, false);
In Watch expectations path I can see that UserACL resource is a namespaced one. All Namespaced scope resources in KubernetesClient must implement io.fabric8.kubernetes.api.model.Namespaced interface:
#Group("custom.example.com")
#Version("v1")
#Kind("UserACL")
public static final class UserACL extends CustomResource<UserACLSpec, UserACLStatus> implements Namespaced { }
(Optional) I'm not sure whether you're using JUnit4 or JUnit5, I also had to update org.junit.Test to org.junit.jupiter.api.Test and also add #EnableRuleMigrationSupport annotation in order to run this test on my JUnit5 project:
#EnableRuleMigrationSupport
public class TestKafkaHelperUtilFourth {
After making these changes, test seemed to run okay for me:
$ mvn -Dtest=io.fabric8.demo.kubernetes.mockserver.TestKafkaHelperUtilFourth test
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running io.fabric8.demo.kubernetes.mockserver.TestKafkaHelperUtilFourth
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
जुल॰ 08, 2022 10:29:31 अपराह्न okhttp3.mockwebserver.MockWebServer$2 execute
INFO: MockWebServer[49697] starting to accept connections
जुल॰ 08, 2022 10:29:31 अपराह्न okhttp3.mockwebserver.MockWebServer$3 processOneRequest
INFO: MockWebServer[49697] received request: GET /apis/custom.example.com/v1/namespaces/default/useracls?watch=true HTTP/1.1 and responded: HTTP/1.1 101 Switching Protocols
जुल॰ 08, 2022 10:29:31 अपराह्न okhttp3.mockwebserver.MockWebServer$2 acceptConnections
INFO: MockWebServer[49697] done accepting connections: Socket closed
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.779 s - in io.fabric8.demo.kubernetes.mockserver.TestKafkaHelperUtilFourth
I had used S4SDK VDM on my Integration Testing to test my ODATA services. There were some issues during the implementation & Alexander bestowed me to get it working. (VDM for Integration Tests)
When I had executed the JUnit in eclipse it works well. However when the JUnit runs during the Maven Build/ in the pipeline, it fails with the below error
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] BusinessServiceIT.createBusinessService:132->createLandscapeObject:214 » ErpOData
[INFO]
[ERROR] Tests run: 21, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:34 min
[INFO] Finished at: 2019-06-13T16:00:26+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project x-srv-landscapeManagement-integration-tests: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\xxxxx\git\x-service-landscapeManagement\srv\integration-tests\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :x-srv-landscapeManagement-integration-tests
public static void beforeClass() {
mockUtil.mockDefaults();
mockUtil.mockAuditLog();
lsoCreateHelper.withCustomHttpHeader("Authorization", jwToken).onRequestAndImplicitRequests();
connectionHelper.withCustomHttpHeader("Authorization", jwToken).onRequestAndImplicitRequests();
}```
``` #Before
public void beforeEach() throws URISyntaxException, IOException, ODataException {
mockUtil.mockDestination("localhorst", new URI("http://localhost:" + randomServerPort));
erpConfCtx = new ErpConfigContext("localhorst");
final String publicKey = FileUtils.readFile("publicKey.txt");
final Map<String, String> verificationkey = ImmutableMap.of("verificationkey", publicKey);
final JsonObject xsuaaServiceCredentials = new Gson().toJsonTree(verificationkey).getAsJsonObject();
when(((ScpCfCloudPlatform) CloudPlatformAccessor.getCloudPlatform())
.getXsuaaServiceCredentials(org.mockito.ArgumentMatchers.any(DecodedJWT.class)))
.thenReturn(xsuaaServiceCredentials);
}```
private UUID createLandscapeObject(String lsoType, String name, String customerNumber, String source,
String usecase, String tenantId, String tenantType) throws ODataException {
Properties properties = new Properties();
List<Properties> propertySet = new ArrayList<>();
if (usecase != null) {
properties.setName("useCase");
properties.setValue(usecase);
properties.setSource(source);
propertySet.add(properties);
}
if (tenantId != null) {
propertySet = new ArrayList<>();
properties.setName("TenantId");
properties.setValue(tenantId);
properties.setSource(source);
propertySet.add(properties);
}
if (tenantType != null) {
propertySet = new ArrayList<>();
properties.setName("TenantType");
properties.setValue(tenantType);
properties.setSource(source);
propertySet.add(properties);
}
LandscapeObjects landscapeObjects = new LandscapeObjects(null, null, null, null, null, name, "benufromit_test",
lsoType, customerNumber, source, null, null, propertySet);
LOG.info("benu-business1");
final LandscapeObjectsCreateFluentHelper lsoCreateHelper = lmsService.createLandscapeObjects(landscapeObjects)
.withCustomHttpHeader("Authorization", jwToken).onRequestAndImplicitRequests();
landscapeObjects = lsoCreateHelper.execute(erpConfCtx);
return landscapeObjects.getId();
}```
[ERROR] Errors:
[ERROR] BusinessServiceIT.createBusinessService:132->createLandscapeObject:214 » ErpOData
target\surefire-reports
-------------------------------------------------------------------------------
Test set: com.sap.crun.landscape.BusinessServiceIT
-------------------------------------------------------------------------------
Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 66.107 s <<< FAILURE! - in com.sap.crun.landscape.BusinessServiceIT
createBusinessService(com.sap.crun.landscape.BusinessServiceIT) Time elapsed: 2.463 s <<< ERROR!
com.sap.cloud.sdk.s4hana.datamodel.odata.helper.ODataVdmErrorResultHandler$ErpODataException:
The endpoint responded with HTTP error code 500.
. .
Full error message:
<?xml version='1.0' encoding='UTF-8'?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code/><message xml:lang="en">Service not available: LandscapeService.</message></error>
at com.sap.crun.landscape.BusinessServiceIT.createLandscapeObject(BusinessServiceIT.java:214)
at com.sap.crun.landscape.BusinessServiceIT.createBusinessService(BusinessServiceIT.java:132)```
**TestApplication**
package com.sap.crun.landscape;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan;
#SpringBootApplication
#ComponentScan(basePackages = {"com.sap.cloud.servicesdk.spring", "com.sap.crun.landscape"})
#ServletComponentScan( "com.sap.cloud.sdk" )
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
}
I am trying to execute a pipeline using Apache Beam but I get an error when trying to put some output tags:
import com.google.cloud.Tuple;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.io.gcp.pubsub.PubsubIO;
import org.apache.beam.sdk.io.gcp.pubsub.PubsubMessage;
import org.apache.beam.sdk.options.PipelineOptionsFactory;
import org.apache.beam.sdk.transforms.DoFn;
import org.apache.beam.sdk.transforms.ParDo;
import org.apache.beam.sdk.transforms.windowing.FixedWindows;
import org.apache.beam.sdk.transforms.windowing.Window;
import org.apache.beam.sdk.values.TupleTag;
import org.apache.beam.sdk.values.TupleTagList;
import org.joda.time.Duration;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.stream.Collectors;
/**
* The Transformer.
*/
class Transformer {
final static TupleTag<Map<String, String>> successfulTransformation = new TupleTag<>();
final static TupleTag<Tuple<String, String>> failedTransformation = new TupleTag<>();
/**
* The entry point of the application.
*
* #param args the input arguments
*/
public static void main(String... args) {
TransformerOptions options = PipelineOptionsFactory.fromArgs(args)
.withValidation()
.as(TransformerOptions.class);
Pipeline p = Pipeline.create(options);
p.apply("Input", PubsubIO
.readMessagesWithAttributes()
.withIdAttribute("id")
.fromTopic(options.getTopicName()))
.apply(Window.<PubsubMessage>into(FixedWindows
.of(Duration.standardSeconds(60))))
.apply("Transform",
ParDo.of(new JsonTransformer())
.withOutputTags(successfulTransformation,
TupleTagList.of(failedTransformation)));
p.run().waitUntilFinish();
}
/**
* Deserialize the input and convert it to a key-value pairs map.
*/
static class JsonTransformer extends DoFn<PubsubMessage, Map<String, String>> {
/**
* Process each element.
*
* #param c the processing context
*/
#ProcessElement
public void processElement(ProcessContext c) {
String messagePayload = new String(c.element().getPayload());
try {
Type type = new TypeToken<Map<String, String>>() {
}.getType();
Gson gson = new Gson();
Map<String, String> map = gson.fromJson(messagePayload, type);
c.output(map);
} catch (Exception e) {
LOG.error("Failed to process input {} -- adding to dead letter file", c.element(), e);
String attributes = c.element()
.getAttributeMap()
.entrySet().stream().map((entry) ->
String.format("%s -> %s\n", entry.getKey(), entry.getValue()))
.collect(Collectors.joining());
c.output(failedTransformation, Tuple.of(attributes, messagePayload));
}
}
}
}
The error shown is:
Exception in thread "main" java.lang.IllegalStateException: Unable to
return a default Coder for Transform.out1 [PCollection]. Correct one
of the following root causes: No Coder has been manually specified;
you may do so using .setCoder(). Inferring a Coder from the
CoderRegistry failed: Unable to provide a Coder for V. Building a
Coder using a registered CoderProvider failed. See suppressed
exceptions for detailed failures. Using the default output Coder from
the producing PTransform failed: Unable to provide a Coder for V.
Building a Coder using a registered CoderProvider failed.
I tried different ways to fix the issue but I think I just do not understand what is the problem. I know that these lines cause the error to happen:
.withOutputTags(successfulTransformation,TupleTagList.of(failedTransformation))
but I do not get which part of it, what part needs a specific Coder and what is "V" in the error (from "Unable to provide a Coder for V").
Why is the error happening? I also tried to look at Apache Beam's docs but they do not seems to explain such a usage nor I understand much from the section discussing about coders.
Thanks
First, I would suggest the following -- change:
final static TupleTag<Map<String, String>> successfulTransformation =
new TupleTag<>();
final static TupleTag<Tuple<String, String>> failedTransformation =
new TupleTag<>();
into this:
final static TupleTag<Map<String, String>> successfulTransformation =
new TupleTag<Map<String, String>>() {};
final static TupleTag<Tuple<String, String>> failedTransformation =
new TupleTag<Tuple<String, String>>() {};
That should help the coder inference determine the type of the side output. Also, have you properly registered a CoderProvider for Tuple?
Thanks to #Ben Chambers' answer, Kotlin is:
val successTag = object : TupleTag<MyObj>() {}
val deadLetterTag = object : TupleTag<String>() {}
I am trying to write an OSGI class which should populate the configuration dialog in Felix console, my Service implementation as shown below. but when i try to run mvn clean install -PautoInstallPackage am getting the below error. any help is appreciated.
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.2:compile
(default-compile) on project osgiexample.core: Compilation failure
[ERROR]
/E://osgiexample/core/src/main/java/osgiexample/core/serviceimpl/TestServiceImpl.java:[40,10]
cannot find symbol
[ERROR] symbol: class Activate
[ERROR] location:
class osgiexample.core.serviceimpl.TestServiceImpl
#Component(immediate=true, label="TEST Service", description="Hello There - This is a Service component", metatype=true)
#Service(value=TestService.class)
public class TestServiceImpl implements TestService {
#Property(value="http://testservice/myservice?wsdl")
static final String SERVICE_ENDPOINT_URL = "service.endpoint.url";
private String serviceEndpointUrl;
#Override
public String getData() {
// TODO Auto-generated method stub
return null;
}
#Activate
public void activate(final Map<String, Object> props) {
System.out.println("Calling Activate Method");
this.serviceEndpointUrl = (String)props.get(SERVICE_ENDPOINT_URL);
System.out.println("ServiceEndpointUrl:" + this.serviceEndpointUrl);
}
}
Add below Activate annotation import statement should resolve your issue
import org.apache.felix.scr.annotations.Activate;
I have simple presenter. Announce the call to the class of singleton
private RandomString randomString = RandomString.getInstance();
When assembling maven I have error
[INFO] [ERROR] Error injecting by.gwttest.client.client.application.packet.PacketPagePresenter$MyProxy: Unable to create or inherit binding: No #Inject or default constructor found for by.gwttest.client.client.application.packet.PacketPagePresenter$MyProxy
[INFO] Path to required node:
[INFO]
[INFO] by.gwttest.client.client.application.packet.PacketPagePresenter$MyProxy [com.gwtplatform.mvp.client.gin.AbstractPresenterModule.bindPresenter(AbstractPresenterModule.java:121)]
[INFO]
[INFO] [ERROR] Error injecting by.gwttest.client.client.application.packet.PacketPageView$Binder: Unable to create or inherit binding: No #Inject or default constructor found for by.gwttest.client.client.application.packet.PacketPageView$Binder
[INFO] Path to required node:
[INFO]
[INFO] by.gwttest.client.client.application.packet.PacketPageView [com.gwtplatform.mvp.client.gin.AbstractPresenterModule.bindPresenter(AbstractPresenterModule.java:120)]
[INFO] -> by.gwttest.client.client.application.packet.PacketPageView$Binder [#Inject constructor of by.gwttest.client.client.application.packet.PacketPageView]
[INFO]
[INFO] [ERROR] Errors in 'gen/com/gwtplatform/mvp/client/DesktopGinjectorProvider.java'
[INFO] [ERROR] Line 8: Failed to resolve 'com.gwtplatform.mvp.client.DesktopGinjector' via deferred binding
RandomString
...
private RandomString() {
}
private static class RandomStringHolder {
private final static RandomString instance = new RandomString();
}
public static RandomString getInstance() {
return RandomStringHolder.instance;
}
...
With what it can be connected? Without declaring RandomString project going
Your error is unrelated to the RandomString. The error says that you are missing a #Inject annotated constructor.
Make sure that your PacketPageView and PacketPagePresenter have an empty constructor that is annotated with #Inject.
#Inject
public PacketPagePresenter() {
}
Error was in this code
private String convertMStoTime(long millis) {
//return null;
return String.format(
"%02d:%02d:%02d",
TimeUnit.MILLISECONDS.toHours(millis),
TimeUnit.MILLISECONDS.toMinutes(millis)
- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
.toHours(millis)),
TimeUnit.MILLISECONDS.toSeconds(millis)
- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
.toMinutes(millis)));
}
TimeUnit dont'realese in GWT