Issue Details (XML | Word | Printable)

Key: GLASSFISH-2105
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: mikeg
Reporter: Joe Fialli
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
glassfish

EJB Web Service resource injection occuring after @PostConstruct method is invoked

Created: 19/Jan/07 12:16 PM   Updated: 25/Feb/12 07:42 PM   Resolved: 01/Jun/07 12:57 PM
Component/s: web_services
Affects Version/s: 9.1pe
Fix Version/s: 9.1pe

Time Tracking:
Not Specified

File Attachments: 1. Java Source File PublisherBean.java (5 kB) 19/Jan/07 12:23 PM - Joe Fialli
2. Java Source File Simple.java (13 kB) 19/Jan/07 12:17 PM - Joe Fialli
3. Java Archive File wstxSampleService-ejb.jar (57 kB) 19/Jan/07 12:19 PM - Joe Fialli

Environment:

Operating System: All
Platform: All

Issue Links:
Related
 

Issuezilla Id: 2,105
Tags:
Participants: gfbugbridge, Joe Fialli, mikeg and vijaysr


 Description  « Hide

Copying a JMS Connection Factory idiom used by a Stateless EJB in Java EE
tutorial, this idion does not work for a Web Service EJB. The resource injected
connection factory is null, when the @PostConstruct method is called. Here
is app server log trace of issue.

Component versions involved:
Glassfish promoted build 30.
Developer build of latest WSIT libraries from 1/19/2007.

Begin app server log trace of deployment of web service:

wsgen successful
wsgen successful
DPL5306:EJB Web Service Endpoint [Simple] listening at address
http://scarry-nt.east.sun.com:8080/SimpleService/Simple
DPL5306:EJB Web Service Endpoint [Bank] listening at address
http://scarry-nt.east.sun.com:8080/BankService/Bank
deployed with moduleid = wstxSampleService-ejb
ADM1041:Sent the event to instance:[ModuleDeployEvent – enable
ejb/wstxSampleService-ejb]
acquiring JMS connection for instance wstx.sample.service.Simple@173d72d
assertion failure: connectionFactory should not be null, resource injection for
connectionFactory has not occurred yet.
Simple.makeConnection:Exception: java.lang.NullPointerException

End app server log file.

Workaround for this problem is to call makeConnection()
once within one of the EJB methods when it notices that
connection has not been set yet.

Will attach source file and ejb jar file for this issue.

Fragment of web service ejb illustrating key components

@WebService(portName = "SimpleServiceBinding",
targetNamespace = "http://tempuri.org/"
)
@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class Simple {

private Connection connection = null;

@Resource(mappedName = "jms/ConnectionFactory")
private ConnectionFactory connectionFactory;

/**

  • Creates the connection.
    */
    @PostConstruct
    public void makeConnection() {
    logger.info("acquiring JMS connection for instance " + this.toString());
    try
    Unknown macro: { if (connectionFactory == null) { System.out.println("assertion failure: connectionFactory should not be null, resource injection for connectionFactory has not occurred yet."); } connection = connectionFactory.createConnection(); }
    catch (Throwable t) { // JMSException could be thrown logger.severe("Simple.makeConnection:" + "Exception: +t.toString()); }
    }


No work has yet been logged on this issue.