No EJB found with interface when built as jar - deployment

I have the following error when deploying and starting the application with Wildfly.
No EJB found with interface of type "de.dev.java.project.api.ProjectApi" for binding de.dev.java.project.restservice.ProjectRestService/projectApi.
Project module structure:
- project-api -> built as jar
- ProjectApi.java
- project-impl -> built as jar
- ProjectRestService.java
{
#EJB ProjectApi projectApi
}
- application -> built as ear, which includes modules above
I only have a problem when i build "project-impl" module as jar. When i built as war i do not have a problem. What does war include which jar does not?

You must build as a proper ejb jar, not just regular jar. It also needs to be referenced properly in the ear. Use you IDE to setup suitable maven project with the right archetype

Related

Tomcat don't load maven provided dependencies

have eclipse, tomcat, maven and project with modules
the parent is pom
module 1 is jar (it's dependency for other modules)
module 2-7 - war
in parent pom have some dependencies with scope provided
when i build WARs - get lightweight files without deps
but if i run tomcat server in eclipse with modules 2-7 - tomcat don't load maven dependencies
i don't understand,what i should wrote in parent pom for lightweight WARs and load jars in debug together
help,please
UPDATE
solve with 2 profiles and 1 parameter as scope for all deps
If you mark a dependency as provided, you say that the container (Tomcat in your case) will provide it.
Maven will not do that for you, but you need to configure it yourself in Tomcat.

In GGTS, how do I have java classes reference jars from BuildConfig.groovy

Using GGTS 3.6.0M1 with Grails 2.4, I have a java class file that needs an external jar to compile. That jar is defined in BuildConfig.groovy in the "compile" stage, but Eclipse still complains that the references class is not found (because it's not in the Java Build Path).
Since dependency management is performed by Grails, what's the best way to handle dependencies from Java classes that are within Grails projects?
EDIT: Refresh-dependencies doesn't solve the problem of my JAVA classes (under src/java) not seeing the jars in their classpath within Eclipse (showing project errors). If I compile externally - it works (grails compile).

java.lang.ClassNotFoundException for a class in external JAR

I have a maven project in Eclipse Java EE IDE for Web Developers.
When running Tomcat, I'm getting an error for a class that I can see that I have included.
My question is - do I have to add these JARs to an additional place because of Tomcat Apache?
Error:
SEVERE: Servlet /Resource threw load() exception
java.lang.ClassNotFoundException: org.odata4j.jersey.producer.resources.ODataApplication
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at com.sun.jersey.core.reflection.ReflectionHelper.classForNameWithException(ReflectionHelper.java:240)
at com.sun.jersey.core.reflection.ReflectionHelper.classForNameWithException(ReflectionHelper.java:220)
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:711)
And here is the class in my Library:
UPDATE:
My Web Deployment Assembly looks like:
The issue you are seeing is due to the fact that tomcat is looking at the wrong directory. It is currently most likely pointed at your src/main/webapp directory of your project. This does not jive with how maven works. Maven downloads the dependencies, but will only include them in the target build. You need to have the tomcat server look at target/myapp-0.0.1, or build to a war and deploy that way. The easiest solution as of now, would be for you to use the tomcat plugin. After setting it up, you can use an imbedded server, and just use the following command 'mvn tomcat:run'.
Maven Tomcat Plugin Docs
UPDATE:
I looked at the properties settings, and you should actually be able to edit the "Web Deployment Assembly" settings for your project (under project properties). Check screenshot for how I have mine setup. Notice how Maven Dependencies is mapped.
http://imgur.com/ofxryns

JAR inter-dependencies inside WAR with ant

We have to package (using ant) a war file to be deployed (on tomcat )
Inside the lib folders, there are several jar files:
3rd-party-lib-A.jar
3rd-party-lib-B.jar
3rd-party-lib-C.jar
...etc
Such that lib-A depends on lib-B ...etc
The WAR is deployed fine, but cannot be started because errors likes this happen:
INFO: ExtensionValidator[/MyWebApp][3rd-party-lib-A.jar]: Required extension "lib-B" not found
INFO: ExtensionValidator[/MyWebApp][3rd-party-lib-A.jar]: Required extension "lib-C" not found
..etc
inside the manifest file of "3rd-party-lib-A.jar" we can find:
...
lib-B-Extension-Name: lib-B
lib-B-Implementation-Version: 1.1
lib-B-Implementation-URL: http://10.10.1.148/bundle/3rd-party-lib-B.jar
log4j-Extension-Name: log4j
log4j-Implementation-Version: 1.2.9
log4j-Implementation-URL: http://jakarta.apache.org/log4j
...
My question is, how to go from here?
1) repackage each jar to have a manifest with class-path, using relative path?
2) put the jars in the tomcat lib?
3) read the manual? :)
4) use maven?
thanks

Spring 3.1 NoClassDefFoundError ListableBeanFactory

I am trying to upgrade an old project from Spring 2.5.6 to Spring 3.1.0. The project is not built with Maven so I had to add the jars manually to the build path.
The application uses Eclipse RAP as well as Spring.
I added all the Spring 3.1 jars in my build path:
lib/org.springframework.aop-3.1.0.RELEASE.jar
lib/org.springframework.asm-3.1.0.RELEASE.jar
lib/org.springframework.aspects-3.1.0.RELEASE.jar
lib/org.springframework.beans-3.1.0.RELEASE.jar
lib/org.springframework.context-3.1.0.RELEASE.jar
lib/org.springframework.context.support-3.1.0.RELEASE.jar
lib/org.springframework.core-3.1.0.RELEASE.jar
lib/org.springframework.expression-3.1.0.RELEASE.jar
lib/org.springframework.instrument-3.1.0.RELEASE.jar
lib/org.springframework.instrument.tomcat-3.1.0.RELEASE.jar
lib/org.springframework.jdbc-3.1.0.RELEASE.jar
lib/org.springframework.jms-3.1.0.RELEASE.jar
lib/org.springframework.orm-3.1.0.RELEASE.jar
lib/org.springframework.oxm-3.1.0.RELEASE.jar
lib/org.springframework.test-3.1.0.RELEASE.jar
lib/org.springframework.transaction-3.1.0.RELEASE.jar
lib/org.springframework.web-3.1.0.RELEASE.jar
lib/org.springframework.web.portlet-3.1.0.RELEASE.jar
lib/org.springframework.web.servlet-3.1.0.RELEASE.jar
lib/org.springframework.web.struts-3.1.0.RELEASE.jar
and I also listed them in the MANIFEST.MF.
The project builds fine, but at runtime when trying to login it gives me the following error:
java.lang.NoClassDefFoundError: org/springframework/beans/factory/ListableBeanFactory
I looked in the beans jar and the class is definitely there. I also searched through the project and the class is not used explicitly anywhere.
What could cause this? Thank you in advance.
This class does not exist in Spring 3.1.0. See http://www.jarfinder.com/index.php/java/info/org.springframework.beans.factory.ListableBeanFactory