How to use LDAP in Lift Framework - scala

Does anyone have a good example showing how to incorporate LDAP to a Lift Scala Project? I have problems adding the dependency in my pom.xml file
<dependency>
<groupId>net.liftweb</groupId>
<artifactId>lift-ldap</artifactId>
<version>2.0</version>
</dependency>
In the project tag throws me an error saying it couldnt find the version in [1.4.5-rc1,1.4.5] to match range [1.4,1.4.3) javax.mail:mail:jar:null
Any ideas?? Thank u

Related

Service Component missing in AEM

I am trying to create a project in Eclipse using the AEM Developer Tools plugin. The project is published in AEM server and can be seen in: Websites and CRXDE Lite.
The project was created using Maven Archetype-10 in Eclipse and the default project has two pages in English and French. When I open the page in the Site URL, I get the end page, where the message from the HelloWorldModel class should be displayed, along with the other text. But I don't get the message from the respective class. Instead, I am getting the following error message:
org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.sightly.SightlyException: Cannot find a a file corresponding to class com.pen.mypen.core.models.HelloWorldModel in the repository.
It looks like the Java files in the CORE project are not published or are not visible to the web page. But the 3 packages: Core, Apps, and Content are all published and synchronized in Eclipse. Is there any way to check if the Java package is deployed to AEM server? Please guide me to what I am missing here. Please find the error stack trace below:
Caused by: org.apache.sling.scripting.sightly.SightlyException: Cannot find a a file corresponding to class com.pen.mypen.core.models.HelloWorldModel in the repository.
at org.apache.sling.scripting.sightly.impl.compiler.SightlyJavaCompilerService.compileRepositoryJavaClass(SightlyJavaCompilerService.java:212)
at org.apache.sling.scripting.sightly.impl.compiler.SightlyJavaCompilerService.getInstance(SightlyJavaCompilerService.java:113)
at org.apache.sling.scripting.sightly.impl.engine.extension.use.JavaUseProvider.provide(JavaUseProvider.java:127)
at org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.call(UseRuntimeExtension.java:84)
at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderContextImpl.call(RenderContextImpl.java:66)
at org.apache.sling.scripting.sightly.apps.pen.components.content.helloworld.SightlyJava_helloworld.render(SightlyJava_helloworld.java:53)
at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderUnit.render(RenderUnit.java:54)
at org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.evaluateScript(SightlyScriptEngine.java:92)
at org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.eval(SightlyScriptEngine.java:78)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388)
UPDATE
AEM - 6.2
Eclipse - Luna
Java - 1.8
You can check the following things:
http://SERVER:PORT/system/console/bundles shows all the java bundles that are installed on your AEM machine. Check if your bundle is listed there. If not then it could not be installed => check the error log
If your bundle is listed there, check if it is status is active, if not there might be missing dependencies or stuff like that. => click the bundle name to see more details what went wron, also check the error log.
If the status is active, click on the bundle and see if the package that contains your java class is listed in the Exported Packages section.
If the package is listed, you might need to check the error log (again).
UPDATE (because of AEM 6.2):
The problem with your project is, that with AEM versions prior to 6.2, there was a dependency to javax.inject version 0 whereas now they need version 1 and that's not reflected in the pom.xml.
Just add this to your pom.xml of the core project - that's the only change you'll have to do:
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
and everything will work. Sorry for the confusion...
In case you are using SlingModels the javax.inject is exposed by the org.apache.sling.models.api
Can you check your pom for the SlingModel dependencies
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.api</artifactId>
<version>VERSION_NUMBER</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.impl</artifactId>
<version>VERSION_NUMBER</version>
<scope>provided</scope>
</dependency>
Check the VERSION_NUMBER you are using and then in /system/console/bundles verify that the same version bundle is present and Active.
With AEM 6.x the Sling Model bundles are available by default. The 6.0 will have a lower version 1.0.x. Fixing the version either by updating the pom or installing the SlingModel bundles with version VERSION_NUMBER fix your issue.
Update for 6.2
For 6.2 with models with version 1.2.2 use following in dependencies -
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.api</artifactId>
<version>1.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.impl</artifactId>
<version>1.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
geronimo-atinject_1.0_spec is the one that is exposing javax.inject in sling models 1.2.2
Sharing my solution which will be helpful.
Tested on AEM 6.2 working perfect.
In core pom.xml file add Import-Package tag with "javax.inject;version=0.0.0,*" inside "org.apache.felix" plugin tag.
Following is the sample :
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<!--
<Embed-Dependency>
artifactId1,artifactId2;inline=true
</Embed-Dependency>
-->
<!-- Import any version of javax.inject, to allow running on multiple versions of AEM -->
<Import-Package>javax.inject;version=0.0.0,*</Import-Package>
<Sling-Model-Packages>
com.next.sample_test_impl.core
</Sling-Model-Packages>
</instructions>
</configuration>
</plugin>

