Glassfish 3.1b41 - JDO83008: CMP Compilation failed: class file not found - java

we have an "old" JavaEE Application, which we want to port from the old Sun Application Server 9.1 to the current Glassfish 3.1. We updated the deployment descriptor xml files (renamed them, updated DocType, validated against DTD, nothing else). But when we try to the deploy into the GF3.1 we get this error:
JDO83008: CMP Compilation failed:
C:\workspace\glassfish31eclipsedefaultdomain\generated\ejb\archivetool-app-1.9.5\archivetool-ejb-1.9.5_jar\de\ems\archivetool\ejb\metadata\cd\eb\CdBean_821611534_ConcreteImpl.java:10:
cannot access de.ems.archivetool.ejb.framework.AbstractCMPBean
class file for de.ems.archivetool.ejb.framework.AbstractCMPBean not found
C:\workspace\glassfish31eclipsedefaultdomain\generated\ejb\archivetool-app-1.9.5\archivetool-ejb-1.9.5_jar\de\ems\archivetool\ejb\productdata\product\eb\ProductionLibraryBean40992531_ConcreteImpl.java:416:
cannot find symbol
symbol : class EBSBusinessException
location: package de.ems.archivetool.ejb.framework
WARNUNG: JDO83004: CMP Compilation failed. See log for details.
SCHWERWIEGEND: Exception while invoking class org.glassfish.ejb.startup.EjbDeployer prepare method
SCHWERWIEGEND: Exception while invoking class org.glassfish.javaee.full.deployment.EarDeployer prepare method
SCHWERWIEGEND: Exception while preparing the app
SCHWERWIEGEND: JDO83004: CMP Compilation failed. See log for details.
org.glassfish.deployment.common.DeploymentException: JDO83004: CMP Compilation failed. See log for details.
But we can still deploy in the old SUN App Server.
The application consists of 4 modules and a build module. Generally, the .ear file, consisting of the two EJB modules, one WAR module and one JAR module, is build with Maven without problems (UnitTest succeed etc).
(pom.xml and the resulting application.xml)
So, everything builds fine, but when we try to deploy the application to GF3.1 we get the "class file not found" error. The classes which are not found are within the JAR module and contain base classes for the EJB modules.
Does anyone has a starting point?
Regards,
Andreas

Ok, after hours of googeling, I finally found the exact answer to this problem here.
The important part is:
The Java EE 6 specification imposes strict rules about which JAR files
are visible from an enterprise archive (EAR) file. Refer to section
EE.8.3.3; specifically, application client modules should not have
access to any EJB JAR file unless the application client JAR file's
manifest Class-Path refers to the EJB JAR file(s) explicitly.
This is a change from GlassFish Server v2, in which application
clients automatically had access to all EJB JAR files in the EAR file
and all JAR files at the top level of the EAR file. To comply with the
stricter specification language, GlassFish Server 3.0.1 cannot
automatically provide application clients with access to these JAR
files.
What you have to do is, let maven put the jar (and other dependencies) into a library folder in the ear container. You do this by adding this to your ear pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
//here starts the important part
<defaultLibBundleDir>lib</defaultLibBundleDir>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
//end of important part
<modules>
<jarModule>
<groupId>gID</groupId>
<artifactId>aID</artifactId>
</jarModule>
//etc some more ebjs, war, ...
</modules>
This will put the jar module into a folder lib, and all depending ejbs will get the Class-Path entry in their MANIFEST.MF.
Hope that helps some of you with the same problem.

Related

Not able to run a Vaadin application on remote server

I am building a Vaadin application with Java. Here is the folder structure.
- com
-- my
--- WebTool
---- ToolUI.java
---- View_1.java
---- View_2.java
The entry point to the application is ToolUI.java and has the method init() that takes VaadinRequest as a parameter. It is this file where I add the views Views_1 and View_2 as views of the application and add navigations among them. Everything runs great when I run the application via the Eclipse IDE.
Now I have a requirement that I have to deploy this application on a remote server. So I created a war of the project and deployed on the server by the name
MyWebTool.war.
Now when I try running the war with the command
java -jar MyWebTool.war
it gives me the error: Can't execute war no main manifest attribute, in MyWebTool.war
I am not sure what to add the main class as since the init method gets invoked and sets the app running. So I put a blank main function inside the MyWebToolUI.java and added this dependency in the pom.xml file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.my.WebTool.ToolUI</mainClass>
</manifest>
</archive>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- Exclude an unnecessary file generated by the GWT compiler. -->
<packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
</configuration>
</plugin>
But now when trying to run the application it says Could not find or load main class com.my.WebTool.ToolUI
Can please somebody shed light on this? I don't know if I am missing something simple here but at this point, I am stuck. Thanks a lot.
For running war packaged applications, you will need a servlet container.
The servlet container provides all the basic infrastructure needed to run java based web applications.
One of the most common ways to do this, is to deploy the war file to a tomcat installation.

