Using EJB3 And Struts 2 Together - java

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.

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.

Migration from WebSphere to WebLogic

I have an webapplication running on WebSphere using JDK 1.6, Spring 2.5.6 and iceFaces 1.8.2. I need to migrate that webapp to WebLogic. So I updated JDK to 1.8 and Spring to 4.2. The iceFaces framework I dont change because of the number of change on my source code.
When I deploy the application I got the following:
com.sun.faces.config.ConfigurationException: Factory 'javax.faces.lifecycle.ClientWindowFactory' was not configured properly.
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:330)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:236)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:439)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:227)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:705)
Truncated. see log file for complete stacktrace
Caused By: javax.faces.FacesException: com.sun.faces.lifecycle.ClientWindowFactoryImpl
at javax.faces.FactoryFinderInstance.getImplGivenPreviousImpl(FactoryFinderInstance.java:409)
at javax.faces.FactoryFinderInstance.getImplementationInstance(FactoryFinderInstance.java:253)
at javax.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:549)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:283)
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:328)
Truncated. see log file for complete stacktrace
Caused By: java.lang.UnsupportedOperationException
at javax.faces.application.Application.subscribeToEvent(Application.java:1797)
at com.sun.faces.lifecycle.ClientWindowFactoryImpl.<init>(ClientWindowFactoryImpl.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
Truncated. see log file for complete stacktrace
Are there some way to resolve that or I need to change my iceFaces version?
I think i resolved that including jsf 1.2 libs on my war file.
Still getting another errors, soon I update the answer if it worked or not.
UPDATE:
Yes, this solved my problem... Now webapplication is deployed sucessful. (Still getting httpError 500 when open my login page...)

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.

Exception while re-deploying my webapp on tomcat 6

All,
I am having problems redeploying my java webapp packaged as war using maven 3.0 (mvn package) on tomcat 6.0
However if I restart my server completely i donot get this exception and the whole app runs perfectly fine.
Here is the details of catalina log:
WARNING: Error while removing context []
java.lang.NoClassDefFoundError: org/apache/struts2/util/ObjectFactoryDestroyable
at org.apache.struts2.dispatcher.Dispatcher.cleanup(Dispatcher.java:263)
at org.apache.struts2.dispatcher.FilterDispatcher.destroy(FilterDispatcher.java:238)
at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:332)
at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:3731)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4493)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:924)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1035)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1203)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(Containe rBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.util.ObjectFactoryDestroyable
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 15 more
Pls help..!

Categories