cannot deploy app on glassfish - eclipse

import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import org.soapwebservice.model.Product;
#WebService
#SOAPBinding(style = Style.RPC)
public interface ProductCatalog {
#WebMethod(action="fetch_Categories",operationName="fetchCategories")
List<String> getProductCategories();
#WebMethod
List<String> getProducts(String category);
#WebMethod
boolean addProduct(String category, String product);
#WebMethod
List<Product> getProductsV2(String category);
}
This is the code it is failing only when I try to include the following line
#SOAPBinding(style = Style.RPC)
and also the the wsdl doesn't change when I try to bind with RPC style.
deploy is failing=Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: Servlet web service endpoint '' failure. Please see server.log for more details.

Related

How to resolve this error on java with selenium?

//Eclipse java code:
package openbrowser;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class OpenChrome {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "d://chromedriver.exe");
WebDriver driver=new ChromeDriver();
}
}
eclipse error
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\Om Murugaa\Downloads\Testing\selenium-server-standalone-3.141.59.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.eclipse.jetty.http.Http1FieldPreEncoder not in module
Adding maven into eclipse resolved this error.

Hibernate and Eclipse error

I'm creating a simple web application with a register form, and I have used Hibernate. But i have this kind of error:
this is the code:
AddUser.java
import java.io.IOException;
import javax.imageio.spi.ServiceRegistry;
import javax.security.auth.login.Configuration;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
#WebServlet("/CreateUser.do")
public class AddUser extends HttpServlet {
private static final long serialVersionUID = 1L;
public AddUser() {
super();
// TODO Auto-generated constructor stub
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Configuration config = new Configuration().configure("hibernate.cfg.xml");
ServiceRegistry servReg = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();
SessionFactory factory = config.buildSessionFactory(servReg);
Session session = factory.openSession();
session.beginTransaction();
User u = new User(request.getParameter("firstname"), request.getParameter("lastname"), request.getParameter("login"), request.getParameter("password"));
session.save(u);
session.getTransaction().commit();
session.close();
RequestDispatcher view = request.getRequestDispatcher("useradd.jsp");
view.forward(request, response);
}
}
This is the error: ERROR
How can I do to solve this problem? Thanks you!
#LuisMuñoz
I add also the error if someone want to see it directly.
HTTP Status 500 – Internal Server Error
Type Exception Report
Message Servlet execution threw an exception
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
java.lang.Error: Unresolved compilation problems:
Cannot instantiate the type Configuration
The method configure() is undefined for the type Configuration
The method getProperties() is undefined for the type Configuration
The method buildSessionFactory(ServiceRegistry) is undefined for the type Configuration
AddUser.doPost(AddUser.java:32)
javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Note The full stack trace of the root cause is available in the server logs.
My Eclipse Page:
ECLIPSE
From the error it looks like there is no method configure for Configuration object. Check the javadocs https://docs.oracle.com/javase/9/docs/api/index.html?javax/security/auth/login/Configuration.html

error inject EJB in JSF project