eclipse: external CDI in EJB module: NoClassDefFoundError

My current project consisting of a war and ejb module, is using a jar (incorperated via maven). This jar contains a CDI component which, when I inject this in the war module it works as expected, but when I inject this in my ejb module I get a NoClassDefFoundError during startup from my WAS 8.5 in eclipse (full profile).
When I start the server first, add the inject later and republish it seems to work. Also when I use Liberty profile it works. Also on Z/os and IPAS it works as expected.
I think it might has something todo with classloading, but have no idea how to solve this properly.
Using Eclipse Neon, WAS 8.5.5.11 full profile , jee6
Project is using java 8 while the component is using java 6
This is the first part of the stacktrace:
[13-9-17 14:54:26:589 CEST] 0000003e InjectionProc W CWNEN0047W: Resource annotations on the fields of the BestelFacade class will be ignored. The annotations could not be obtained because of the exc
eption : Logger
at java.lang.Class.getDeclaredFieldsImpl(Native Method)
Thanks
I found a way to get the job done, but I'm not sure if this is a proper solution or just a workaround while masking the real problem.
When I take a look at the ear module assembly I see in the source column c:/ws/.../jar and in the deploy path lib/jar
when I change the source into /..ear/target/../jar it works
Try setting the <bundleDir>/</bundleDir>
This will place the external jar/ejb not in lib, but in the root.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
...........
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<jarModule>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<bundleDir>/</bundleDir>
</jarModule>
</modules>
</configuration>
</plugin>

How to use httpcomponents in wildfly 10 with EAR project?

