How to deploy .war file to glassfish server? - java

I've created a a .war file and now I want to deploy it to glassfish, but when I deploy it, I received an error
Caused by: Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [com.microsoft.sqlserver.jdbc.SQLServerDriver] not found.
How to fix the error? Can someone give me an detailed instruction for deploy .war file to glassfish server?

Related

java.lang.NoClassDefFoundError when deploying to Glassfish application server

I have created a simple demo rest service which queries Ethereum to get basic information. I am using the Web3j library version 5.0.0 https://mvnrepository.com/artifact/org.web3j/core/5.0.0
I have added the library to the project using Maven. Built the project which compiles successfully and trying to debug it. I am using GlassFish 6.2.51 for my application server.
Any ideas why I am getting the below error?
[2023-02-09 11:44:19,706] Artifact demoapi:war exploded: java.io.IOException: com.sun.enterprise.admin.remote.RemoteFailureException: Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError: org/web3j/protocol/Web3jService.

Provider org.eclipse.persistence.jaxb.JAXBContextFactory could not be instantiated: javax.xml.bind.JAXBException

I am facing following exception when I am running a batch job wherein I am making a webservice call and getting the xml response.
JAXBContext.newInstance("somewsdl");
[Exception [EclipseLink-50000] (Eclipse Persistence Services - 2.6.1.v20150916-55dc7c3): org.eclipse.persistence.exceptions.JAXBException
Exception Description:
The context path "wsdl class" contains no ObjectFactory or jaxb.index,
no external metadata was found in properties Map, and sessions.xml was
found or was invalid.
Internal Exception: Exception [EclipseLink-7095] (Eclipse Persistence Services - 2.6.1.v20150916-55dc7c3): org.eclipse.persistence.exceptions.ValidationException
Exception Description:
The sessions.xml resource [sessions.xml] was not found on the resource
path. Check that the resource name/path and classloader passed to the
SessionManager.getSession are correct. The sessions.xml should be
included in the root of the application's deployed jar, if the
sessions.xml is deployed in a sub-directory in the application's jar
ensure that the correct resource path using "/" not "\" is used.]
Caused by: javax.xml.bind.JAXBException: Provider
org.eclipse.persistence.jaxb.JAXBContextFactory could not be
instantiated: javax.xml.bind.JAXBException
with linked exception:
[Exception [EclipseLink-50000] (Eclipse Persistence Services - 2.6.1.v20150916-55dc7c3): org.eclipse.persistence.exceptions.JAXBException
I am using web logic 1221.1.I am getting this error when I am upgrading my spring to 4.3.3 and quartz version is 2.2.3

Getting runtime error while trying to connect mysql from java

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from [Module "deployment.Sample.war:main" from Service Module Loader].
The above one is my error message.
I have included mysql-connector-java-5.1.35-bin.jar in my class path and it is shown in the libraries as well.
I am using JBoss AS 7.1.0.Final server to run it. How to resolve this error?

java.sql.SQLException: No suitable driver found jdbc:oracle:thin

I am trying to deploy a spring based web application in my local tomcat server. Below are my application details:
Spring based web application (war)
Tomcat 6 server
Java 1.6
Oracle DB
Below are by jdbc configuration:
Configuration for tomcat settings only.
javax.persistence.jdbc.drive=oracle.jdbc.OracleDriver javax.persistence.jdbc.url=jdbc:oracle:thin:#coursesdev.cvbaybp20ew7.eu-west-1.rds.amazonaws.com:1521:DEVCRS
javax.persistence.jdbc.user=test
javax.persistence.jdbc.password=test
I have also added ojdbc6.jar,ojdbc14.jar in my /lib folder
I deployed my war file without any issues. But when my application tries to connect to db it throws the error:"java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:#coursesdev.cvbaybp20ew7.eu-west"
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:#coursesdev.cvbaybp20ew7.eu-west-1.rds.amazonaws.com:1521:DEVCRS
Error Code: 0
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:517)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:272)
at org.springframework.orm.jpa.JpaTransactionManager.createEntityManagerForTransaction(JpaTransactionManager.java:445)
at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:366)
... 81 more
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:#coursesdev.cvbaybp20ew7.eu-west-1.rds.amazonaws.com:1521:DEVCRS
Error Code: 0
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:109)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:330)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:293)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:418)
at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:216)
at org.eclipse.persistence.sessions.server.ConnectionPool.startUp(ConnectionPool.java:504)
at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:484)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:208)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:488)
... 87 more
Caused by: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:#coursesdev.cvbaybp20ew7.eu-west-1.rds.amazonaws.com:1521:DEVCRS
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
... 97 more
I have seen a lot of post with the similar issue but am not sure what i am missing though.
This error is depends on your building structure. Adding jar file to your lib folder is not gonna do anything.
You should add the jar file to your classpath.
If you are building your project by IDE, lets say eclipse, you should add it to .classpath file. If you are using Idea you should add it to your .iml file and etc.
If you are building your project by ant you should add jar address to your build.xml file.
I suppose you are not using maven.