Could not find or load main class org.scalatest.tools.Runner

Created the maven scala project.
I had correctly specified all the configuration . But still facing this error.
any help appreciated.
I solved this error.
Its coming because I had make the entry for org.scalatest plugin and there is no src/test/scala dir and no test cases.After removing org.scalatest plugin entry from pom file everything work fine.
For anyone that comes across this issue in the future, make sure you have the following dependency in your pom.xml.
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>

ClassNotFoundException despite adding to classpath and pom.xml

I'm trying to use one of the Apache Commons Math3 classes in Eclipse.
Downloaded the jar, and used these instructions for adding to the build path: ClassNotFoundException in eclipse.
In addition, since the project uses Maven, I added this to the pom.xml file:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.0</version>
</dependency>
Here is where I'm using the class:
import org.apache.commons.math3.distribution.fitting.MultivariateNormalMixtureExpectationMaximization;
...
MixtureMultivariateNormalDistribution mmnd = MultivariateNormalMixtureExpectationMaximization.estimate(data, 2);
There are no errors at compile time, but at runtime:
Error text:java.lang.ClassNotFoundException: org.apache.commons.math3.distribution.fitting.MultivariateNormalMixtureExpectationMaximization
I know there are a couple of stackoverflow answers regarding adding jar files, I've followed several of them and they don't seem to solve the issue.
Thanks in advance!

java.lang.NoClassDefFoundError: scala/reflect/ClassManifest

I am getting an error when trying to run an example on spark. Can anybody please let me know what changes do i need to do to my pom.xml to run programs with spark.
Currently Spark only works with Scala 2.9.3. It does not work with later versions of Scala. I saw the error you describe when I tried to run the SparkPi example with SCALA_HOME pointing to a 2.10.2 installation. When I pointed SCALA_HOME at a 2.9.3 installation instead, things worked for me. Details here.
You should add dependecy for scala-reflect to your maven build:
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>2.10.2</version>
</dependency>
Ran into the same issue using the Scala-Redis 2.9 client (incompatible with Scala 2.10) and including a dependency to scala-reflect does not help. Indeed, scala-reflect is packaged as its own jar but does not include the Class missing which is deprecated since Scala 2.10.0 (see this thread).
The correct answer is to point to an installation of Scala which includes this class (In my case using the Scala-Redis client, the answer of McNeill helped. I pointed to Scala 2.9.3 using SBT and everything worked as expected)
In my case, the error is raised in Kafka's api. I change the dependency from
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.9.2</artifactId>
<version>0.8.1.1</version>
</dependency>
to
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming-kafka_2.10</artifactId>
<version>1.6.1</version>
</dependency>
fixed the problem.

Arquillian and jboss-4.2.3.GA

i am workign on a jboss-4.2.3.GA project. Its a old project but we cant upgrade to new server.
I am trying to use Arquillian for JPA..
We are using folliwng entry in pom for JPA
<dependency>
<groupId>com.jboss</groupId>
<artifactId>ejb3-persistence.jar</artifactId>
<version>4.2.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>hibernate</groupId>
<artifactId>hibernate3</artifactId>
<version>3.2.4.SP1</version>
<scope>provided</scope>
</dependency>
I am trying to configure Arquillian but i am getting some issue like nosuchmethod found or some time no default container set.
Anyone help me what container i need to set and any dependency settings ?
Add the arquillian-bom to the dependencyManagement section of your pom, see the Getting Started Guide: http://arquillian.org/guides/getting_started/#add_the_arquillian_apis
That will update the version of the dependencies the jbossas adapter has on arquillian core. Without it you will be running a mix of Core 1.0.1.Final and Core X (what ever the adapter happens to be compiled against currently which may or may not be compatible with the 1.0.1.Final Core artifacts).