I can't get org.apache.httpcomponents to work in Wildfly 10. I didn't try 9. The error I get is, basically.
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest from [Module "deployment.opca-ear.ear.opca-ejb.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 185 more
I looked at Wildfly 8.1 ClassNotFound org.apache.http.conn.ClientConnectionManager, but jboss-deployment-structure.xml described there is not working here.
I tried various combinations of things in the POM file, but I'm not getting anywhere with that.
The class fails when being constructed, so the import statements are causing problems.
I haven't been able to get access to the module or get the needed jar files to be deployed into the ear lib directory.
EDIT: I'm using JBoss Developer Studio. I seem to be making some progress in that if I copy my opca-ear.ear file to the deployment directory manually then the httpclient and httpcore jars get deployed, but they don't if I deploy from jbstudio, so I guess it's an issue with jboss-modules.jar deployments. Not being able to debug/deploy from jbstudio is going to be a pain. Httpclient and httpcore are in my opca-ear.ear file in the lib directory, as well as the ejb/target/opca-ear/lib directory.
If I could get something like jboss-deployment-structure.xml or perhaps an entry in the a manifest file working so that wildfly provides the client access to the org.apache.httpcomponents resources then I wouldn't have to worry about jboss-modules.jar.
SOLUTION: As noted in the accepted answer, jboss-deployment-structure.xml only works on "full" deployments, so I used a manifest.mf entry
Dependencies: org.apache.httpcomponents
and updated the maven-ejb-plugin to use it:
<artifactId>maven-ejb-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<!-- Tell Maven we are using EJB 3.1 -->
<ejbVersion>3.1</ejbVersion>
<archive>
<manifestFile>${basedir}/src/main/resources/META-INF/manifest.mf</manifestFile>
</archive>
</configuration>
It all depends on which code needs it. The jboss-deployment-structure.xml you are mentionning isn't going to work if you don't declare your 'full' application.
Maybe you should just add a Manifest with the entry Dependencies: org.apache.httpcomponents in the jar/war that needs it.
Tkae a look at https://docs.jboss.org/author/display/WFLY10/Class+Loading+in+WildFly

RAD WebSphere NoClassDefFoundError

My projects look like this
EAR_proj
lib/
3rd party jars
EJB_proj
Web_proj (a web service with WSDL)
Common_proj1
Common_proj2
EAR_proj has Deployment Assembly contains all other projects
All projects have "EAR library" in their classpath for the 3rd party libraries.
The Web_proj has Deployment Assembly contains Common_proj1 and Common_proj2 (in its MANIFEST.MF)
However when I deploy the Web_project to the server (within RAD), I kept getting NoClassDefFoundError for 1 class that resides within Common_proj1.
Looking at WebSphere ffdc error file, it says
FFDC Exception:java.io.FileNotFoundException SourceId:com.ibm.ws.websvcs.utils.Axis2Utils.getApplicationClassPath ProbeId:874
java.io.FileNotFoundException: Common_proj1\bin (Access is denied.)
The other ffdc file indicate Common_proj1/bin is on the classpath of some ClassLoader...I'm not sure why it doesn't just treat Common_proj1 as a jar file. Is it because this happen within the IDE?
The server Classloader policy is set to "Single" and "Classes loaded with parent class loader first" policy
Turn out this is a RAD problem after upgrading to a newer JDK.
http://www-01.ibm.com/support/docview.wss?uid=swg21667356
Adding the attribute wsldLocation in the web service implementation class solves the problem.

How to dynamically load Java classes at Runtime in OSGI framework?

We are performing a POC in our project, where in we send SOAP based request and correspondingly get a SOAP response from a web service. We aim to leverage webservices template (client side API) provided by spring framework in our application. As per our architecture, we create an OSGI compliant bundle (for our code that uses webservices template API to interact with the web service) which is then deployed into the Apache Felix container. We have also installed all the dependent OSGI compliant bundles in the Felix container so that all the dependencies are resolved.
As per the webservices template, the default Web Service Message sender is HttpUrlConnectionMessageSender which is dynamically loaded at run time by the class loader. As per my understanding, we are getting the below exception because the Felix container is not able to load the class from the dependent OSGI bundle (web services bundle contains the HttpUrlConnectionMessageSender).Please refer to the exception logs below.
* org.springframework.beans.factory.BeanInitializationException: Could not find default strategy class for interface [org.springframework.ws.transport.WebServiceMessageSender]; nested exception is java.lang.ClassNotFoundException:org.springframework.ws.transport.http.HttpUrlConnectionMessageSender at org.springframework.ws.support.DefaultStrategiesHelper.getDefaultStrategies(DefaultStrategiesHelper.java:126)
at org.springframework.ws.support.DefaultStrategiesHelper.getDefaultStrategies(DefaultStrategiesHelper.java:90)
at org.springframework.ws.client.core.WebServiceTemplate.initMessageSenders(WebServiceTemplate.java:320)
at org.springframework.ws.client.core.WebServiceTemplate.initDefaultStrategies(WebServiceTemplate.java:306)
at org.springframework.ws.client.core.WebServiceTemplate.<init>(WebServiceTemplate.java:143)
at test.soapservice.service.SOAPServiceImpl.<init>(SOAPServiceImpl.java:40)
at test.soapservice.service.SOAPServiceActivator.start(SOAPServiceActivator.java:17)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:641)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at org.apache.felix.gogo.command.Basic.start(Basic.java:729)
Caused by: java.lang.ClassNotFoundException: org.springframework.ws.transport.http.HttpUrlConnectionMessageSender
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:164)
at org.springframework.ws.support.DefaultStrategiesHelper.getDefaultStrategies(DefaultStrategiesHelper.java:114)
As per my understanding,Felix container is unable to dynamically load the class using ClassUtils.forName() which exists in another bundle. I see this as a collaboration issue where the current bundle has a different class loader as opposed to class loader of dependent bundle.
Did someone from this community have encountered the same exception? If yes, then what were steps taken by you to resolve the run time class dependency? Please share your thoughts/pointers to resolve the above issue.A quick response would be highly appreciated and may help us to make our POC successful.
Thanks in advance,
Mridul Chopra
Classloading in the form of Class.forName() is not a problem in any OSGi container. You problem here is that the MANIFEST.MF file does not contain the right import declarations. One bundle should export the org.springframework.ws.transport package, while your bundle should import the same package.
If you are using Maven to build your bundle, you can use the Felix Bundle Plugin to generate the right manifest information.
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Private-Package>my.private.package.*</Private-Package>
</instructions>
</configuration>
</plugin>
</plugins>
This should inspect your code and add imports for anything that is not inside your "private" package scope. One other thing you should do to make this work is to set the packaging type to bundle.
<packaging>bundle</packaging>
But, the examples above is when you are using Maven as a build tool. If you are using Gradle, you can use the Gradle OSGi plugin to build manifest. Or, if using Ant you can use SpringSource Bundlor project (btw, which also has a Maven plugin).

Categories

Resources