Using EJB3 And Struts 2 Together

As I know, we can use ejb3 and struts 1 in Netbeans under JBoss.
But when i use ejb3 and struts 2, they got error when i deploy in JBoss 6.1.0.
I'm using Netbeans 7.2.1
I try to deploy separate components and they OK, no error.
But if I add module ejb and war to, they have problems.
Error:
15:48:38,023 ERROR [org.apache.struts2.dispatcher.Dispatcher] Dispatcher initialization failed: Unable to load configuration. - bean - vfs:/D:/javaKHANH/JavaKit_t.Khanh/jboss-6.1.0.Final/server/default/deploy/EJB3EntityStruts2Combine.ear/lib/struts2-convention-plugin-2.3.15.3.jar/struts-plugin.xml:32:155
Caused by: Unable to load bean: type:org.apache.struts2.convention.ActionConfigBuilder class:org.apache.struts2.convention.PackageBasedActionConfigBuilder - bean - vfs:/D:/javaKHANH/JavaKit_t.Khanh/jboss-6.1.0.Final/server/default/deploy/EJB3EntityStruts2Combine.ear/lib/struts2-convention-plugin-2.3.15.3.jar/struts-plugin.xml:32:155
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.StrutsException from BaseClassLoader#162f61f{vfs:///D:/javaKHANH/JavaKit_t.Khanh/jboss-6.1.0.Final/server/default/deploy/EJB3EntityStruts2Combine.ear}
Caused by: java.lang.NoClassDefFoundError: org/apache/struts2/StrutsException
at java.lang.Class.getDeclaredConstructors0(Native Method) [:1.7.0_25]
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2483) [:1.7.0_25]
at java.lang.Class.getDeclaredConstructors(Class.java:1891) [:1.7.0_25]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:235) [:2.3.15.3]
15:48:38,115 ERROR [org.apache.catalina.core.StandardContext] Error filterStart
15:48:38,116 ERROR [org.apache.catalina.core.StandardContext] Context [/Struts2War] startup failed due to previous errors
15:48:38,122 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=jboss.web.deployment:war=/Struts2War state=Create mode=Manual requiredState=Installed: org.jboss.deployers.spi.DeploymentException: URL file:/D:/javaKHANH/JavaKit_t.Khanh/jboss-6.1.0.Final/server/default/tmp/vfs/automount3affa1740d934a8/Struts2War.war-667258e36d105fd7/ deployment failed
DEPLOYMENTS IN ERROR: Name -> Error
vfs:///D:/javaKHANH/JavaKit_t.Khanh/jboss-6.1.0.Final/server/default/deploy/EJB3EntityStruts2Combine.ear -> org.jboss.deployers.spi.DeploymentException: URL file:/D:/javaKHANH/JavaKit_t.Khanh/jboss-6.1.0.Final/server/default/tmp/vfs/automount3affa1740d934a8/Struts2War.war-667258e36d105fd7/ deployment failed
DEPLOYMENTS IN ERROR:
Deployment "vfs:///D:/javaKHANH/JavaKit_t.Khanh/jboss-6.1.0.Final/server/default/deploy/EJB3EntityStruts2Combine.ear" is in error due to the following reason(s): org.jboss.deployers.spi.DeploymentException: URL file:/D:/javaKHANH/JavaKit_t.Khanh/jboss-6.1.0.Final/server/default/tmp/vfs/automount3affa1740d934a8/Struts2War.war-667258e36d105fd7/ deployment failed
I'm currently using EJB 3.1 in an EAR with multiple Struts2 WARs deployed on JBoss EAP 6 (JBss AS 7). They works great.
If you are using Maven (if you are not, I suggest you to give it a try, instead of building complex ANT scripts that you will need to rewrite for your next project), be sure to create and deploy the project in the right way. If you are starting it now, use an archetype.
Since you are using Java EE and JBoss, I suggest the jboss-javaee6-webapp Maven Archetype.
I've used it too. Then use an Struts Archetype for the war, and substitute it to the one generated by the JBoss archetype, or modify it manually.

Categories