STS warnings on #Value tag - spring-tool-suite

Sts shows the following warning on all my instances of #Value. Is there something incorrect, or can/should the warning be supressed?
Unsatisfied 'required' dependency of type [class java.lang.String]. Expected at least 1 matching bean

This sounds like a bug in the validation that you should file at: https://issuetracker.springsource.com/browse/STS. A sample project that reproduces the problem would be great.
In addition to that you can disable the validation in the preferences. I think it is the "Autowire" validation.

Related

Drools HelloWorld sample application gives error

When I first set up the sample hello world application I get errors in the rules/sample.drl files
The error is as follows:
Rule Compilation error Only a type can be imported. com.sample.DroolsTest.Message resolves to a package
Only a type can be imported. org.drools.core.spi.KnowledgeHelper resolves to a package
KnowledgeHelper cannot be resolved to a type
com.sample.DroolsTest.Message cannot be resolved to a type
org.kie.api.runtime.rule.FactHandle cannot be resolved to a type
org.kie.api.runtime.rule.FactHandle cannot be resolved to a type
java.lang.Exception cannot be resolved to a type
org.kie.api.runtime.rule.RuleContext cannot be resolved to a type
Message.GOODBYE cannot be resolved to a type
org.drools.core.util.bitmask.AllSetBitMask cannot be resolved to a type
com.sample.DroolsTest.Message cannot be resolved to a type
Also I fixed the error when I write dialect "mvel"
but for some reason I am not okay with this quick fix.
Am I missing some plugin or dependencies?
I am a newbie to drools rule engine and I followed all steps correctly.
Yes the most possible explanation is that you have missed some depedencies.
You need to include drools-core for example:
Only a type can be imported. org.drools.core.spi.KnowledgeHelper resolves to a package
suggests that Rules does not have access to KnowledgeHelper and tries to import it as a package.
Same thing happens with:
org.kie.api.runtime.rule.RuleContext
and kie-api depedency.
If you use Eclipse or some other IDE and started a new drools project then maybe drools library is not in build path.

Intellij 15.0.5 issue with SBT and Scala project

I am trying to set up IntelliJ for my Scala development after hearing how much better it is compared to alternatives. But I can't seem to run anything. The problems I'm facing are as follows:
As soon as the project is created, the console shows SBT failures
My build.sbt file shows red wiggles (compile time errors)
The confusing part is that opening the "SBT Console" view from within the IDE works fine.
The error trace is something along the lines of:
[info] Loading project definition from D:\workspaces\intellij\scala\untitled\project
java.io.IOException: The filename, directory name or volume label syntax is incorrect
[error] (*:update) java.io.IOException: The filename, directory name or volume label syntax is incorrect
Would anyone please know what can cause this? I have tried deleting the project and creating a new one but the problem still persists.
UPDATE
Just had a look at .sbt\boot\update.log and something seems fishy. Is it just me or the sbt.ivy.home is completely borked?
impossible to define new type: class not found: org.apache.ivy.osgi.obr.OBRResolver in [] nor Ivy classloader
impossible to define glob matcher: org.apache.ivy.plugins.matcher.GlobPatternMatcher was not found.
setting 'jline.esc.timeout' to '0'
setting 'sbt.ivy.home' to 'D:\software\installed\sbt\.ivy2 -Divy.home=D:\software\installed\sbt\.ivy2'
setting 'java.runtime.name' to 'Java(TM) SE Runtime Environment'
I have finally managed to hunt down the root cause. The errors were due to rogue environment variables set in my profile related to SBT (specifically SBT_OPTS). Once I deleted all of them and started with a clean slate, things started working on expected.

STS reports error in bean config for java.sql.Date property

I have a bean class with a property setter like this:
public void setDueDate(java.sql.Date dueDate)
I also have an instance of this bean configured in XML like this:
<property name="dueDate">
<bean class="java.sql.Date"/>
</property>
STS marks that config with an error:
No constructor with 0 arguments defined in class 'java.sql.Date'
Well, that's true, java.sql.Date has no no-arg constructor. But this app works fine so obviously Spring is smart enough to create a Date instance without a constructor. Question is, why is the STS editor/builder complaining, and is it possible to convince it that this is not an error or warning?
At this time, I can only see 3 situations where the code "would work", in the order of their likeliness to happen:
the parent bean where the property is injected is defined with scope="prototype" or lazy-init="true" and is not accessed at all
the runtime classpath contains an implementation of java.sql.Dateshadowing the original
that particular context xml is not used in the application
Otherwise, Spring should issue a nice:
Could not instantiate bean class [java.sql.Date]: No default constructor found; nested exception is java.lang.NoSuchMethodException: java.sql.Date.<init>()
In case the code works, but STS reports an wrong error, please file a bug against STS at https://issuetracker.springsource.com/browse/STS (as mentioned above).
In the meantime you can workaround this issue by disabling the validation via the Spring preferences for the project. Just go to preferences of the project -> Spring, then the "Project Validators" tab, and deactivate the validation that is responsible for the wrong error report.

Scala error: class file is broken, bad constant pool index

I'm trying to call the Selenium Java libraries from Scala. I'm using Scala IDE (Eclipse), and Scala 2.10.2. What is causing this compiler error?
error while loading Function, class file '/Dev/selenium-2.35.0/libs/guava-
14.0.jar(com/google/common/base/Function.class)' is broken
(class java.lang.RuntimeException/bad constant pool index: 0 at pos: 479)
Sometimes I fix broken class file errors by including more jars -- jars that javac would not need to see, but apparently scalac does. But is this case I don't know what other jars I can add.
Found the answer. It's caused by this: https://code.google.com/p/guava-libraries/issues/detail?id=1095. The error disappeared when I added the jsr305 jar.
RobN's answer is correct, but I thought I'd write a little bit longer answer with my own experiences. This is related to this question and discussions on Guava issues 776 and 1095 mentioned by RobN.
I had this same problem trying to access
com.google.common.io.BaseEncoding.base64()
Eclipse claims the base64 member does not exist and Gradle build
produces the error in the question:
[ant:scalac] error: error while loading BaseEncoding, class file
'.../guava-16.0.jar(com/google/common/io/BaseEncoding.class)' is broken
The error is caused by optional dependency on some annotations in Guava's pom.xml. As explained in this answer, Java compiler ignores
annotations for which corresponding class file is not found, but Scala compiler
requires the defitions to compile.
Explicitly adding the dependency that is optional should solve the problem.
In this particular case Guava's pom.xml has following optional dependency and adding the dependency declarations below to your project will solve the problem:
Gradle:
compile 'com.google.code.findbugs:jsr305:2.0.2'
Maven:
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.2</version>
</dependency>

How to prevent Intellij from treating Scala warning as error?

I'm trying out Intellij on a mixed Java/Scala project. Build is failing with errors like this:
Error: scala:
/home/kevin/ij/backend/srctest/com/example/package/DoStuffTest.java:35:
warning: [deprecation] OldStuffList in com.example.package has been
deprecated
I'm not able to find any setting related to treating warning as errors. I'd like these to be reported as warnings (because indeed, they are warnings), but not prevent the build from completing.
In the scala compiler settings, check that there is no -Xfatal-warnings
This option makes scalac treat warning as error.
Note that I had this problem after a colleague added this option in the build.sbt of an sbt project. Intellij then added it to its scala compiler settings.
If you hit alt-enter on the highlighted error, it should at least give you a dropdown option called "Disable inspection" which should let you turn that off for that instance or all Deprecated errors. This doesn't really solve your problem, but it might at least get you past it.