Arquillian and jboss-4.2.3.GA - jboss

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).

Related

com.day.cq.dam.commons.util,version=[1.50,2) -- Cannot be resolved

I'm trying to run AEM 6.5 however i'm running into an issue below:
com.day.cq.dam.commons.util,version=[1.50,2) -- Cannot be resolved
It can boot up Author, but there is no content and it looks like that's the only source of the error I can see.
You can add the maven dependency in your pom.xml and build and install the code in AEM and check if this issue still exists.
<dependency>
<groupId>com.day.cq.dam</groupId>
<artifactId>cq-dam-commons</artifactId>
<version>5.6.6</version>
<scope>provided</scope>
</dependency>

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>

GWT 2.8 websocket support

Does jetty server in gwt 2.8 support websocket now? As I know it did not support before. If there is a positive answer, then how to make it work? Stripping out jetty-8 and replaceing it with jetty-9 is not a good idea I think.
then how to make it work?
I want to elaborate a bit on this after the GWT 2.8.0 release. The only thing required for using javax.websocket is the knowledge of the Jetty version packaged with GWT and the following set of Maven dependencies (see also the Jetty WebSocket examples on GitHub):
<project>
<properties>
<sdm.jetty.version>9.2.14.v20151106</sdm.jetty.version>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${sdm.jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>${sdm.jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</depencies>
</project>
Make doubly sure that the scope is provided - for the former two this will mean they are not packaged into the final app - you will be requiring those only when running the SuperDev-Mode (SDM). Ifjava.websocket-apiwas on your classpath probably the annotation-based configuration will not work at all (at least in embedded Tomcat and Jetty) due to the annotations being picked up by the wrong class loader (see also related question WebSocket 404 error for more info on this topic).
GWT 2.8 has switched to Jetty 9.2, and now supports Servlets 3.1 servlets container initializers, which I think are being used to setup WebSockets.
I haven't tried it but I suppose that you can now have WebSockets in DevMode, provided you add the required dependencies to the classpath.
You can also simply use a separate server rather than the one embedded into DevMode.

ClassNotFoundException when I try to deploy to Tomcat / tc Server in Eclipse / STS

I'm new to Eclipse/STS, and I am having deploying to Tomcat / tcServer. My project builds just fine and deploys to Tomcat fine both in Netbeans and directly to Tomcat, but it will not deploy to Tomcat or tc Server in Eclipse. I get a ClassNotFoundException for org.hibernate.HibernateException, which I know is on the included in the pom.
Here's my log output if it helps.
Also in the markers view, I see the following build path problem:
Archive for required library: '~/.m2/repository/org/hibernate/hibernate-core/4.1.1.Final/hibernate-core-4.1.1.Final.pom' in project 'flamespass-web-dev' cannot be read or is not a valid ZIP file
I found a work around:
I noticed that I had hibernate-core:4.1.1.Final in my Dependency Hierarchy twice, so I tried a few things, and specifying the newest version of hibernate-core in my dependencyManagement node fixed my problem.
I am not sure why. I can only assume that the two copies of hibernate-core:4.1.1 were creating some sort of ambiguity that m2eclipse or WTP couldn't understand even though my external Maven/Tomcat could. I would really appreciate any explanation or better fixes anyone may have. Thanks.
...
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.9.Final</version>
</dependency>
</dependencies>
</dependencyManagement>

Using Drools on Jetty

I am trying to start up a webapp that uses Drools 5.2.0.M1. I get the following stacktrace on startup:
java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclipse/jdt/core/compiler/CategorizedProblem;
at org.drools.commons.jci.compilers.EclipseJavaCompiler$3.acceptResult(EclipseJavaCompiler.java:336)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335)
at org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:366)
at org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:51)
at org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:366)
at org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:55)
I have the jars in my pom:
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.2.0.M1</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>3.5.1</version>
</dependency>
Why Can't it find CompilationResult.getProblems()?
JDT isn't backwards compatible.
Check the drools-compiler pom (of exactly the version you're using) on which version of ecj it depends and use that version. Or don't declare ecj at all, it's a transitive dependency for drools-compiler anyway.
PS: upgrade to drools 5.2.0.CR1 (or final once it's out)
I had a similar problem. I was having a web-app using Jetty 6. Jetty 6 which apparently bringing in a non-compatible version of JDT. After switching to Jetty 7 the problem was solved.