hi everyone im new in java EE and i want to developpe an application with EJB and JSF and when i want to inject my JAR in web dynamique project i have this error and i dont understood anything please anyone can help me
17:54:06,324 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."PGestion.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."PGestion.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "PGestion.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEJB0406: No EJB found with interface of type 'com.bestofgeeks.gestion.dao.Implement.GestionDAOBean' for binding com.bestofgeeks.gestion.services.ImplService.ImplServiceProduct/product
at org.jboss.as.ejb3.deployment.processors.EjbInjectionSource.getResourceValue(EjbInjectionSource.java:90)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.addJndiBinding(ModuleJndiBindingProcessor.java:211)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:182)
at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:186)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:143)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
... 5 more
17:54:06,341 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-2) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.8.Final
17:54:06,696 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 62) WFLYCLINF0002: Started client-mappings cache from ejb container
17:54:06,777 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "PGestion.war")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"PGestion.war\".INSTALL" => "WFLYSRV0153: Failed to process phase INSTALL of deployment \"PGestion.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEJB0406: No EJB found with interface of type 'com.bestofgeeks.gestion.dao.Implement.GestionDAOBean' for binding com.bestofgeeks.gestion.services.ImplService.ImplServiceProduct/product"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"PGestion.war\".beanmanager"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.deployment.unit.\"PGestion.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"PGestion.war\".beanmanager]",
"jboss.deployment.unit.\"PGestion.war\".batch.artifact.factory is missing [jboss.deployment.unit.\"PGestion.war\".beanmanager]"
]
}
This is the interface DAO:
package com.bestofgeeks.gestion.dao;
import java.util.List;
import javax.ejb.Local;
import com.bestofgeeks.gestion.entity.products;
#Local
public interface IGestion {
public void delete(products p);
public products persiste(products p);
public List<products> selectAll();
}
interface DAO
package com.bestofgeeks.gestion.dao;
import java.util.List;
import javax.ejb.Local;
import com.bestofgeeks.gestion.entity.products;
#Local
public interface IGestion {
public void delete(products p);
public products persiste(products p);
public List<products> selectAll();
}
implement DAO
package com.bestofgeeks.gestion.dao.Implement;
import java.util.List;
import javax.ejb.Stateless;
import javax.management.Query;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.bestofgeeks.gestion.dao.IGestion;
import com.bestofgeeks.gestion.entity.products;
#Stateless
public class GestionDAOBean implements IGestion{
#PersistenceContext(unitName = "Gestion_PU")
EntityManager entityManager;
#Override
public void delete(products p) {
// TODO Auto-generated method stub
entityManager.remove(p);
}
#Override
public products persiste(products p){
// TODO Auto-generated method stub
entityManager.persist(p);
return p;
}
#Override
public List<products> selectAll() {
// TODO Auto-generated method stub
Query query = (Query) entityManager.createQuery("SELECT o from products o");
return ((javax.persistence.Query) query).getResultList();
}
}
and this is package service of my project
this service have interface Iservice and a package of implement class name ImplServiceProduct
for Iservice this is the code
package com.bestofgeeks.gestion.services;
import java.util.List;
import javax.ejb.Local;
import com.bestofgeeks.gestion.entity.products;
#Local
public interface Iservices {
public List<products> selectAll();
public void delete(products p);
public products persiste(products p);
}
for implement service
package com.bestofgeeks.gestion.services.ImplService;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import com.bestofgeeks.gestion.dao.Implement.GestionDAOBean;
import com.bestofgeeks.gestion.entity.products;
import com.bestofgeeks.gestion.services.Iservices;
#Stateless
public class ImplServiceProduct implements Iservices{
#EJB
GestionDAOBean product;
#Override
public List<products> selectAll() {
return product.selectAll();
}
#Override
public void delete(products p) {
// TODO Auto-generated method stub
product.delete(p);
}
#Override
public products persiste(products p) {
// TODO Auto-generated method stub
return product.persiste(p);
}
}
for the entity
package com.bestofgeeks.gestion.entity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table
public class products {
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
#Column
private String nameproduct;
#Column
private String reference;
#Column
private Date dateposte;
public products(String nameproduct, String reference, Date dateposte) {
super();
this.nameproduct = nameproduct;
this.reference = reference;
this.dateposte = dateposte;
}
public products() {
super();
// TODO Auto-generated constructor stub
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNameproduct() {
return nameproduct;
}
public void setNameproduct(String nameproduct) {
this.nameproduct = nameproduct;
}
public String getRefence() {
return reference;
}
public void setRefences(String reference) {
this.reference = reference;
}
public Date getDateposte() {
return dateposte;
}
public void setDateposte(Date dateposte) {
this.dateposte = dateposte;
}
}
and for my jsf project
i create a controller
this is the code
package com.bestofgeeks.gestion.controllers;
import javax.annotation.ManagedBean;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import com.bestofgeeks.gestion.services.Iservices;
#RequestScoped #ManagedBean
public class myProduct {
#EJB
public String name = "noredine";
Iservices service;
}
You must inject the local interface not the bean:
#EJB
IGestion product;
As #kukeltje says in the comment:
Read the error: (emphasis mine) "No EJB found with interface of type
'com.bestofgeeks.gestion.dao.Implement.GestionDAOBean" and what it
references is a impl, not
an interface!

Weld cannot find CDI producer

WildFly 10.1 used. In modules added single module that contains jar file with interface EzRegistryService.
Producer code:
package com.ejbtest;
import org.apache.log4j.Logger;
import javax.ejb.EJB;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Default;
import javax.enterprise.inject.Produces;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class Resources {
private static final Logger log = Logger.getLogger(Resources.class);
public static final String jndiName = "java:global/ejbtest.main/EzRegistryServiceBean!com.ejbtest.EzRegistryService";
//also didn't work
//#Produces
//#EJB(lookup = jndiName)
//private EzRegistryService ezRegistryService;
// didn't work
#Produces
public EzRegistryService getEzRegistryService() {
log.info("getEzRegistryService called");
try {
InitialContext ctx = new InitialContext();
Object service = ctx.lookup(jndiName);
log.info("Found: " + service);
return (EzRegistryService) service;
} catch (NamingException e) {
log.error("Exception while getting EzRegistryService", e);
return null;
}
}
}
Singleton bean:
package com.ejbtest;
import org.apache.log4j.Logger;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
#Singleton
#Startup
public class MyGateStartup {
private static final Logger log = Logger.getLogger(MyGateStartup.class);
//#EJB(mappedName = Resources.jndiName) //works fine
#Inject
private EzRegistryService service;
#PostConstruct
public void start() {
log.info("MyGateStartup started");
//...
}
#PreDestroy
public void end() {
//...
log.info("MyGateStartup stopped");
}
}
beans.xml in WEB-INF folder:
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1"
bean-discovery-mode="all">
</beans>
WildFly can't deploy resulting war-file:
2017-03-14 13:15:05,237 MSC service thread 1-8 INFO [org.jboss.weld.deployer] WFLYWELD0006: Starting Services for CDI deployment: ejbtest.gate-1.0-SNAPSHOT.war
2017-03-14 13:15:05,241 MSC service thread 1-8 INFO [org.jboss.weld.deployer] WFLYWELD0009: Starting weld service for deployment ejbtest.gate-1.0-SNAPSHOT.war
2017-03-14 13:15:05,299 MSC service thread 1-6 ERROR [org.jboss.msc.service.fail] MSC000001: Failed to start service jboss.deployment.unit."ejbtest.gate-1.0-SNAPSHOT.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."ejbtest.gate-1.0-SNAPSHOT.war".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.6.Final.jar:1.2.6.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_121]
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type EzRegistryService with qualifiers #Default
at injection point [BackedAnnotatedField] #Inject private com.ejbtest.MyGateStartup.service
at com.ejbtest.MyGateStartup.service(MyGateStartup.java:0)
Why CDI can't find producer in Resources class?
In CDI specification, it is written in section 2.5:
Producer methods (as defined in Producer methods) whose bean class does not have a bean defining annotation are not discovered....
The class where you have your #Produces annotated method must be a CDI bean. Try giving it a scope :)
Looks like CDI is not managing your Resources class.
Once it's just a factory bean, you can annotated it with #ApplicationScoped:
#ApplicationScoped
public class Resources {
...
}

WELD-001408 Unsatisfied dependencies

I have a very famous error, but I can't solve it.
I'm trying to run arqullian test for my application.
I've done everything according to the official documentation.
The long search for solution to the problem given nothing.
16:49:42,713 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."test.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Sender] with qualifiers [#Default] at injection point [[field] #Inject com.test.test2.ejb.AppManagerBean.sender]
at org.jboss.as.weld.services.WeldService.start(WeldService.java:83)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_13]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_13]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_13]
Caused by: org.jboss.weld.exceptions.DeploymentException:
WELD-001408 Unsatisfied dependencies for type [Sender] with qualifiers [#Default]
at injection point [[field] #Inject com.test.test2.ejb.AppManagerBean.sender]
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:275)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:244)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:107)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:127)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:346)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:331)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:366)
at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83)
at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
... 5 more
My test class:
package com.highstreetlabs.wlcome.rest;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
import com.test.test2.ejb.AppManager;
import com.test.test2.ejb.Storage;
import com.test.test2model.Customer;
import com.test.test2.rest.model.ProximityModel;
import com.test.test2.util.EntityManagerProducer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.json.simple.parser.ParseException;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.ejb.EJB;
import javax.inject.Inject;
#RunWith(Arquillian.class)
public class CustomerCollectionResourceTest {
#Deployment
public static WebArchive createTestArchive() {
return ShrinkWrap.create(WebArchive.class, "test.war")
.addClasses(CustomerCollectionResource.class, EntityManagerProducer.class,
AppManager.class, Storage.class,
ParseException.class, Sender.class)
.addPackage(Customer.class.getPackage())
.addPackage(Result.class.getPackage())
.addPackage(NotFoundException.class.getPackage())
.addPackage(CustomerPhotoResource.class.getPackage())
.addPackage(ProximityModel.class.getPackage())
.addAsResource("import.sql")
.addAsManifestResource(EmptyAsset.INSTANCE, "META-INF/beans.xml")
.addAsManifestResource("test-ds.xml", "test-ds.xml");
}
#Inject
CustomerCollectionResource resource;
#EJB
AppManager manager;
#Test
public void testList() throws Exception {
resource = new CustomerCollectionResource();
resource.list(null);
}
}
AppManagerBean.java
import com.google.android.gcm.server.Constants;
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
import com.google.common.base.Strings;
import com.test.test2.json.JacksonObjectMapperProvider;
import com.test.test2.model.*;
import com.test.test2.rest.HttpStatusException;
import com.test.test2.rest.NotFoundException;
import com.test.test2.rest.model.ProximityModel;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.Asynchronous;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.persistence.*;
import javax.persistence.criteria.*;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.List;
/**
* Stateless EJB bean containing entire business logic implementation
*/
#Local(AppManager.class)
#Stateless
public class AppManagerBean implements AppManager {
public static final String
GCM_ENTER_ACTION = "enter",
GCM_EXIT_ACTION = "exit",
PARAM_DATA_JSON = "proximityModel",
PARAM_CUSTOMER_ID = "customerId",
PARAM_ACTION = "action";
#Inject
EntityManager em;
#Inject
Sender sender;
....
}
And finally class for test CustomerCollectionResource
#Path("customer/")
#RequestScoped
public class CustomerCollectionResource {
final static int CACHEABLE_SECONDS = 0;
#EJB
private AppManager manager;
#GET
#Produces(MediaType.APPLICATION_JSON)
public Response list(#QueryParam("email") String email) {
final List<Customer> entities = manager.listCustomers(email);
if(entities.size() == 0)
throw new NotFoundException("There is no any customer");
ListModel<ListItem> result = new ListModel<ListItem>(entities.size());
result.itemType = ListItem.MEDIA_TYPE;
final UriBuilder itemLink = UriBuilder.fromResource(CustomerResource.class);
for (Customer entity : entities) {
result.add(new ListItem(entity.getName(), itemLink.build(entity.getId())));
}
CacheControl cc = new CacheControl();
cc.setMaxAge(CACHEABLE_SECONDS);
cc.setPrivate(true);
return Response.ok(result).cacheControl(cc).build();
}
}
Sender Producer
public class GcmSenderProducer {
#Resource String senderId;
#Produces public Sender getSender() {
return new Sender(senderId);
}
}
Yes, I also think the GcmSenderProducer is missing so the Sender class cannot be injected propperly since it looks like it has no no-arg constructor and I guess the constructor.