I'm deploying my war file to Oracle Weblogic Application 12c.
This war file, it's running OK on apache tomcat 8.
However, when I deploy it to Weblogic, I get this error:
java.lang.NoClassDefFoundError: Could not initialize class
org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller
I use Apache POI to read the excel file.
Possibility is run time version of mentioned class differs from version at compile time. You need to check whether you have multiple versions of this class in the classpath.Could you please check for existence of multiple jars containing this class.May be one inside the lib folder of server and another inside your application under lib folder.You need this jar just inside lib folder of your application.
Related
I have a spring boot application using ms-sql database, it deploys properly in external tomcat when the server is newly started, but when I redeploy the same war file I get the following error(the war file still deploys but is not functioning properly:
Native library mssql-jdbc_auth-8.4.1.x64.dll already loaded in another classloader when I redeploy the war file in external tomcat.
So I undeploy the war file, restart the tomcat server, and redeploy it, and it's deploying properly and working (functions and CRUD).
I am using tomcat 9.0.43 and there are no other applications deployed to the server instance.
EDIT: I am running tomcat on windows and also have the .dll file in the tomcat bin folder. Also I'm using maven for dependency management.
The program uses integrated security for DB auth
Your problem comes from the double usage you want to make of your WAR file:
on one side you need the JDBC driver whenever you run the WAR file using java -jar,
on the other side you don't want JDBC drivers in the web application's classloader, whenever the WAR file is deployed in a servlet container. The servlet container should provide the drivers.
Fortunately the spring-boot-maven-plugin already provides such a feature in the repackage goal: all the dependencies marked as provided (such as the Embedded Tomcat libraries) are placed in the WEB-INF/lib-provided folder and hence are not loaded by the servlet container.
Therefore you only need to mark the JDBC driver as provided and add it to Tomcat's common loader's classpath ($CATALINA_BASE/lib).
I've added mysql connector jar file, but class not found exception still arises.
*
Your error clearly says that the MySql connector jar is not placed in the correct folder. The correct folder is WEB-INF/lib. So place your jar in this folder.
You have your eclipse project referencing the mysql library. This allows the compiler, in eclipse, to find the classes when compiling. However, you do not have the library as part of your web app when you publish it to your tomcat server. You need to remove the library from the project, and copy the jar file into your app's WEB-INF/lib directory.
java.lang.classnotfoundexception com.mysql.jdbc.MySql issued by WebAppClassLoader. This tells that you need to include MySql connector jar in your web path under WEB-INF/lib directory.
I'm trying to deploy WAR file into JBoss 7.
I placed the WAR file in the standalone/deployments folder.
while starting the server I’m getting ClassNotFoundError.
I believe Since the jars are not part of the WAR file and not placed in the WEB_INF/lib folder so I need to add them externally.
I read so many tutorials but I just can’t understand how it works.
So my question is how I simply add JAR files to the JBoss classpath.
If you want to add any jars that are not part of WebApp but are still needed to be loaded, one approach would trying to copy the jars at following location:
$JAVA_HOME/jre/lib/ext.
The JBOSS server should point to this java installation and this might resolve your issue.
This might be one way.
JBOSS 7 uses module based loading, hence most of the jars will be loaded if module is included in standalone.xml.
You will need to check in JBoss Release notes if third party modules can be loaded.
Ok I solved it by creating new module and by adding the module dependency in the MANIFEST of my jar.
I have a project which in the meantime runs locally on Tomcat but I'm planning to deploy to some server in the future.
I have a few questions:
I'm using tomcat-jdbc.jar. How should I include that jar in the project? copy it to WEB-INF/lib or add a library reference to tomcat? is the latter portable? Can I use this jar even if the server I'm deploying to is using jetty?
When I added the JRE, eclipse asked me to point it to the JRE path. The line that was added in the classpath was
classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"
How does eclipse figure out from this line where the JRE is at?
When the project is deployed to the server, how would the project hierarchy look like?
My guess is:
<project name>
----<build> (.class files)
----<WebContent>
--------<META-INF>
------------MANIFEST.MF
--------<WEB-INF>
------------<lib>
----------------external_jar.jar
------------web.xml
---------index.html
Is this correct? if so, how will the runtime know where to find the JRE? or the tomcat-jdbc.jar which is in the Tomcat installation folder?
Your application needs the following three types of "resources"
System Resources: JRE classes, some extensions/libraries provided by the server you deploy on.
Your dependencies: Any libraries you use, say common-utils, poi etc. These JAR files go in your web-inf/lib folder
Your classes. These are deployed with the WAR file at web-inf/classes
So, to answer your questions:
If you are deploying to Tomcat, the tomcat-jdbc.jar will be provided. Take care of the version though. If your prod server will be tomcat but dev is say Jetty, then you need to provide this jar in your local IDE, but not export it in the WAR file. But if you are developing on tomcat and say deploying on some other server, then this jar has to be bundled with your war file (web-inf/lib folder). Dev and Prod servers need not be same, but take care of the JRE version and dependency on Prod server provided libraries.
JRE is a configurable setting for your server and also your IDE (Eclipse)
Project hierarchy is correct, but you will most probably deploy as WAR file, so your build folder is exported in web-inf/classes. You can verify by opening the WAR file with any zip editor.
Regarding the portability of tomcat-jdbc.jar
Unfortunately this depends on the tomcat library and version. There might be more dependencies of this jar file which might cause problems later on. I would recommend not relying on this jar unless you plan to deploy on tomcat.
you should test your application with the same server you're going to use in production.
to see and set the jre properties eclipse->preferences->java->Installed JREs.
If you export a war file, all files in WebContent will be in the war and the .class files from src folder will be in WEB-INF/classes.
When you uses a server like tomcat, it uses the configuration you setted on it.
If you want the application to always reference your jar, put it in the web-inf lib.
As Daniel has mentioned below,eclipse gets the JREs from the installed JREs under the preferences tab. You can have multiple JREs installed and configured in your eclipse and then select individually for a project and also select default.
3.Your project hierarchy is correct. The runtime will get the JRE from the JAVA_HOME environment variable set on the server.
1) Pool connections, it's a service provided by Application Server (Tomcat in this case). IMHO you have to avoid bind your application with specific implementation, in that case use generic javax.sql.DataSource for expample, and then "inject" or lookup the implmementation from the server. Then if you use Jetty, configure what you want as connection pool implementation https://wiki.eclipse.org/Jetty/Howto/Configure_JNDI_Datasource
So dont´t include in your web-inf/lib tomcat-jdbc.jar.
2) The "org.eclipse.jdt.launching.JRE_CONTAINER" it's a internal variable of eclipse and the value is what you configure on eclipse properties. It's used for eclipse to compile and run your app.
3) in your project structure ".class" files, must go in "WEB-INF/classes". That it's defined by servlet specification. Eclipse automatically generate the correct structure if you select yor project and with right click run "Export" --> "War file". Or you can use maven.
I am trying to use postgres on a EJB in a EAR, but i keep getting the error:
java.lang.ClassNotFoundException: org.postgresql.driver
so my app is not finding the jar. According to what I saw here: How to use 3rd party libraries in glassfish?, I should put the jar on either glassfish3/glassfish/domains/domain1/lib/ext or glassfishv3/glassfish/domains/domain1/lib, I tried both and is not working.
I was also not sure of something, should I add the jar to that folder and then reference the build path (using netbeans) of my app to the jar on that folder? or should I omit this step?
Anyhow, I tried both, referencing it and not doing it (only adding the jar to the folder in glassfish) and is not working.
So, how can I add an external jar to my application (EAR) that is put on a glassfish cluster?